diff --git a/Perso/package_restore.sh b/Perso/package_restore.sh old mode 100644 new mode 100755 index 84bd73d..7fad345 --- a/Perso/package_restore.sh +++ b/Perso/package_restore.sh @@ -1,11 +1,16 @@ #! /bin/bash -cp . /etc/apt/sources.list -cp ./preferences.d/ /etc/apt/preferences.d/my_preferences +if [ $(id -u) -ne "0" ]; then + echo "Please execute with superuser privileges" + exit -1 +fi + +cp ./sources.list /etc/apt/sources.list +cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences cp -r ./sources.list.d/* /etc/apt/sources.list.d apt-get update apt-get install dselect dpkg --set-selections < "manual_package_save" apt-get dselect-upgrade -apt-get remove dselect +apt-get remove dselect \ No newline at end of file diff --git a/Perso/package_save.sh b/Perso/package_save.sh index e31ee8e..25908b1 100755 --- a/Perso/package_save.sh +++ b/Perso/package_save.sh @@ -41,9 +41,14 @@ b="package_restore.sh" echo "#! /bin/bash" > $b echo "" >> $b -echo cp . /etc/apt/sources.list >> $b -echo cp ./preferences.d/ /etc/apt/preferences.d/my_preferences >> $b -echo cp -r ./sources.list.d/* /etc/apt/sources.list.d >> $b +echo 'if [ $(id -u) -ne "0" ]; then' >> $b +echo ' echo "Please execute with superuser privileges"' >> $b +echo " exit -1" >> $b +echo fi >> $b +echo "" >> $b +echo cp ./sources.list /etc/apt/sources.list >> $b +echo cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences >> $b +echo 'cp -r ./sources.list.d/* /etc/apt/sources.list.d' >> $b echo "" >> $b echo apt-get update >> $b echo apt-get install dselect >> $b @@ -55,5 +60,4 @@ chmod u-x "$b" cd - -exit - +exit \ No newline at end of file