summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO48
-rwxr-xr-xPKGBUILD71
-rwxr-xr-xboot-kernel-list13
-rwxr-xr-xexchange-info114
-rwxr-xr-ximage-mount297
-rw-r--r--image-mount.131
-rwxr-xr-ximage-umount218
-rwxr-xr-xioscheduler-list13
-rwxr-xr-xmacinstall490
-rw-r--r--macinstall.1116
-rw-r--r--macinstall.conf103
-rwxr-xr-xpendrive-detect46
-rwxr-xr-xsimonas-scripts60
-rw-r--r--simonas-scripts.changelog16
-rwxr-xr-xuuid-change101
15 files changed, 1737 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..2ea719463aae
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,48 @@
+pkgbase = simonas-scripts
+ pkgdesc = Bash unique command for mount image files (iso, vms, crypto, squashfs), detect pendrive device name, list all kernels, list all i/o schedulers, copy install files.
+ pkgver = 0.1.0
+ pkgrel = 1
+ changelog = simonas-scripts.changelog
+ arch = any
+ license = GPL3
+ depends = bash
+ depends = awk
+ depends = util-linux
+ depends = sed
+ depends = sudo
+ optdepends = qemu: {image-mount} for mount qemu image files
+ optdepends = fuseiso: {image-mount} another way to mount iso image files
+ optdepends = cryptsetup: {image-mount} for mount crypto image files
+ optdepends = squashfs-tools: {image-mount} for squashfs image files
+ optdepends = e2fsprogs: {uuid-change} to change uuid to ext4 volumes with command tune2fs
+ optdepends = ntfs-3g: {uuid-change} to change uuid to ntfs volumes with command ntfslabel
+ optdepends = dosfstools: {uuid-change} to change uuid to fat32 volumes with command mkdosfs
+ optdepends = btrfs-progs: {uuid-change} to change uuid to btrfs volumes with command btrfstune
+ backup = etc/macinstall.d/macinstall.conf
+ source = boot-kernel-list
+ source = image-mount
+ source = image-umount
+ source = ioscheduler-list
+ source = pendrive-detect
+ source = simonas-scripts
+ source = uuid-change
+ source = macinstall
+ source = macinstall.conf
+ source = image-mount.1
+ source = macinstall.1
+ source = exchange-info
+ md5sums = 3f5599c3588f01b625aa9feb0a0e8b99
+ md5sums = a66639338ea804997cc38af80d9249ea
+ md5sums = 861389b38ba1cd9e6bcc47b6c469e383
+ md5sums = c58f5737bb41c8af2bff7dd24a3d2723
+ md5sums = 40ef9e0d1831cc1865208bf52eaa2cef
+ md5sums = f5466c638c1692bd3b244d0fbb461914
+ md5sums = 3189eb5ae50a9ddce43c8820c35ba2b0
+ md5sums = 962dd112eb6d348f8a2efdd69b982359
+ md5sums = 6bdfded6596cd064703e37e5657a351a
+ md5sums = 261d420ae53438b3fadda33059686a33
+ md5sums = f3197a3b2aad5cb79b5dbab0d35fd0f9
+ md5sums = ad9c80d0c54c4a91f6f467ffd567b0db
+
+pkgname = simonas-scripts
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100755
index 000000000000..3ebbe43c9af0
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,71 @@
+# Maintainer: Simona <simona.pisano[at]gmail[dot]com>
+pkgname=simonas-scripts
+pkgver=0.1.0
+pkgrel=1
+pkgdesc="Bash unique command for mount image files (iso, vms, crypto, squashfs), detect pendrive device name, list all kernels, list all i/o schedulers, copy install files."
+
+#t does not need to be included in the source array
+changelog=$pkgname.changelog
+
+arch=('any')
+license=('GPL3')
+
+#util-linux -> lsblk
+depends=('bash' 'awk' 'util-linux' 'sed' 'sudo' )
+optdepends=('qemu: {image-mount} for mount qemu image files'
+ 'fuseiso: {image-mount} another way to mount iso image files'
+ 'cryptsetup: {image-mount} for mount crypto image files'
+ 'squashfs-tools: {image-mount} for squashfs image files'
+ 'e2fsprogs: {uuid-change} to change uuid to ext4 volumes with command tune2fs'
+ 'ntfs-3g: {uuid-change} to change uuid to ntfs volumes with command ntfslabel'
+ 'dosfstools: {uuid-change} to change uuid to fat32 volumes with command mkdosfs'
+ 'btrfs-progs: {uuid-change} to change uuid to btrfs volumes with command btrfstune' )
+
+
+source=( "boot-kernel-list"
+ "image-mount"
+ "image-umount"
+ "ioscheduler-list"
+ "pendrive-detect"
+ "simonas-scripts"
+ "uuid-change"
+ "macinstall"
+ "macinstall.conf"
+ "image-mount.1"
+ "macinstall.1"
+ "exchange-info" )
+
+backup=('etc/macinstall.d/macinstall.conf')
+
+md5sums=('3f5599c3588f01b625aa9feb0a0e8b99'
+ 'a66639338ea804997cc38af80d9249ea'
+ '861389b38ba1cd9e6bcc47b6c469e383'
+ 'c58f5737bb41c8af2bff7dd24a3d2723'
+ '40ef9e0d1831cc1865208bf52eaa2cef'
+ 'f5466c638c1692bd3b244d0fbb461914'
+ '3189eb5ae50a9ddce43c8820c35ba2b0'
+ '962dd112eb6d348f8a2efdd69b982359'
+ '6bdfded6596cd064703e37e5657a351a'
+ '261d420ae53438b3fadda33059686a33'
+ 'f3197a3b2aad5cb79b5dbab0d35fd0f9'
+ 'ad9c80d0c54c4a91f6f467ffd567b0db')
+
+package() {
+ cd "$srcdir"
+ install -Dm 755 "$srcdir/simonas-scripts" "$pkgdir/usr/bin/simonas-scripts"
+ install -Dm 755 "$srcdir/pendrive-detect" "$pkgdir/usr/bin/pendrive-detect"
+ install -Dm 755 "$srcdir/image-mount" "$pkgdir/usr/bin/image-mount"
+ install -Dm 755 "$srcdir/image-umount" "$pkgdir/usr/bin/image-umount"
+ install -Dm 755 "$srcdir/boot-kernel-list" "$pkgdir/usr/bin/boot-kernel-list"
+ install -Dm 755 "$srcdir/ioscheduler-list" "$pkgdir/usr/bin/ioscheduler-list"
+ install -Dm 755 "$srcdir/uuid-change" "$pkgdir/usr/bin/uuid-change"
+ install -Dm 755 "$srcdir/macinstall" "$pkgdir/usr/bin/macinstall"
+ install -Dm 755 "$srcdir/exchange-info" "$pkgdir/usr/bin/exchange-info"
+ install -Dm 755 "$srcdir/macinstall.conf" "$pkgdir/etc/macinstall.d/macinstall.conf"
+ install -Dm 644 "$srcdir/image-mount.1" "$pkgdir/usr/share/man/man1/image-mount.1"
+ install -Dm 644 "$srcdir/macinstall.1" "$pkgdir/usr/share/man/man1/macinstall.1"
+
+}
+
+
+
diff --git a/boot-kernel-list b/boot-kernel-list
new file mode 100755
index 000000000000..a86fdb7d6807
--- /dev/null
+++ b/boot-kernel-list
@@ -0,0 +1,13 @@
+#!/bin/bash
+# Simona Pisano - 2018-11-18 -
+# simona-scripts
+# Libertamente utilizzabile sotto GPL v3
+
+ #alias sget-kernel-list='
+ search=`uname -r`; printf "Kernels /boot :\n";
+ for file in /boot/vmlinuz* ; do
+ info=`file $file`; file="${file:6:99}"; ver=${info#*version}; ver=${ver%\(*}; [[ $ver =~ $search ]] && flag="<-used" || flag="";
+ printf "%-28s %s %24s %s\n" "$file" "->" "$ver" "$flag";
+ done;
+ #'
+
diff --git a/exchange-info b/exchange-info
new file mode 100755
index 000000000000..de5289e52a69
--- /dev/null
+++ b/exchange-info
@@ -0,0 +1,114 @@
+#!/bin/bash
+# Simona Pisano - 2018-12-18
+# simona-scripts
+# Libertamente utilizzabile sotto GPL v3
+
+#exchange-info() {
+ #read echange from internet
+ query_http="http://free.currencyconverterapi.com/api/v5/convert?q=EUR_USD&compact=y"
+ currency_echange="EUR_USD"
+ raw_echange=`wget -q -O - ${query_http}`
+ value=0
+ #echo "raw_echange=$raw_echange"
+ #raw_echange={"EUR_USD":{"val":1.14075}}
+
+ if [[ $raw_echange != "" ]] ; then
+ if [[ ${raw_echange:1:10} == "\"${currency_echange}\":" ]] ; then
+ value=${raw_echange#*\"val\":} #estract to right of "val":
+ if [[ ${value:${#value}-2:2} == "}}" ]]; then
+ value=${value:0:${#value}-2} #remove last two {{
+ if [[ $value != "" ]] ; then
+ echo -n "Echange EURO vs US DOLLAR: 1€ = ${value}\$"
+ fi
+ fi
+ fi
+
+ if [[ $value != "" ]]; then
+ #read cfg with yesterday's echange
+ today=`date +%Y%m%d`
+ file_name="${HOME}/.last_exch.log"
+ if [[ -r $file_name ]]; then
+
+ count_row=0
+ prop="blank"
+ cont=""
+ last_prop="blank"
+ last_cont=""
+ while read line ; do
+ let count_row+=1
+
+ last_prop=$prop
+ last_cont=$cont
+ prop=${line%=*}
+ cont=${line#*=}
+
+ if [[ $count_row -gt 2 ]]; then #can't happen
+ echo -n " [something goes wrong (1) !!!] "
+ echo -n -e "Value-${today}-${currency_echange}=${value}\n" >$file_name #reset file
+ break;
+ fi
+
+ done < $file_name
+
+ #newer value
+
+ get_date=${prop:6:8}
+
+ if [[ $get_date == "" ]]; then #to-do correct check string
+ echo -n " [something goes wrong (2) !!!] "
+ echo -n "Value-${today}-${currency_echange}=${value}\n" >$file_name
+ echo ""
+ exit
+ fi
+
+ if [[ $today != $get_date ]]; then #add today's new value and store old one
+ echo -n -e "${prop}=${cont}\n" >$file_name
+ echo -n -e "Value-${today}-${currency_echange}=${value}\n" >>$file_name
+ fi
+
+ #older value
+
+ [[ $last_prop != "blank" ]] && { prop=$last_prop; cont=$last_cont; }
+
+ if [[ $prop != "blank" ]]; then
+ # ho prop e last_prop da scegliere
+ get_date=${prop:6:8}
+
+ if [[ $get_date == "" ]]; then #to-do correct check string
+ echo -n " [something goes wrong (3) !!!] "
+ echo -n -e "Value-${today}-${currency_echange}=${value}\n" >$file_name
+ echo -e -n "\n"
+ exit
+ fi
+
+ #data 20181208
+ #idx 01234567
+ if [[ $get_date != $today ]]; then
+ calc=`echo "$value - $cont" | bc`
+ [[ ${calc:0:1} == "." ]] && calc="0${calc}" #add 0 if start with .459859
+ [[ ${calc:0:1} != "-" ]] && calc="+${calc}" #add + if not negative sign present
+ echo -n " (today is: ${today:6:2}/${today:4:2}/${today:0:4}, "\
+ "diff from ${get_date:6:2}/${get_date:4:2}/${get_date:0:4} :${calc})"
+ fi
+
+ else #if file blank
+ echo -e -n "Value-${today}-${currency_echange}=${value}\n" >$file_name
+ fi
+ else #if file do not exist
+ #Value-20181208-EUR_USD
+ #0123456789
+ # 10 15 19
+ echo -e -n "Value-${today}-${currency_echange}=${value}\n" >$file_name
+ fi
+ echo -e -n "\n"
+ fi
+ else
+ echo "Offline."
+ fi
+#}
+
+#exchange-info()
+
+
+
+
diff --git a/image-mount b/image-mount
new file mode 100755
index 000000000000..258277677b8d
--- /dev/null
+++ b/image-mount
@@ -0,0 +1,297 @@
+#!/bin/bash
+# Simona Pisano - 2018-11-18 -
+# simona-scripts
+# Libertamente utilizzabile sotto GPL v3
+#srun-mount-img() {
+
+#to-do add input parameters
+
+[[ $1 == "" ]] && exit 0 #TO-DO attivare invece la richiesta dei parametri?
+
+#color Foreground Background
+#black 30 40
+#red 31 41
+#green 32 42
+#yellow 33 43
+#blue 34 44
+#magenta 35 45
+#cyan 36 46
+#white 37 47
+EchoReset="\e[0m"
+echo -e -n "$EchoReset"
+OK="\E[32;40m[OK]${EchoReset}"
+WARN="\E[33;40m[OK]${EchoReset}"
+ERR="\E[31;40m[OK]${EchoReset}"
+#echo -e "$OK $WARN $ERR"
+
+# ------------------------------------------------------------------------------------------------------------------------
+# INPUT PARAMETER --------------------------------------------------------------------------------------------------------
+# ------------------------------------------------------------------------------------------------------------------------
+
+allow_formats="raw qcow2 vdi blkdebug blklogwrites blkreplay blkverify bochs cloop copy-on-read dmg file ftp ftps gluster host_cdrom host_device http https iscsi iser luks nbd nfs null-aio null-co nvme parallels qcow qed quorum rbd replication sheepdog ssh throttle vhdx vmdk vpc vvfat"
+allow_formats_iso="iso nrg bin img mdf"
+allow_formats_crypto="tcrypt plain luks luks1 luks2 loopaes"
+
+if [[ $1 == "-h" || $1 == "--help" ]] ; then
+ cat << EOF
+image-mount command help
+
+Usage
+ image-mount [--help|-h]"
+ image-mount [path/]file-name[.format] [format | #partition] [path-where-mount | #partition] [--force-iso-stdmount]
+ --force-iso-stdmount -> force in iso sudo mount 'mount -o loop' instead 'fuseiso'
+ -y --ask-confirm -> ask confirm before proceeed
+
+Warnings
+ 1) part# in in format 0-9 with one integer value
+ 2) format must be explicily specified if file extension do not say itself the correct format.
+ 3) all parameters are case sensitive.
+
+Default pars:
+ image-mount image.raw raw 0 \${HOME}/mount/image
+Minimal usate:
+ image-mount file.ext
+Common usage:
+ image-mount file.ext 2
+
+Full allowed format list (with 'more partitions inside' supported)
+----------------------------------------------------------------------------------------------------
+Virtual images allowed ('qemu' for this function package required):
+ ${allow_formats}
+Iso images (fuse standard mount or optional 'fuseiso' package required):
+ ${allow_formats_iso}
+Crypto images ('cryptsetup' for this function package is required):
+ ${allow_formats_crypto}
+Squash readonly file (can ben modified, saved on umount) (package 'squashfs-tools' required):
+ sqhashfs
+EOF
+
+ exit 0
+elseif [[ $1 == "--version" ]]
+ echo "image-mount Version 0.0 (simonascripts package)"
+ exit 0
+fi
+
+# DEFAULTS -------------------------------------------------------------------------------------------------------------
+full_path_image="image.raw"
+n_part=0
+#n_part=2
+mount_where="$HOME/mount/image"
+format="" #something required (no default allowed)
+
+# PARS -----------------------------------------------------------------------------------------------------------------
+#parameter $1: name file used as image
+par=$1; [[ $1 != "" && ${par:0:1} != "-" ]] && full_path_image=$1
+image="${full_path_image##*/}" # estract substring: take only final part after last '/' char
+[[ ! -f "$full_path_image" ]] && { echo -e "$ERR File image '$full_path_image' not found!! Exit."; exit 1; }
+
+ext="${image##*.}" # extract substring: take only final part after last '.' char
+[[ $ext != "" ]] && format=$ext
+
+#parameter $2: format or partition number
+case $2 in
+ [0-9]* ) n_part=$2 ;;
+ [a-z]* ) format=$2 ;;
+esac
+
+#parameter $3: mount path or partition number
+case $3 in
+ [0-9]* ) n_part=$3 ;;
+ * ) par=$3; [[ $3 != "" && ${par:0:1} != "-" ]] && format=$3 ;;
+esac
+
+[[ $format == "" ]] && { echo "Parameter missing. Please insert format as second command parameter."; exit 1; }
+if [[ ! $allow_formats =~ $format &&
+ ! $allow_formats_iso =~ $format &&
+ ! $allow_formats_crypto =~ $format &&
+ ! "squashfs" =~ $format ]] ; then
+ echo -e "$ERR Format $format unknown or not supported. Sorry. Exit."
+ exit 1
+fi
+
+#parameter 4: mount path
+par=$4; [[ $4 != "" && ${par:0:1} != "-" ]] && mount_where=$4
+
+[[ ! -d $mount_where ]] && { echo "[TO-DO] Please create $mount_where with 'mkdir -p $mount_where'. Exit."; exit 1; }
+
+#display default
+#[[ $full_path_image == "image.raw" ]] && echo "Default: 'image.raw' image file"
+[[ $allow_formats =~ $format && $n_part == 0 ]] && echo "Default: partition number 0"
+[[ $mount_where == "$HOME/mount/image" ]] && echo "Default: '$HOME/mount/image' dir where mount image"
+
+[[ -d "$mount_where/$image" ]] && { echo -e "$ERR $image found. umount/rm -r \"$mount_where/$image\". Exit."; exit 1; }
+
+forceIsoStdMount=false #default par
+flagAskConfirm=false
+while [ $# -ne 0 ] ; do
+ case $1 in
+ --force-iso-stdmount) forceIsoStdMount=true ;;
+ -y|--ask-confirm) flagAskConfirm=true ;;
+ *) ;;
+ esac
+ shift
+done
+
+echo "Now mounting image <$image> format <$format> on path <$mount_where>, partition number <$n_part>."
+if [[ "$flagAskConfirm" == true ]] ; then
+ echo -n "Continue? (Y/N): "; read ask
+ [[ ! $ask =~ ^(yes|y|YES|y|s|S|si|SI|sì)$ ]] && { echo "Exit forced by user."; exit 0; }
+fi
+
+
+# ------------------------------------------------------------------------------------------------------------------------
+# WORK -------------------------------------------------------------------------------------------------------------------
+# ------------------------------------------------------------------------------------------------------------------------
+
+mkdir -p "$mount_where/$image"
+[[ $? -ne 0 ]] && { echo -e "$ERR Fail creation dir $mount_where/$image! Exit."; exit 1; }
+
+cd "$mount_where/$image"
+if [[ $? -ne 0 ]] ; then
+ echo -e "$ERR Fail 'cd \"$mount_where/$image\"' cmd! Exit."
+ rmdir "$mount_where/$image" #undo
+ [ $? -ne 0 ] && echo -e "$WARN Fail undo removing dir 'rmdir $mount_where/$image' cmd!"
+ exit 1
+fi
+echo "[OK] prepare success."
+
+# vm images -----------------------------------------------------------------------------------------------------------
+if [[ $allow_formats =~ $format ]] ; then
+
+ [[ ! -r /bin/qemu-nbd ]] && { echo -e "$ERR Missing qemu-nbd cmd (qemu pkg?)! Exit"; exit 1; }
+
+ sudo modprobe nbd max_part=63
+ [[ $? -ne 0 ]] && { echo -e "$ERR Fail 'modprobe nbd max_part=63' cmd! Exit."; exit 1; }
+ echo "[OK] nbd module prepared... success."
+
+ sudo qemu-nbd -c /dev/nbd0 --format=$format "$full_path_image"
+ [[ $? -ne 0 ]] && { echo -e "$ERR Fail 'qemu-nbd -c /dev/nbd0 --format=$format \"$full_path_image\"' cmd! Exit."; exit 1; }
+ echo -e "$OK qemu nbd started... success."
+
+ if [[ n_part -eq 0 ]] ; then
+ #ls /dev/nbd0p?
+ #echo -n "* "; for dev_part in /dev/nbd0p* ; do echo $dev_part; done
+ #echo -n "? "; for dev_part in /dev/nbd0p? ; do echo $dev_part; done
+ #echo -n "[0-9] "; for dev_part in /dev/nbd0p[0-9] ; do echo $dev_part; done
+ for dev_part in /dev/nbd0p[0-9] ; do
+ part=${dev_part:10:1} # estrae substring: dopo n-esimo carattere (0 based) per N caratteri
+ mkdir -p "$mount_where/$image/$part"
+ if [ $? -ne 0 ]; then
+ echo -e "$WARN Fail creation dir $mount_where/$image/$part and mount part $part..."
+ els
+ sudo mount $dev_part "$mount_where/$image/$part"
+ if [ $? -ne 0 ]; then
+ sudo qemu-nbd -d /dev/nbd0 >/dev/null #undo
+ [[ $? -ne 0 ]] && echo -e "$WARN Fail undo 'qemu-nbd -d /dev/nbd0' cmd!" || echo -e "$OK qemu nbd stopped... success."
+ #rmdir -r "$mount_where/$image" #undo
+ #[ $? -ne 0 ] && echo "Can't execute command 'rmdir $mount_where/$image'!"
+ echo -e "$ERR Fail'mount $dev_part $mount_where/\"$image/$part\"' cmd! Exit."
+ exit 1
+ fi
+ fi
+ echo -e "$OK Mount $dev_part ... [part# $part] on $mount_where/$image/$part success."
+ done
+ else
+ sudo mount /dev/nbd0p$n_part "$mount_where/$image"
+ if [ $? -ne 0 ]; then
+ sudo qemu-nbd -d /dev/nbd0 >/dev/null #undo
+ [[ $? -ne 0 ]] && echo -e "$WARN Fail undo 'qemu-nbd -d /dev/nbd0' cmd!" || echo -e "$OK qemu nbd stopped... success."
+ rmdir "$mount_where/$image" #undo
+ [ $? -ne 0 ] && echo -e "$WARN Fail undo removing dir 'rmdir $mount_where/$image' cmd!"
+ echo -e "$ERR Part num $n_part really exist? Fail mount /dev/nbd0p$n_part on $mount_where/\"$image\"'! Exit."
+ exit 1
+ fi
+ echo -e "$OK Mount /dev/nbd0p$n_part ... [partition $n_part] on $mount_where/$image success."
+ fi
+
+# iso images ----------------------------------------------------------------------------------------------------------
+elif [[ $allow_formats_iso =~ $format ]] ; then
+ iso_mount_type=""
+ if [[ -r /bin/fuseiso && "$forceIsoStdMount" != true ]] ; then
+
+ fuseiso "$full_path_image" "$mount_where/$image"
+ if [ $? -ne 0 ]; then
+ rmdir "$mount_where/$image" #undo
+ [ $? -ne 0 ] && echo -e "$WARN Fail undo removing dir 'rmdir $mount_where/$image' cmd!"
+ echo -e "$ERR Fail'fuseiso "$full_path_image" /mnt' cmd! Exit."
+ exit 1
+ fi
+ echo -e "$OK Mount (fuseiso) $mount_where/$image success."
+ iso_mount_type="fuseiso"
+ else
+
+ sudo mount -o loop "$full_path_image" "$mount_where/$image"
+ if [ $? -ne 0 ]; then
+ rmdir "$mount_where/$image" #undo
+ [ $? -ne 0 ] && echo -e "$WARN Fail undo removing dir 'rmdir $mount_where/$image' cmd!"
+ echo -e "$ERR Fail 'mount -o loop \"$full_path_image\" \"$mount_where/$image\"' cmd! Exit."
+ exit 1
+ fi
+
+ echo -e "$OK Mount (sudo mount loop) $mount_where/$image success."
+ iso_mount_type="mount-loop"
+
+ fi
+
+# crypto images -------------------------------------------------------------------------------------------------------
+elif [[ $allow_formats_crypto =~ $format ]] ; then
+
+ [[ ! -r /bin/cryptsetup ]] && { echo -e "$ERR Missing cryptsetup cmd (cryptsetup pkg?)! Exit"; exit 1; }
+
+ sudo cryptsetup open --type $format "$full_path_image" crypt-disk
+ if [ $? -ne 0 ]; then
+ rmdir "$mount_where/$image" #undo
+ [ $? -ne 0 ] && echo -e "$WARN Fail removing dir 'rmdir $mount_where/$image' cmd!"
+ echo -e "$ERR Fail 'cryptsetup open --type $format \"$full_path_image\" crypt-disk' cmd! Exit."
+ exit 1
+ fi
+ sudo mount -o uid=1000 /dev/mapper/crypt-disk "$mount_where/$image"
+ if [ $? -ne 0 ]; then
+ sudo cryptsetup close crypt-disk #undo
+ [ $? -ne 0 ] && echo -e "$WARN Fail 'cryptsetup close crypt-disk' cmd!"
+ rmdir "$mount_where/$image" #undo
+ [ $? -ne 0 ] && echo -e "$WARN Fail undo removing dir 'rmdir $mount_where/$image' cmd!"
+ echo -e "$ERR Fail 'mount -o uid=1000 /dev/mapper/crypt-disk \"$mount_where/$image\"' cmd! Exit."
+ exit 1
+ fi
+
+ echo -e "$OK Mount 'pwd-crypt..."
+
+# sqhash images -------------------------------------------------------------------------------------------------------
+elif [[ "squashfs" =~ $format ]] ; then
+ [[ ! -r /bin/mksquash ]] && { echo -e "$ERR Missing mksqhash cmd (squash-tool pkg?)! Exit"; exit 1; }
+
+ cp "$full_path_image" "$mount_where/$image/."
+ if [[ $? -ne 0 ]] ; then
+ echo -e "$ERR Fail copy squashfs image! Exit."
+ rmdir "$mount_where/$image" #undo
+ [ $? -ne 0 ] && echo -e "$WARN Fail undo removing dir 'rmdir $mount_where/$image' cmd!"
+ exit 1
+ fi
+
+ #sudo mount root.sqsh mnt -t squashfs -o loop #ok, but read only, because squash file cannot be modified
+ unsquashfs "$full_path_image"
+ if [[ $? -ne 0 ]] ; then
+ echo -e "$ERR Fail unsquash cmd! Exit."
+ rmdir "$mount_where/$image" #undo
+ [ $? -ne 0 ] && echo -e "$WARN Fail undo removing dir 'rmdir $mount_where/$image' cmd!"
+ exit 1
+ else
+ echo -e "$OK unsquash success."
+ fi
+
+ rm "$mount_where/$image/$image" #erase copy of sqhash filesystem image file (after decompressed)
+ [ $? -ne 0 ] && echo -e "$WARN Fail removing image file dupe '$mount_where/$image/$image'!"
+
+fi
+
+start_evid="\e[1;39;41m"
+stop_evid="\e[0m"
+exit_string="All done. [MEMO] Dont' forget to use ${start_evid}srun-umount-img \"${image}\""
+[[ $format != $ext ]] && exit_string="${exit_string} ${format}"
+[[ $iso_mount_type == "mount-loop" && "$forceIsoStdMount" == true ]] && exit_string="${exit_string} --force-iso-stdmount"
+exit_string="${exit_string}${stop_evid} when finished."
+echo -e "$exit_string"
+exit 0
+
+
diff --git a/image-mount.1 b/image-mount.1
new file mode 100644
index 000000000000..aca595e3458b
--- /dev/null
+++ b/image-mount.1
@@ -0,0 +1,31 @@
+.\" Manpage for image-mount.
+.\" Contact Simona <simona.pisano.70[at]gmail[dot]com> to correct errors or typos.
+.TH man 1 "25 Nov 2018" "1.0" "image-mount man page"
+.SH NAME
+image-mount \- Bash script to mount image files (iso, vms, crypto, squashfs) inside simonascripts pkg
+.SH SYNOPSIS
+image-mount image-mount [path/]file-name[.format] [format | #partition] [path-where-mount | #partition] [--force-iso-stdmount]
+.SH DESCRIPTION
+Bash script to mount image files (iso, vms, crypto, squashfs) inside simonascripts pkg.
+.SH OPTIONS
+-h, --help
+ display this help and exit
+
+--force-iso-stdmount
+ force in iso sudo mount 'mount -o loop' instead 'fuseiso'
+
+-y, --ask-confirm
+ confirm before execute
+
+--version
+ output version information and exit
+.SH EXAMPLES
+
+.SH SEE ALSO
+image-umount, simona-scripts
+.SH BUGS
+No known bugs.
+.SH AUTHOR
+Simona Pisano (simona.pisano.70[at]gmail[dot]com)
+.SH COPYRIGHT
+Copyright © 2018 Simona Pisano. License GPLv3: GNU GPL version 3 <https://gnu.org/licenses/gpl.html>.
diff --git a/image-umount b/image-umount
new file mode 100755
index 000000000000..04159a44b945
--- /dev/null
+++ b/image-umount
@@ -0,0 +1,218 @@
+#!/bin/bash
+# Simona Pisano - 2018-11-18
+# simona-scripts
+# Libertamente utilizzabile sotto GPL v3
+#srun-umount-img() {
+
+[[ $1 == "" ]] && exit 0 #TO-DO attivare invece la richiesta dei parametri?
+
+EchoReset="\e[0m"
+echo -e -n "$EchoReset"
+OK="\E[32;40m[OK]${EchoReset}"
+WARN="\E[33;40m[OK]${EchoReset}"
+ERR="\E[31;40m[OK]${EchoReset}"
+#echo -e "$OK $WARN $ERR"
+
+if [[ $1 == "-h" || $1 == "--help" ]] ; then
+ cat << EOF
+image-umount command help
+
+More details and supported formats are supplied inside 'image-mount -h' script.
+
+Usage
+ image-umount [--help|-h]
+ image-umount reset [path] (try)
+ image-umount image.ext [format] [mount-path] [--force-iso-stdmount]
+ --force-iso-stdmount -> force in iso mount 'mount -o loop' instead 'fuseiso'
+
+Warning:
+ 1) format must be explicily specified if file extension do not say itself the correct format.
+ 2) Warning: all parameters are case sensitive.
+
+Default parameters:
+ image-umount image.raw raw 0 \$HOME/mount/image
+Minimal usage:
+ image-umount file.ext
+Typical usage:
+ image-umount file.ext 2
+EOF
+ exit 0
+elseif [[ $1 == "--version" ]]
+ echo "image-umount Version 0.0 (simonascripts package)"
+ exit 0
+fi
+
+# ------------------------------------------------------------------------------------------------------------------------
+# RESET ------------------------------------------------------------------------------------------------------------------
+# ------------------------------------------------------------------------------------------------------------------------
+
+if [[ $1 == "reset" ]] ; then
+ mount_where="$HOME/mount/image" #default
+ [[ $2 != "" ]] && mount_where=$2
+ cd "$mount_where"
+ [[ $? -ne 0 ]] && echo -e "$WARN Fail 'cd \"$mount_where\"' cmd! Reset so don't Exit."
+ if [[ -r /bin/qemu-nbd ]] ; then
+ sudo qemu-nbd -d /dev/nbd0 >/dev/null
+ [[ $? -ne 0 ]] && echo -e "$WARN Fail undo 'qemu-nbd -d /dev/nbd0' cmd!" || echo -e "$OK qemu nbd stopped... success."
+ fi
+ if [[ -r /bin/fuseiso ]] ; then
+ for dir in "$mount_where" ; do
+ fusermount -u "$dir"
+ [[ $? -ne 0 ]] && echo -e "$WARN Fail undo 'fusemount -u \"$dir\"' cmd!" || echo -e "$OK fusemount success."
+ done
+ fi
+ if [[ -r /bin/cryptsetup ]] ; then
+ sudo cryptsetup close crypt-disk
+ [[ $? -ne 0 ]] && echo -e "$WARN Fail 'cryptsetup close crypt-disk' cmd!" || echo -e "$OK 'cryptsetup close crypt-disk' success."
+ fi
+ #if [[ -r /bin/mksquash ]] ; then
+ #TO-DO
+ #fi
+
+ for dir in "$mount_where" ; do
+ sudo umount "$dir"
+ [[ $? -ne 0 ]] && echo -e "$WARN Fail umount \"$dir\" !" || echo -e "$OK umount ok"
+ done
+ sudo umount "$mount_where"
+ [[ $? -ne 0 ]] && echo -e "$WARN Fail umount \"$mount_where\"' ! Reset so don't Exit." || echo -e "$OK umount success."
+ exit 0
+ echo "All done."
+fi
+
+# ------------------------------------------------------------------------------------------------------------------------
+# INPUT PARAMETER --------------------------------------------------------------------------------------------------------
+# ------------------------------------------------------------------------------------------------------------------------
+
+allow_formats="raw qcow2 vdi blkdebug blklogwrites blkreplay blkverify bochs cloop copy-on-read dmg file ftp ftps gluster host_cdrom host_device http https iscsi iser luks nbd nfs null-aio null-co nvme parallels qcow qed quorum rbd replication sheepdog ssh throttle vhdx vmdk vpc vvfat"
+allow_formats_iso="iso nrg bin img mdf"
+allow_formats_crypto="tcrypt plain luks luks1 luks2 loopaes"
+
+#þarameter $1
+full_path_image="image.raw" #default
+par=$1
+if [[ $1 != "" && ${par:0:1} != "-" ]] ; then
+ full_path_image=$1
+else
+ echo "Default: 'image.raw' image file"
+fi
+image="${full_path_image##*/}" # estract substring: take only final string after last /
+ext="${image##*.}" #estract sbustring: take only final string aster last .
+
+#þarameter $2
+format="" #no default
+par=$2
+if [[ $2 != "" && ${par:0:1} != "-" ]] ; then
+ format=$2
+else
+ [[ $ext != "" ]] && format=$ext
+fi
+
+[[ $format == "" ]] && { echo "Parameter missing. Please insert format as second command parameter."; exit 1; }
+
+#þarameter $3
+mount_where="$HOME/mount/image" #default
+[[ $3 != "" ]] && mount_where=$3
+
+[[ ! -d "$mount_where/$image" ]] && { echo -e "$ERR Directory $mount_where/$image do not exist!! Exit."; exit 1; }
+
+forceIsoStdMount=false #default par
+while [ $# -ne 0 ] ; do
+ arg="$1"
+ case "$arg" in
+ --force-iso-stdmount) forceIsoStdMount=true ;;
+ *) ;;
+ esac
+ shift
+done
+
+# ------------------------------------------------------------------------------------------------------------------------
+# WORK -------------------------------------------------------------------------------------------------------------------
+# ------------------------------------------------------------------------------------------------------------------------
+
+#before exit for mounted directory if inside
+if [[ $PWD == "$mount_where/$image" ]] ; then
+ cd "$mount_where"
+ [[ $? -ne 0 ]] && { echo -e "$ERR Fail 'cd \"$mount_where\"' cmd! Exit."; exit 1; }
+fi
+
+# vm images -----------------------------------------------------------------------------------------------------------
+if [[ $allow_formats =~ $format ]] ; then
+
+ [[ ! -r /bin/qemu-nbd ]] && { echo -e "$ERR Missing qemu-nbd cmd (qemu pkg?)! Exit"; exit 1; }
+
+ sudo umount "$mount_where/$image"
+ [[ ! -d "$mount_where/$image" ]] && echo -e "$OK umount $mount_where/$image done." || echo -e "$WARN Fail umount $mount_where/$image!!"
+
+ sudo qemu-nbd -d /dev/nbd0 >/dev/null
+ [[ $? -ne 0 ]] && { echo -e "$ERR Fail 'qemu-nbd -d /dev/nbd0' cmd! Exit."; exit 1; } || echo -e "$OK qemu nbd stopped... success."
+
+# iso images ----------------------------------------------------------------------------------------------------------
+elif [[ $allow_formats_iso =~ $format ]] ; then
+
+ if [[ -r /bin/fuseiso && "$forceIsoStdMount" != true ]] ; then
+
+ fusermount -u "$mount_where/$image"
+ [[ $? -ne 0 ]] && { echo -e "$ERR Fail 'fusemount -u \"$mount_where/$image\"' cmd! Exit."; exit 1; }
+ echo-e "$OK umount (fusermount -u) $mount_where/$image success."
+ else
+
+ sudo umount "$mount_where/$image"
+ [[ $? -ne 0 ]] && { echo -e "$ERR Fail 'umount \"$mount_where/$image\"' cmd! Exit."; exit 1; }
+ echo -e "$OK umount (sudo umount loop) $mount_where/$image success."
+
+ fi
+
+# crypto images -------------------------------------------------------------------------------------------------------
+elif [[ $allow_formats_crypto =~ $format ]] ; then
+
+ [[ ! -r /bin/cryptsetup ]] && { echo -e "$ERR Missing cryptsetup cmd (cryptsetup pkg?)! Exit."; exit 1; }
+
+ sudo umount "$mount_where/$image"
+ [[ $? -ne 0 ]] && { echo -e "$ERR Fail 'umount \"$mount_where/$image\"' cmd! Exit."; exit 1; }
+
+ sudo cryptsetup close crypt-disk
+ [[ $? -ne 0 ]] && { echo -e "$ERR Fail 'cryptsetup close crypt-disk' cmd! Exit."; exit 1; }
+ echo -e "$OK Umount \"$mount_where/$image\"..."
+
+# sqhash images -------------------------------------------------------------------------------------------------------
+elif [[ "squashfs" =~ $format ]] ; then
+ [[ ! -r /bin/mksquash ]] && { echo -e "$ERR Missing mksquash cmd (squash-tool pkg?)! Exit"; exit 1; }
+
+ cd "$mount_where/$image"
+ [[ $? -ne 0 ]] && { echo -e "$ERR Fail 'cd $mount_where/$image' cmd!! Exit."; exit 1; }
+
+ sudo mksquash * $image
+ [[ $? -ne 0 ]] && { echo -e "$ERR Fail 'mksquash * $image' cmd!! Exit."; exit 1; } || echo -e "$OK mksquash success."
+
+ cp "$mount_where/$image/$image" "$full_path_image"
+ if [[ $? -ne 0 ]] ; then
+ echo -e "$WARN Fail copy update squashfs over original image! Check file '$mount_where/$image/$image' and remember to do 'rm -r $mount_where/$image'."
+ exit 1
+ else
+ echo -e "$OK Created new updated squash image file sucessfully."
+ fi
+
+ rm "$mount_where/$image/$image" #erase copy of sqhash filesystem image file
+ [ $? -ne 0 ] && echo -e "$WARN Fail removing image file dupe '$mount_where/$image/$image'!"
+
+else
+ [[ $format == "" ]] && detail="absent" || detail="unknown"
+ echo -e "$ERR Supplied format $format ${detail}. Exit."
+ exit 1
+fi
+
+for dir in $mount_where/$image/[0-9] ; do [[ -d "$dir" ]] && rmdir "$dir"; done
+rmdir "$mount_where/$image"
+if [[ $? -ne 0 ]] ; then
+ echo -e "$ERR Fail 'rmdir $mount_where/$image' cmd! Exit."
+ sudo rm -r "$mount_where/$image"
+ [[ $? -ne 0 ]] && echo -e "$WARN sudo rm -r $mount_where/$image fail!" || echo -e "$OK Sudo removed dir '$mount_where/$image' success."
+ exit 1
+else
+ echo -e "$OK Removed dir '$mount_where/$image' success."
+fi
+
+echo "All done."
+exit 0
+
+
diff --git a/ioscheduler-list b/ioscheduler-list
new file mode 100755
index 000000000000..002aab712408
--- /dev/null
+++ b/ioscheduler-list
@@ -0,0 +1,13 @@
+#!/bin/bash
+# Simona Pisano - 2018-11-18
+# simona-scripts
+# Libertamente utilizzabile sotto GPL v3
+
+ #alias sget-io-sched-all-device='
+ echo -e -n "I/O sched: ";
+ for device in /sys/block/nvme*/queue/scheduler ; do echo -e -n "nvme${device:15:3}>\e[1;39;41m" ` cat /sys/block/nvme${device:15:4}/queue/scheduler | cut -d "[" -f2 | cut -d "]" -f1 ` "\e[0m " ; done;
+ for device in /sys/block/sd*/queue/scheduler ; do echo -e -n "sd${device:13:1}>\e[1;39;41m" `cat /sys/block/sd${device:13:1}/queue/scheduler | cut -d "[" -f2 | cut -d "]" -f1` "\e[0m "; done;
+ echo ""
+ #'
+
+
diff --git a/macinstall b/macinstall
new file mode 100755
index 000000000000..14a85d3cf477
--- /dev/null
+++ b/macinstall
@@ -0,0 +1,490 @@
+#!/bin/bash
+# Simona Pisano - 2018-11-27
+# simona-scripts
+# Libertamente utilizzabile sotto GPL v3
+
+
+if [[ $1 == "-h" || $1 == "--help" ]] ; then
+
+ cat << EOF
+macinstall command help
+
+Imagine you want install arch linux one time and that clone on all disk
+ad pc you have. But you should have some different file that differ from
+one installation to another. This command help you to manage this.
+
+Imagine you have your /etc/macinstall.d/yourpc* with all files/folder
+like:
+ /etc/macinstall.d/yourpc1/etc/fstab
+ /etc/macinstall.d/yourpc1/boot/grug/grub.cfg
+ /etc/macinstall.d/yourpc1/etc/machine-id
+ /etc/macinstall.d/yourpc1/etc/hostname
+ /etc/macinstall.d/yourpc1/etc/ssh/host_*
+ /etc/macinstall.d/yourpc1/..
+A second install like
+ /etc/macinstall.d/yourpc2/etc/fstab
+ /etc/macinstall.d/yourpc2/boot/grug/grub.cfg
+ /etc/macinstall.d/yourpc2/etc/machine-id
+ /etc/macinstall.d/yourpc2/etc/hostname
+ /etc/macinstall.d/yourpc2/etc/ssh/host_*
+ /etc/macinstall.d/yourpc2/etc/..
+A config file with sessione [yourpc1] and [yourpc2] (edit yourself
+macinstall.conf)
+ /etc/macinstall.d/macinstall.conf
+with:
+ [yourpc1]
+ CopyFilesNum=5
+ CopyFile1=/etc/fstab
+ CopyFile2=/boot/grub/grub.cfg
+ CopyFile3=/etc/grub.d/40_custom
+ CopyFile4=/etc/hostname
+ CopyFile5=/etc/machine-id
+ CopyDirectoriesNum=1
+ CopyDirectory1=/etc/ssh
+ WriteSemaphore=yes
+ AllowOnlyIfPreviousMacIs=yourpc2
+and
+ [yourpc2]
+ CopyFilesNum=5
+ CopyFile1=/etc/fstab
+ CopyFile2=/boot/grub/grub.cfg
+ CopyFile3=/etc/grub.d/40_custom
+ CopyFile4=/etc/hostname
+ CopyFile5=/etc/machine-id
+ CopyDirectoriesNum=1
+ CopyDirectory1=/etc/ssh
+ WriteSemaphore=yes
+ AllowOnlyIfPreviousMacIs=yourpc1
+And finally a command like to switch from one system to another
+ macinstall yourpc1 ---this-is-not-an-exercise
+ macinstall yourpc2 ---this-is-not-an-exercise
+And a semaphore file like
+ /etc/macinstall.d/CurrentSystem-yourpc1
+or
+ /etc/macinstall.d/CurrentSystem-yourpc2
+
+Summary usage
+ macinstall [-i --info none] [--help|-h] [--version] name-install
+ [local-import]
+
+Option parameters
+ --help -h -> this help page
+ -i --info or blank -> who am i looking semaphore file
+ --version -> output version information and exit
+ -y --ask-confirm -> ask confirm before proceeed
+ ---this-is-not-an-exercise -> force real work. without this
+ none is really done. this is a
+ secure check.
+ ---no-test -> use dest / instead $USER/test
+
+Path used
+ /etc/macinstall.d -> contains all single
+ install related files (example fstab grub.cfg machine-id...)
+ /usr/bin/macinstall -> this command itself
+ /etc/macinstall-d/CurrentSystem-pcname -> semaphore of installed
+ system (touch bank file)
+
+Example
+ A file /etc/macinstall.d/macinstall.conf with some demo config
+ is already supplyed.
+
+Packages required
+ sed sudo
+
+Cfg file used
+ /etc/macinstall.d/macinstall.conf
+
+EOF
+
+ exit 0
+elseif [[ $1 == "--version" ]]
+ echo "macinstall Version 0.0"
+ exit 0
+fi
+
+#
+## who am I
+#
+path_prefix_system_semaphore="/etc/macinstall.d/CurrentSystem-"
+#path_prefix_system_semaphore="/home/simona/My Work/my-pkg simonascripts/root-test/etc/CurrentSystem-"
+if [[ $1 == "" || $1 == "-i" || $1 == "--info" ]] ; then
+ numSem=`ls "$path_prefix_system_semaphore"* 2> /dev/null | wc -l`
+ case $numSem in
+ 1) currSystem=`ls -1 "$path_prefix_system_semaphore"* 2> /dev/null`
+ currSystem="${currSystem:${#path_prefix_system_semaphore}:${#currSystem}-${#path_prefix_system_semaphore}}"
+ echo "I am $currSystem"
+ ;;
+ 0) echo "Can't detect current system."
+ ;;
+ *) echo "Ambiguous CurrentSystem ($numSem)!!!"
+ ;;
+ esac
+fi
+
+[[ ! -r /bin/sed ]] && { echo -e "$ERR Missing sed utility! Exit"; exit 1; }
+[[ ! -r /bin/sudo ]] && { echo -e "$ERR Missing sudo utility! Exit"; exit 1; }
+
+[[ $1 != "" ]] && install_macname=$1 || exit 0
+#[[ $1 != "" ]] && install_macname=$1 || { echo "Please insert install name as first command parameter!!"; exit 0; }
+
+runLocalImport=false
+[[ $2 == "local-import" ]] && runLocalImport=true
+
+flagNoTest=false
+flagForceRealWork=false
+flagAskConfirm=false
+while [ $# -ne 0 ] ; do
+ case $1 in
+ -y|--ask-confirm) flagAskConfirm=true ;;
+ ---this-is-not-an-exercise) flagForceRealWork=true;;
+ ---no-test) flagNoTest=true;;
+ *) ;;
+ esac
+ shift
+done
+
+#color Foreground Background
+#black 30 40
+#red 31 41
+#green 32 42
+#yellow 33 43
+#blue 34 44
+#magenta 35 45
+#cyan 36 46
+#white 37 47
+EchoReset="\e[0m"
+echo -e -n "$EchoReset"
+OK="\E[32;40m[OK]${EchoReset}"
+WARN="\E[33;40m[WARN]${EchoReset}"
+ERR="\E[31;40m[ERR]${EchoReset}"
+#echo -e "$OK $WARN $ERR"
+
+#path_cfg must be '/' terminated
+filename_cfg="macinstall.conf"
+path_cfg="/etc/macinstall.d/"
+[[ ${path_cfg:${#path_cfg}-1:1} != "/" ]] && path_cfg="$path_cfg/" #if last char is not '/' add it
+if [[ ! -d $path_cfg ]] ; then
+ mkdir -p $path_cfg
+ [[ $? -ne 0 ]] && { echo -e "$ERR Fail '$path_cfg' mkdir cmd creation !!"; exit 1; }
+fi
+if [[ ! -r $path_cfg$filename_cfg ]] ; then
+ touch $path_cfg$filename_cfg
+ [[ $? -ne 0 ]] && { echo -e "$ERR Fail '$path_cfg$filename_cfg' touch cmd creation !!"; exit 1; }
+fi
+
+#path_dest must be '/' terminated
+path_dest="$HOME/test/"
+[[ "$flagNoTest" == true ]] && { echo "$WARN Using real path / for destination..."; path_dest="/"; }
+[[ ${path_dest:${#path_dest}-1:1} != "/" ]] && path_dest="$path_dest/" #if last char is not '/' add it
+if [[ ! -d $path_dest ]] ; then
+ [[ ${path_dest:0:5} == "/home" && ! -d "/home" ]] && { echo "$ERR Path '/home' missing. (For / use) Exit."; exit 1; }
+ mkdir -p $path_dest
+ [[ $? -ne 0 ]] && { echo -e "$ERR Fail $path_dest mkdir cmd creation !!"; exit 1; }
+fi
+
+postfix_bak_file_name=".bak"
+
+#cfg related
+prop_cfg_file_copy_num="CopyFilesNum"
+prop_cfg_dir_copy_num="CopyDirectoriesNum"
+prop_cfg_rm_num="RmNums"
+
+prop_cfg_file_copy="CopyFile"
+prop_cfg_dir_copy="CopyDirectory"
+prop_cfg_rm="Rm"
+
+prop_cfg_write_sem="WriteSemaphore"
+prop_cfg_read_sem="AllowOnlyIfPreviousMacIs"
+
+if [[ "$flagAskConfirm" == true ]] ; then
+ echo -n "Continue? (Y/N): "; read ask
+ [[ ! $ask =~ ^(yes|y|YES|y|s|S|si|SI|sì)$ ]] && { echo "Exit forced by user."; exit 0; }
+fi
+
+number_files=`sed -nr "/^\[$install_macname\]/ { :l /^$prop_cfg_file_copy_num[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg`
+number_directories=`sed -nr "/^\[$install_macname\]/ { :l /^$prop_cfg_dir_copy_num[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg`
+number_rm=`sed -nr "/^\[$install_macname\]/ { :l /^$prop_cfg_rm_num[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg`
+
+ok_write_semaphore=`sed -nr "/^\[$install_macname\]/ { :l /^$prop_cfg_write_sem[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg`
+[[ $ok_write_semaphore == "" ]] && ok_write_semaphore="yes" #default
+[[ $ok_write_semaphore != "yes" && $ok_write_semaphore != "no" ]] && ok_write_semaphore="yes" #default
+
+#Check cfg file integrity
+if [[ $number_files -lt 1 && $number_directories -lt 1 && $number_rm -lt 1 ]] ; then
+ echo -e "$ERR $filename_cfg: None to do!!! 'CopyFilesNum' or 'CopyDirectoriesNum' or 'RmNum' not correctly defined. Please modify cfg."
+ exit 1
+fi
+
+if [[ $number_files -gt 0 ]] ; then
+ for (( counter=1; counter <= $number_files; counter++ )) ; do
+ dupe=`sed -nr "/^\[$install_macname\]/ { :l /^$prop_cfg_file_copy$counter[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg`
+ [[ $dupe == "" ]] && { echo -e "$ERR $filename_cfg: '$prop_cfg_file_copy$counter' not found inside cfg. Fix cfg!!"; exit 1; }
+ [[ ! -r $path_cfg$install_macname$dupe ]] && { echo -e "$ERR File '$path_cfg$install_macname$dupe' defined in config but not found!"; exit 1; }
+
+ #prepare destination creatinf directory if required
+ #remove starting '/' if exist
+ [[ ${dupe:0:1} == "/" ]] && dupe=${dupe:1:${#dupe}-1}
+ # extract path from $dupe and mkdir -p it
+ dupeFilename=${dupe##*/} #extract froms tring all is over last '/' (filename)
+ dupePath=${dupe:0:${#dupe}-${#dupeFilename}} #extract path (remove filename cutting string)
+ #echo "filename=$dupeFilename path=$path_dest$dupePath" #debug
+ if [[ ! -d "$path_dest$dupePath" ]] ; then
+ mkdir -p "$path_dest$dupePath"
+ if [[ $? -ne 0 ]] ; then
+ sudo mkdir -p "$path_dest$dupePath"
+ [[ $? -ne 0 ]] && { echo -e "$WARN Fail generating directory '$path_dest$dupePath'. Exit."; exit 1; }
+ fi
+ fi
+ done
+fi
+
+if [[ $number_directories -gt 0 ]] ; then
+ for (( counter=1; counter <= $number_directories; counter++ )) ; do
+ dupe=`sed -nr "/^\[$install_macname\]/ { :l /^$prop_cfg_dir_copy$counter[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg`
+ [[ $dupe == "" ]] && { echo -e "$ERR $filename_cfg: '$prop_cfg_dir_copy$counter' not found inside cfg. Fix cfg!!"; exit 1; }
+ [[ ! -d $path_cfg$install_macname$dupe ]] && { echo -e "$ERR Directory '$path_cfg$install_macname$dupe' defined in config but not found!"; exit 1; }
+
+ #prepare destination creating directory if required
+ #remove starting '/' if exist
+ [[ ${dupe:0:1} == "/" ]] && dupe=${dupe:1:${#dupe}-1}
+ #remove ending '/' if exist
+ [[ ${dupe:${#dupe}-1:1} == "/" ]] && dupe=${dupe:0:${#dupe}-1}
+ # extract path from $dupe and mkdir -p it
+ dupeFoldername=${dupe##*/} #extract froms tring all is over last '/' (foldername)
+ dupePath=${dupe:0:${#dupe}-${#dupeFoldername}} #extract path (remove filename cutting string)
+ if [[ ! -d "$path_dest$dupePath" ]] ; then
+ mkdir -p "$path_dest$dupePath"
+ if [[ $? -ne 0 ]] ; then
+ sudo mkdir -p "$path_dest$dupePath"
+ [[ $? -ne 0 ]] && { echo -e "$WARN Fail generating directory '$path_dest$dupePath'. Exit."; exit 1; }
+ fi
+ fi
+ done
+fi
+
+if [[ $number_rm -gt 0 ]] ; then
+ for (( counter=1; counter <= $number_rm; counter++ )) ; do
+ dupe=`sed -nr "/^\[$install_macname\]/ { :l /^$prop_cfg_rm$counter[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg`
+ [[ $dupe == "" ]] && { echo -e "$ERR $filename_cfg: '$prop_cfg_rm$counter' not found inside cfg. Fix cfg!!"; exit 1; }
+ [[ ! -d $path_cfg$install_macname$dupe ]] && { echo -e "$ERR File/dir '$path_cfg$install_macname$dupe' defined in config but not found!"; exit 1; }
+ done
+fi
+
+
+# ------------------------------------------------------------------------------------------------------------------------
+# WORK -------------------------------------------------------------------------------------------------------------------
+# ------------------------------------------------------------------------------------------------------------------------
+
+if [[ "$flagForceRealWork" == true ]] ; then
+ echo -e "$WARN Warning: using REAL path. This is not a simulation. I can damage system."
+ echo "Dest dir used is '$path_dest'."
+ echo -n "Continue? (Y/N): "; read ask
+ [[ ! $ask =~ ^(yes|y|YES|y|s|S|si|SI|sì)$ ]] && { echo "Exit forced by user."; exit 0; }
+fi
+
+#TO-DO local-import come secondo parametro
+#legge macchina corrente su file semaforo, legge macchina corrente da parametro (devono corrispondere)
+# e va ricopiarsi tutti i files elencati sulla macchina (se presente) nella cartella giusta (è un fresh dei files di install)
+if [[ $runLocalImport == true ]] ; then
+
+ #if current install exist but it is not the one current i can't proceede
+ numSem=$(ls "$path_prefix_system_semaphore"* 2> /dev/null | wc -l)
+ if [[ numSem -gt 0 ]] ; then
+ if [[ ! -r "$path_prefix_system_semaphore$install_macname" ]] ; then
+ echo -e "$ERR Another install. Can't work"
+ exit 1
+ fi
+ fi
+
+ #
+
+ exit 0
+fi
+
+#?????
+#echo "1"
+#sed -nr "/^\[$install_macname\]/ { :l /^ciccia[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg
+#sed -nr "/^\[$install_macname\]/ { :l /^AllowOnlyIfPreviousMacIs[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg
+
+#
+## Verify semaphore file (opzional)
+#
+AllowOnlyIfPreviousMacIs=`sed -nr "/^\[$install_macname\]/ { :l /^$prop_cfg_read_sem[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg`
+if [[ $AllowOnlyIfPreviousMacIs != "" ]] ; then
+ echo " Found in cfg: AllowOnlyIfPreviousMacIs=$AllowOnlyIfPreviousMacIs"
+
+ if [[ ! -r "$path_prefix_system_semaphore$AllowOnlyIfPreviousMacIs" ]] ; then
+ echo -e "$ERR Missing semaphore '$path_prefix_system_semaphore$AllowOnlyIfPreviousMacIs'. Previous install required but not verified. Stop."
+ exit 1
+ else
+ flag_old_mac_to_erase="$AllowOnlyIfPreviousMacIs"
+ fi
+
+else
+ echo -e "$WARN Warning: control of previous installed machine disabled."
+ echo -n "Continue? (Y/N): "; read ask
+ [[ ! $ask =~ ^(yes|y|YES|y|s|S|si|SI|sì)$ ]] && { echo "Exit forced by user."; exit 0; }
+fi
+
+#
+## Backup old files
+#
+if [[ $number_files -gt 0 ]] ; then
+ for (( counter=1; counter <= $number_files; counter++ )) ; do
+ backup=`sed -nr "/^\[$install_macname\]/ { :l /^$prop_cfg_file_copy$counter[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg`
+ [[ ${backup:0:1} == "/" ]] && backup=${backup:1:${#backup}-1} #remove starting '/' if exist
+ if [[ -r $path_dest$backup ]] ; then
+ if [[ "$flagForceRealWork" == true ]] ; then
+ cp -f "$path_dest$backup" "$path_dest$backup$postfix_bak_file_name"
+ if [[ $? -ne 0 ]] ; then
+ sudo cp -f "$path_dest$backup" "$path_dest$backup$postfix_bak_file_name"
+ if [[ $? -ne 0 ]] ; then
+ echo -e "$WARN Fail generating backup file '$path_dest$backup$postfix_bak_file_name'. Ask User."
+ echo -n "Continue? (Y/N): "; read ask
+ [[ ! $ask =~ ^(yes|y|YES|y|s|S|si|SI|sì)$ ]] && { echo "Exit forced by user with error."; exit 1; }
+ else
+ echo -e "$OK Generation of backup file [1] '$path_dest$backup' as '$path_dest$backup$postfix_bak_file_name'"
+ fi
+ else
+ echo -e "$OK Generation of backup file [2] '$path_dest$backup' as '$path_dest$backup$postfix_bak_file_name'"
+ fi
+ else
+ echo -e "$OK [Simulated] Generation of backup file '$path_dest$backup' as '$path_dest$backup$postfix_bak_file_name'"
+ fi
+ else
+ echo -e "$WARN File '$path_dest$backup' to backup not present. Ignoring backup."
+ fi
+ done
+fi
+
+if [[ $number_directories -gt 0 ]] ; then
+ for (( counter=1; counter <= $number_directories; counter++ )) ; do
+ backup=`sed -nr "/^\[$install_macname\]/ { :l /^$prop_cfg_dir_copy$counter[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg`
+ [[ ${backup:0:1} == "/" ]] && backup=${backup:1:${#backup}-1} #remove starting '/' if exist
+ if [[ -d "$path_dest$backup" ]] ; then
+ if [[ "$flagForceRealWork" == true ]] ; then
+ #if bak directory alrrady exist to not create a new ssh dir inside it....
+ if [[ -d "$path_dest$backup$postfix_bak_file_name" ]] ; then
+ rm -r -f "$path_dest$backup$postfix_bak_file_name"
+ if [[ $? -ne 0 ]] ; then
+ sudo rm -r -f "$path_dest$backup$postfix_bak_file_name"
+ [[ $? -ne 0 ]] && echo -e "$WARN Fail removing old backup directory.'$path_dest$backup$postfix_bak_file_name'."
+ fi
+ fi
+ #do work
+ mv -f "$path_dest$backup" "$path_dest$backup$postfix_bak_file_name"
+ if [[ $? -ne 0 ]] ; then
+ sudo mv -f "$path_dest$backup" "$path_dest$backup$postfix_bak_file_name"
+ if [[ $? -ne 0 ]] ; then
+ echo -e "$WARN Fail generating backup directory '$path_dest$backup$postfix_bak_file_name'. Ask User."
+ echo -n "Continue? (Y/N): "; read ask
+ [[ ! $ask =~ ^(yes|y|YES|y|s|S|si|SI|sì)$ ]] && { echo "Exit forced by user with error."; exit 1; }
+ else
+ echo -e "$OK Generation [1] of backup directory '$path_dest$backup$postfix_bak_file_name'"
+ fi
+ else
+ echo -e "$OK Generation [2] of backup directory '$path_dest$backup$postfix_bak_file_name'"
+ fi
+ else
+ echo -e "$OK [Simulated] Generation of backup directory '$path_dest$backup$postfix_bak_file_name'"
+ fi
+ else
+ echo -e "$WARN Directory '$path_dest$backup' to backup not present. Ignoring backup."
+ fi
+ done
+fi
+
+if [[ $number_rm -gt 0 ]] ; then
+ echo -e "$WARN Attention! Backup of remove ($number_rm) not done."
+fi
+
+#
+## Copia nuovi files
+#
+if [[ $number_files -gt 0 ]] ; then
+ for (( counter=1; counter <= $number_files; counter++ )) ; do
+ dupe=`sed -nr "/^\[$install_macname\]/ { :l /^$prop_cfg_file_copy$counter[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg`
+ [[ ${dupe:0:1} == "/" ]] && dupe=${dupe:1:${#dupe}-1} #remove starting '/' if exist
+ if [[ "$flagForceRealWork" == true ]] ; then
+ cp -f "$path_cfg$install_macname/$dupe" "$path_dest$dupe"
+ if [[ $? -ne 0 ]] ; then
+ sudo cp -f "$path_cfg$install_macname/$dupe" "$path_dest$dupe"
+ if [[ $? -ne 0 ]] ; then
+ echo -e "$ERR Fail copyng file over destination from <$install_macname> to '$path_dest$dupe'. Ask User."
+ echo -n "Continue? (Y/N): "; read ask
+ [[ ! $ask =~ ^(yes|y|YES|y|s|S|si|SI|sì)$ ]] && { echo "Exit forced by user with error."; exit 1; }
+ fi
+ fi
+ echo -e "$OK Copied file from <$install_macname> '$path_dest$dupe'."
+ else
+ echo -e "$OK [Simulated] Copied file from '$path_cfg$install_macname/$dupe' to '$path_dest$dupe'."
+ fi
+ done
+fi
+
+if [[ $number_directories -gt 0 ]] ; then
+ for (( counter=1; counter <= $number_directories; counter++ )) ; do
+ dupe=`sed -nr "/^\[$install_macname\]/ { :l /^$prop_cfg_dir_copy$counter[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg`
+ [[ ${dupe:0:1} == "/" ]] && dupe=${dupe:1:${#dupe}-1} #remove starting '/' if exist
+ [[ ${dupe:${#dupe}-1:1} == "/" ]] && dupe=${dupe:0:${#dupe}-1} #remove ending '/' if exist
+ if [[ "$flagForceRealWork" == true ]] ; then
+ cp -f -r "$path_cfg$install_macname/$dupe" "$path_dest$dupe"
+ if [[ $? -ne 0 ]] ; then
+ sudo cp -f -r "$path_cfg$install_macname/$dupe" "$path_dest$dupe"
+ if [[ $? -ne 0 ]] ; then
+ echo -e "$ERR Fail copyng directory over destination from <$install_macname> to '$path_dest$dupe'. Ask User."
+ echo -n "Continue? (Y/N): "; read ask
+ [[ ! $ask =~ ^(yes|y|YES|y|s|S|si|SI|sì)$ ]] && { echo "Exit forced by user with error."; exit 1; }
+ fi
+ fi
+ echo -e "$OK Copied directory <$install_macname> '$path_dest$dupe'."
+ else
+ echo -e "$OK [Simulated] Copied directory from '$path_cfg$install_macname/$dupe' to '$path_dest$dupe'."
+ fi
+ done
+fi
+
+if [[ $number_rm -gt 0 ]] ; then
+ for (( counter=1; counter <= $number_rm; counter++ )) ; do
+ dupe=`sed -nr "/^\[$install_macname\]/ { :l /^$prop_cfg_rm$counter[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" $path_cfg$filename_cfg`
+ [[ ${dupe:0:1} == "/" ]] && dupe=${dupe:1:${#dupe}-1} #remove starting '/' if exist
+ if [[ "$flagForceRealWork" == true ]] ; then
+ rm -f "$path_dest$dupe"
+ if [[ $? -ne 0 ]] ; then
+ sudo rm -f "$path_dest$dupe"
+ if [[ $? -ne 0 ]] ; then
+ echo -e "$ERR Fail removing file '$path_dest$dupe'. Ask User."
+ echo -n "Continue? (Y/N): "; read ask
+ [[ ! $ask =~ ^(yes|y|YES|y|s|S|si|SI|sì)$ ]] && { echo "Exit forced by user with error."; exit 1; }
+ fi
+ fi
+ echo -e "$OK Removed file <$install_macname> '$path_dest$dupe'."
+ else
+ echo -e "$OK [Simulated] Removed file '$path_dest$dupe'."
+ fi
+ done
+fi
+
+#
+## Write new semaphore (can be disabled)
+#
+if [[ $ok_write_semaphore == "yes" ]] ; then
+ if [[ -r $path_prefix_system_semaphore$flag_old_mac_to_erase ]] ; then
+ #if [[ "$flagForceRealWork" == true ]] ; then
+ rm "$path_prefix_system_semaphore$flag_old_mac_to_erase"
+ if [[ $? -ne 0 ]] ; then
+ sudo rm "$path_prefix_system_semaphore$flag_old_mac_to_erase"
+ [[ $? -ne 0 ]] && echo -e "$WARN All was OK but I can't remove '$path_prefix_system_semaphore$flag_old_mac_to_erase' !!"
+ fi
+ touch "$path_prefix_system_semaphore$install_macname"
+ if [[ $? -ne 0 ]] ; then
+ sudo touch "$path_prefix_system_semaphore$install_macname"
+ [[ $? -ne 0 ]] && echo -e "$WARN All OK EXCEPT creation of blank file '$path_prefix_system_semaphore$install_macname' !!"
+ fi
+ fi
+fi
+
+exit 0;
+
+
+
diff --git a/macinstall.1 b/macinstall.1
new file mode 100644
index 000000000000..bff5575b0b2d
--- /dev/null
+++ b/macinstall.1
@@ -0,0 +1,116 @@
+.\" Manpage for image-mount.
+.\" Contact Simona <simona.pisano.70[at]gmail[dot]com> to correct errors or typos.
+.TH man 1 "29 Nov 2018" "1.0" "macinstall man page"
+.SH NAME
+macinstall \- Bash script to manage different install files (if you clone smae install on more pcs)
+.SH SYNOPSIS
+macinstall macinstall [-i --info none] [--help|-h] [--version] name-install [local-import]
+.SH DESCRIPTION
+Bash script to manage different install files (if you clone smae install on more pcs)
+.SH OPTIONS
+--help, -h
+ this help page
+
+-i --info or blank
+ who am i looking semaphore file
+
+--version
+ output version information and exit
+
+-y --ask-confirm
+ ask confirm before proceeed
+
+---this-is-not-an-exercise
+ force real work. without this none is really done. this is a secure check.
+
+---no-test
+ use dest / instead $USER/test
+
+-h, --help
+ display this help and exit
+
+-y, --ask-confirm
+ confirm before execute
+
+.SH PATH USED
+/etc/macinstall.d
+ contains all single install related files (example fstab grub.cfg machine-id...)
+
+/usr/bin/macinstall
+ this command itself
+
+/etc/macinstall-d/CurrentSystem-pcname
+ semaphore of installed system (touch bank file)
+
+.SH PACKAGE REQUIRED
+sed sudo
+
+.SH EXAMPLES
+Imagine you want install arch linux one time and that clone on all disk
+ad pc you have. But you should have some different file that differ from
+one installation to another. This command help you to manage this.
+
+Imagine you have your /etc/macinstall.d/yourpc* with all files/folder
+like:
+
+ /etc/macinstall.d/yourpc1/etc/fstab
+ /etc/macinstall.d/yourpc1/boot/grug/grub.cfg
+ /etc/macinstall.d/yourpc1/etc/machine-id
+ /etc/macinstall.d/yourpc1/etc/hostname
+ /etc/macinstall.d/yourpc1/etc/ssh/host_*
+ /etc/macinstall.d/yourpc1/..
+
+A second install like
+ /etc/macinstall.d/yourpc2/etc/fstab
+ /etc/macinstall.d/yourpc2/boot/grug/grub.cfg
+ /etc/macinstall.d/yourpc2/etc/machine-id
+ /etc/macinstall.d/yourpc2/etc/hostname
+ /etc/macinstall.d/yourpc2/etc/ssh/host_*
+ /etc/macinstall.d/yourpc2/etc/..
+
+A config file with sessione [yourpc1] and [yourpc2] (edit yourself macinstall.conf)
+ /etc/macinstall.d/macinstall.conf
+
+with:
+ [yourpc1]
+ CopyFilesNum=5
+ CopyFile1=/etc/fstab
+ CopyFile2=/boot/grub/grub.cfg
+ CopyFile3=/etc/grub.d/40_custom
+ CopyFile4=/etc/hostname
+ CopyFile5=/etc/machine-id
+ CopyDirectoriesNum=1
+ CopyDirectory1=/etc/ssh
+ WriteSemaphore=yes
+ AllowOnlyIfPreviousMacIs=yourpc2
+
+and
+ [yourpc2]
+ CopyFilesNum=5
+ CopyFile1=/etc/fstab
+ CopyFile2=/boot/grub/grub.cfg
+ CopyFile3=/etc/grub.d/40_custom
+ CopyFile4=/etc/hostname
+ CopyFile5=/etc/machine-id
+ CopyDirectoriesNum=1
+ CopyDirectory1=/etc/ssh
+ WriteSemaphore=yes
+ AllowOnlyIfPreviousMacIs=yourpc1
+
+And finally a command like to switch from one system to another
+ macinstall yourpc1 ---this-is-not-an-exercise
+ macinstall yourpc2 ---this-is-not-an-exercise
+
+And a semaphore file like
+ /etc/macinstall.d/CurrentSystem-yourpc1
+or
+ /etc/macinstall.d/CurrentSystem-yourpc2
+
+.SH SEE ALSO
+simona-scripts
+.SH BUGS
+No known bugs.
+.SH AUTHOR
+Simona Pisano (simona.pisano.70[at]gmail[dot]com)
+.SH COPYRIGHT
+Copyright © 2018 Simona Pisano. License GPLv3: GNU GPL version 3 <https://gnu.org/licenses/gpl.html>.
diff --git a/macinstall.conf b/macinstall.conf
new file mode 100644
index 000000000000..987e260b639a
--- /dev/null
+++ b/macinstall.conf
@@ -0,0 +1,103 @@
+#Propname (wold before '=' char) can't contain spaces but file name accept '"' and delimiter and single '\' (before space)
+
+[ExampleNewInstall]
+CopyFilesNum=1
+#128bit, 32 chat, lowercase hex value, UUID del so, regenerated id not found, or with command 'systemd-machine-id-setup'
+CopyFile1=/etc/machine-id
+CopyDirectoriesNum=1
+#if required regenerate with rm /etc/ssh/ssh_host* and "ssh-keygen -A"
+CopyDirectory1=/etc/ssh/
+#default yes (case sensitive)
+WriteSemaphore=yes
+#WriteSemaphore=no
+
+# future implementation?
+#MakeFile1=/etc/machine-id
+#EraseFile1=/etc/grub.d/40_custom
+#DescriptionNum 2
+#Description1 djgfkljgdkljg
+#Description2 djgfkljgdkljg
+
+[simonapc1]
+CopyFilesNum=5
+CopyFile1=/etc/fstab
+CopyFile2=/boot/grub/grub.cfg
+CopyFile3=/etc/grub.d/40_custom
+CopyFile4=/etc/hostname
+CopyFile5=/etc/machine-id
+CopyDirectoriesNum=1
+CopyDirectory1=/etc/ssh
+WriteSemaphore=yes
+#se assente trova simonapc1???? TO-DO debug
+AllowOnlyIfPreviousMacIs=
+
+[simonapc2]
+CopyFilesNum=5
+CopyFile1=/etc/fstab
+CopyFile2=/boot/grub/grub.cfg
+CopyFile3=/etc/grub.d/40_custom
+CopyFile4=/etc/hostname
+CopyFile5=/etc/machine-id
+CopyDirectoriesNum=1
+CopyDirectory1=/etc/ssh
+AllowOnlyIfPreviousMacIs=
+#AllowOnlyIfPreviousMacIs=simonapc1
+#warning: no backup
+RmNums=1
+Rm1=/etc/systemd/system/multi-user.target.wants/ddclient.service
+WriteSemaphore=yes
+
+
+[simonamobilepc1]
+CopyFilesNum=5
+CopyFile1=/etc/fstab
+CopyFile2=/boot/grub/grub.cfg
+#same as simonapc2
+CopyFile3=/etc/grub.d/40_custom
+CopyFile4=/etc/hostname
+CopyFile5=/etc/machine-id
+CopyDirectoriesNum=1
+CopyDirectory1=/etc/ssh
+AllowOnlyIfPreviousMacIs=simonapc2
+
+[mammamobilepc1]
+CopyFilesNum=4
+CopyFile1=/etc/fstab
+CopyFile2=/boot/grub/grub.cfg
+CopyFile3=/etc/hostname
+CopyFile4=/etc/machine-id
+CopyDirectoriesNum=0
+AllowOnlyIfPreviousMacIs=simonapc2
+
+[simonapc1recovery]
+CopyFilesNum=5
+#same as simonapc2
+CopyFile1=/etc/fstab
+#same as simonapc2
+CopyFile2=/boot/grub/grub.cfg
+#same as simonapc2
+CopyFile3=/etc/grub.d/40_custom
+#same as simonamobilepc1
+CopyFile4=/etc/hostname
+#same as simonamobilepc1
+CopyFile5=/etc/machine-id
+CopyDirectoriesNum=1
+#same as simonamobilepc1
+CopyDirectory1=/etc/ssh
+#AllowOnlyIfPreviousMacIs=simonapc2
+
+[simonapc1virt]
+CopyFilesNum=5
+CopyFile1=/etc/fstab
+CopyFile2=/boot/grub/grub.cfg
+#same as simonapc2
+CopyFile3=/etc/grub.d/40_custom
+CopyFile4=/etc/hostname
+CopyFile5=/etc/machine-id
+CopyDirectoriesNum=1
+#same as simonamobilepc1
+CopyDirectory1=/etc/ssh
+#AllowOnlyIfPreviousMacIs=simonapc2
+
+
+
diff --git a/pendrive-detect b/pendrive-detect
new file mode 100755
index 000000000000..143632f12734
--- /dev/null
+++ b/pendrive-detect
@@ -0,0 +1,46 @@
+#!/bin/bash
+# Simona Pisano - 2018-11-18
+# simona-scripts
+# Libertamente utilizzabile sotto GPL v3
+
+ #sget-pendrive() {
+ n_found=0
+ for short_dev in `lsblk -ndlo NAME` ; do
+ drive="/dev/$short_dev"
+ if [[ -b $drive ]] ; then
+ short_dev="${drive##*/}" # estract substring: take only final part after last '/' char
+ #for drive in /dev/sd?* /dev/nvme* ; do
+ #if [[ -b $drive ]] ; then
+
+ letter=${drive:7:1}
+ #short_dev="${drive##*/}" # estract substring: take only final part after last '/' char
+
+ #base search
+ udev=`udevadm info -q path -n $drive`
+ udev=`udevadm info -a -p $udev `
+
+ search=`echo KERNEL==\"$short_dev\"`
+ udev_info=`echo "$udev" | grep $search | tr -d ' ' `
+ [[ $udev_info != "KERNEL==\"$short_dev\"" ]] && continue #not correct device
+
+ udev_info=`echo "$udev" | grep 'SUBSYSTEM=="block"' | tr -d ' ' `
+ [[ $udev_info != "SUBSYSTEM==\"block\"" ]] && continue #not correct device
+
+ udev_info=`echo "$udev" | grep 'ATTR{events}=="media_change"' | tr -d ' ' `
+ [[ $udev_info != "ATTR{events}==\"media_change\"" ]] && continue #not correct device
+
+ #check > 0 per evitare device pur presenti ma senza memoria inserita
+ udev_info=`echo "$udev" | grep -E 'ATTR{size}=="[0-9]{1,}"' | tr -d ' ' `
+ [[ $udev_info != *"ATTR{size}=="* ]] && continue #not correct device
+ value=` echo "$udev_info" | cut -d "\"" -f2 | cut -d "\"" -f1 `
+ [[ $value -lt 1 ]] && continue #not correct device
+
+ echo -e "Pendrive \e[1;39;41m$drive\e[0m (size $(($value *512/1000/1000/1000 ))GBi) detected."
+ #break #uncomment to stop search after the first
+
+ n_found=$(( $n_found + 1 ))
+ fi
+ done
+ [[ $n_found -lt 1 ]] && echo "No pendrive found" || echo "$n_found pendrives total found."
+ #}
+
diff --git a/simonas-scripts b/simonas-scripts
new file mode 100755
index 000000000000..e99d58663132
--- /dev/null
+++ b/simonas-scripts
@@ -0,0 +1,60 @@
+#!/bin/bash
+# Simona Pisano - 2018-11-18 -
+# simonas-scripts
+# Libertamente utilizzabile sotto GPL v3
+
+if [[ $1 == "-h" || $1 == "--help" || $1 == "list" || $1 == "" ]] ; then
+
+ cat << EOF
+simonas-scripts - GPL v3 license
+image-mount - image - mount a big amount of image file (use -h for a full list)
+image-umount - imageu - related to image-mount. umount all what mounted
+pendrive-detect - pendrive - detect a pendrive, size, full device
+ioscheduler-list - iosched - list scheduler for all block devices
+boot-kernel-list - boot - list kernels inside /boot, extract version (lile uname -r), say what is used in recent boot
+uuid-change - uuid - change uuid of a volume
+macinstall - install id files (commanded by config file)
+exchange-info - change euro dollar and diff with previouos day
+
+EOF
+
+
+ exit
+elseif [[ $1 == "--version" ]]
+ echo "simona-scripts Version 0.0"
+ exit
+fi
+
+case $1 in
+image|imageu|pendrive|ioched|boot)
+ case $1 in
+ image) launch="image-mount" ;;
+ imageu) launch="image-umount" ;;
+ pendrive) launch="pendrive-detect" ;;
+ ioched) launch="ioscheduler-list" ;;
+ boot) launch="boot-kernel-list" ;;
+ uuid) launch="uuid-change" ;;
+ *) ;;
+ esac
+ ;;
+image-mount|image-umount|pendrive-detect|ioscheduler-list|boot-kernel-list|uuid-change|exchange-info)
+ launch=$1
+ ;;
+*)
+ echo "Sorry, but this one is not a known simonascript bash script."
+ launch=""
+ ;;
+esac
+
+if [[ $launch != "" ]] ; then
+ if [[ -r /bin/$launch ]] ; then
+ echo "Launch '$launch'..."
+ shift
+ #. "$launch"
+ exec "$launch" "$@"
+ else
+ echo "Installed package 'simonas-script' is damaged. Script is unavailable. Please reinstall."
+ fi
+fi
+
+
diff --git a/simonas-scripts.changelog b/simonas-scripts.changelog
new file mode 100644
index 000000000000..f54287f9d0a0
--- /dev/null
+++ b/simonas-scripts.changelog
@@ -0,0 +1,16 @@
+# Changelog
+All notable changes to this project will be documented in this file.
+
+## [0.0.8] - 2018-11-26
+
+### Added
+- Added first release of command uuid-change to package
+
+## [0.0.1] - 2018-11-18
+## First Release
+
+### Added
+
+### Changed
+
+### Removed
diff --git a/uuid-change b/uuid-change
new file mode 100755
index 000000000000..1e355fc2af64
--- /dev/null
+++ b/uuid-change
@@ -0,0 +1,101 @@
+#!/bin/bash
+# Simona Pisano - 2018-11-18
+# simona-scripts
+# Libertamente utilizzabile sotto GPL v3
+
+if [[ $1 == "-h" || $1 == "--help" ]] ; then
+ cat << EOF
+uuid-change command help
+
+If no new uuid is suppplied the command show only 'lsblk -f' output.
+
+Usage
+ uuid-change [--help|-h]
+ uuid-change [--version]
+ uuud-change [device (no /dev prefix required)]
+ uuud-change [device (no /dev prefix required)] [new_uuid]
+
+Optional parameters
+ --help -h -> this help page
+ --versione -> version
+ -y --ask-confirm -> ask confirm before proceeed
+ --force-yes -> required to change parameter for fat32 (very dangerous)
+
+EOF
+
+ exit 0
+elseif [[ $1 == "--version" ]]
+ echo "uuid-change Version 0.0 (simonascripts package)"
+ exit 0
+fi
+
+[[ $1 != "" ]] && device=$1 || { echo "Please insert device (no prefix '/dev/' required) as first command parameter!!"; exit 0; }
+[[ $2 != "" ]] && new_uuid=$2 || new_uuid=""
+
+flagAskConfirm=false
+flagForceYes=false
+while [ $# -ne 0 ] ; do
+ case $1 in
+ -y|--ask-confirm) flagAskConfirm=true ;;
+ --force-yes) flagForceYes=true ;;
+ *) ;;
+ esac
+ shift
+done
+
+[[ ! -r /bin/lsblk ]] && { echo "[ERR] Equired command 'lsblk' not found!! Can't operate. Sorry."; exit 1; }
+[[ ! -r /bin/awk ]] && { echo "[ERR] Equired command 'awk' not found!! Can't operate. Sorry."; exit 1; }
+
+#add /dev prefix
+if [[ ${device:0:1} == "/" ]] ; then
+ if [[ ${device:0:5} != "/dev/" ]] ; then
+ echo "[ERR] Only /dev prefix is accempted as device name. Sorry."
+ exit 1
+ fi
+else
+ device="/dev/$device"
+fi
+
+echo "device=$device" #debug
+
+echo "-------------------- This is the file system interested from command ------------------------"
+lsblk -f $device
+[[ $? -ne 0 ]] && { echo "[ERR] No device '$device' found!!!"; exit 1; } #fail
+echo "----------------------------------------------------------------------------------------------"
+
+[[ $new_uuid == "" ]] && { echo "New uuid not supplyed. Stop here. Bye."; exit 0; }
+
+filesystem=` lsblk -f -n $device | awk '{ print $2 }' `
+old_uuid=` lsblk -f -n $device | awk '{ print $4 }' `
+
+echo "Now changing device <$device> (file system detected <$filesystem>) old <$old_uuid> to new uuid <$new_uuid>..."
+
+if [[ "$flagAskConfirm" == true ]] ; then
+ echo -n "Continue? (Y/N): "; read ok
+ [[ ! $ok =~ ^(yes|y|YES|y|s|S|si|SI|sì)$ ]] && { echo "Exit forced by user."; exit 0; }
+fi
+
+if [[ $filesystem == "vfat" ]] ; then
+ echo -n "This is FAT32 file system. Command change UUID but also reset entire volume content. Are you sure to procede (Y/N): "
+ read ok
+ [[ ! $ok =~ ^(yes|y|YES|y|s|S|si|SI|sì)$ ]] && { echo "Secure exit forced by user."; exit 0; }
+fi
+
+[[ "$flagForceYes" == false && $filesystem == "vfat" ]] && { echo "Too dangerous: specify --force-yes as parameter."; exit 1; }
+
+case $filesystem in
+ ext4)
+ ;; [[ -r /bin/tune2fs ]] && sudo tune2fs -U $new_uuid $device || { echo "[ERR] 'tune2fs' not found!"; exit 1; } ;;
+ ntfs)
+ ;; [[ -r /bin/ntfslabel ]] && sudo ntfslabel --new-serial=$new_uuid $device || { echo "[ERR] 'tune2fs' not found!"; exit 1; } ;;
+ vfat)
+ ;; [[ -r /bin/mkdosfs ]] && sudo mkdosfs -i $new_uid $device || { echo "[ERR] 'mkdosfs' not found!"; exit 1; } ;;
+ btrfs)
+ ;; [[ -r /bin/btrfstune ]] && sudo btrfstune -U $new_uuid $device || { echo "[ERR] 'btrfstune' not found!"; exit 1; } ;;
+ swap) echo "Swap file... nonsense"; exit 1 ;;
+ *) echo "Unsupported file system"; exit 1 ;;
+esac
+
+[[ $? -ne 0 ]] && { echo "[ERR] Fail uuid change cmd!"; exit 1; } #fail
+exit 0;
+