From 3012af9c19b698ae1230768054b7c02c96927043 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Tue, 27 Feb 2018 14:43:30 +0100 Subject: [PATCH] =?UTF-8?q?On=20arr=C3=AAte=20d'=C3=AAtre=20stupide=20et?= =?UTF-8?q?=20on=20=C3=A9chappe=20les=20commandes=20Arr=C3=AAt=20de=20la?= =?UTF-8?q?=20restauration=20si=20non=20superuser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Perso/package_restore.sh | 11 ++++++++--- Perso/package_save.sh | 14 +++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) mode change 100644 => 100755 Perso/package_restore.sh 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