1
0
Fork 0

On arrête d'être stupide et on échappe les commandes

Arrêt de la restauration si non superuser
This commit is contained in:
trotFunky 2018-02-27 14:43:30 +01:00
parent 414cf617ff
commit 3012af9c19
2 changed files with 17 additions and 8 deletions

9
Perso/package_restore.sh Normal file → Executable file
View file

@ -1,7 +1,12 @@
#! /bin/bash #! /bin/bash
cp . /etc/apt/sources.list if [ $(id -u) -ne "0" ]; then
cp ./preferences.d/ /etc/apt/preferences.d/my_preferences 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 cp -r ./sources.list.d/* /etc/apt/sources.list.d
apt-get update apt-get update

View file

@ -41,9 +41,14 @@ b="package_restore.sh"
echo "#! /bin/bash" > $b echo "#! /bin/bash" > $b
echo "" >> $b echo "" >> $b
echo cp . /etc/apt/sources.list >> $b echo 'if [ $(id -u) -ne "0" ]; then' >> $b
echo cp ./preferences.d/ /etc/apt/preferences.d/my_preferences >> $b echo ' echo "Please execute with superuser privileges"' >> $b
echo cp -r ./sources.list.d/* /etc/apt/sources.list.d >> $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 "" >> $b
echo apt-get update >> $b echo apt-get update >> $b
echo apt-get install dselect >> $b echo apt-get install dselect >> $b
@ -56,4 +61,3 @@ chmod u-x "$b"
cd - cd -
exit exit