summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimona2018-12-05 11:24:09 +0100
committersimona2018-12-05 11:24:09 +0100
commitd18699fdb5fd4f943a6c745a78089b3a1012a76b (patch)
tree79694fa9ca93f7d6450e691d9934a7ce2e059b70
parentd23f5f9d35e10099383c940fe87cfaa6d1c1661c (diff)
downloadaur-simonascripts.tar.gz
added param Rm to macinstall cmd
-rw-r--r--.SRCINFO6
-rwxr-xr-xPKGBUILD6
-rwxr-xr-xmacinstall48
-rw-r--r--macinstall.conf4
4 files changed, 55 insertions, 9 deletions
diff --git a/.SRCINFO b/.SRCINFO
index e853171149f4..a63780d88c92 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = simonascripts
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.0.20
+ pkgver = 0.0.21
pkgrel = 1
changelog = simonascripts.changelog
arch = any
@@ -36,8 +36,8 @@ pkgbase = simonascripts
md5sums = 40ef9e0d1831cc1865208bf52eaa2cef
md5sums = 331e7dbdd1adbed7beaad5975a368d91
md5sums = 3189eb5ae50a9ddce43c8820c35ba2b0
- md5sums = 11525ff54253381211531dbb13f761fd
- md5sums = 895210bbf0e6c16c6df7437eb3489ac1
+ md5sums = 39af555980d188d68f3ec51dff7a0be5
+ md5sums = 6bdfded6596cd064703e37e5657a351a
md5sums = 261d420ae53438b3fadda33059686a33
md5sums = f3197a3b2aad5cb79b5dbab0d35fd0f9
diff --git a/PKGBUILD b/PKGBUILD
index 4e2f45b64b40..2cd0d18a3fed 100755
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,6 +1,6 @@
# Maintainer: Simona <simona.pisano[at]gmail[dot]com>
pkgname=simonascripts
-pkgver=0.0.20
+pkgver=0.0.21
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."
@@ -41,8 +41,8 @@ md5sums=('3f5599c3588f01b625aa9feb0a0e8b99'
'40ef9e0d1831cc1865208bf52eaa2cef'
'331e7dbdd1adbed7beaad5975a368d91'
'3189eb5ae50a9ddce43c8820c35ba2b0'
- '11525ff54253381211531dbb13f761fd'
- '895210bbf0e6c16c6df7437eb3489ac1'
+ '39af555980d188d68f3ec51dff7a0be5'
+ '6bdfded6596cd064703e37e5657a351a'
'261d420ae53438b3fadda33059686a33'
'f3197a3b2aad5cb79b5dbab0d35fd0f9')
diff --git a/macinstall b/macinstall
index e5cf0db368cb..50c4ae1797d9 100755
--- a/macinstall
+++ b/macinstall
@@ -187,8 +187,12 @@ postfix_bak_file_name=".bak"
#cfg related
prop_cfg_file_copy_num="CopyFilesNum"
prop_cfg_dir_copy_num="CopyDirectoriesNum"
+prop_cfg_rm_num="RmNum"
+
prop_cfg_file_copy="CopyFile"
prop_cfg_dir_copy="CopyDirectory"
+prop_cfg_rm="Rm"
+
prop_cfg_write_sem="WriteSemaphore"
prop_cfg_read_sem="AllowOnlyIfPreviousMacIs"
@@ -199,14 +203,15 @@ 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 ]] ; then
- echo -e "$ERR $filename_cfg: None to do!!! 'CopyFilesNum' and 'CopyDirectoriesNum' not correctly defined. Please modify cfg."
+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
@@ -215,6 +220,8 @@ if [[ $number_files -gt 0 ]] ; then
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
@@ -236,6 +243,8 @@ if [[ $number_directories -gt 0 ]] ; then
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
@@ -253,6 +262,14 @@ if [[ $number_directories -gt 0 ]] ; then
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 -------------------------------------------------------------------------------------------------------------------
@@ -289,7 +306,6 @@ fi
#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)
#
@@ -378,6 +394,10 @@ if [[ $number_directories -gt 0 ]] ; then
done
fi
+if [[ $number_rm -gt 0 ]] ; then
+ echo -e "$WARN Attention! Backup of remove ($number_rm) not done."
+fi
+
#
## Copia nuovi files
#
@@ -424,6 +444,28 @@ if [[ $number_directories -gt 0 ]] ; then
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)
#
diff --git a/macinstall.conf b/macinstall.conf
index c8d180fb4b8f..987e260b639a 100644
--- a/macinstall.conf
+++ b/macinstall.conf
@@ -42,8 +42,12 @@ 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