2017-11-19 15:22:42 +01:00
|
|
|
#! /bin/bash
|
|
|
|
|
2017-11-21 23:23:43 +01:00
|
|
|
name=packages_state
|
|
|
|
location="$HOME/SYS_SAVES/"
|
|
|
|
|
|
|
|
if [ $# -ne 0 ]; then
|
|
|
|
if [ ! -z "$1" -a "$1" != "here" ]; then
|
|
|
|
name=$1
|
|
|
|
fi
|
|
|
|
if [ "$2" = here -o "$1" = here ]; then
|
|
|
|
location="."
|
|
|
|
elif [ ! -z "$2" ]; then
|
|
|
|
echo "Second argument can be void or 'here' only"
|
|
|
|
exit
|
|
|
|
fi
|
2017-11-19 15:22:42 +01:00
|
|
|
fi
|
|
|
|
|
2017-11-21 23:23:43 +01:00
|
|
|
cd $location
|
2017-11-19 15:22:42 +01:00
|
|
|
pathName="$name""_$(date +'%Y-%m-%d @ %Hh%M')"
|
|
|
|
|
|
|
|
mkdir "$pathName"
|
|
|
|
cd "./$pathName"
|
|
|
|
mkdir "./preferences.d"
|
|
|
|
|
|
|
|
cp /etc/apt/sources.list .
|
|
|
|
cp /etc/apt/preferences.d/my_preferences ./preferences.d/
|
2017-11-21 22:01:17 +01:00
|
|
|
cp -r --copy-contents /etc/apt/sources.list.d .
|
2017-11-19 15:22:42 +01:00
|
|
|
|
|
|
|
sudo dpkg --get-selections > "manual_package_save"
|
|
|
|
|
2017-11-21 22:01:17 +01:00
|
|
|
a=C4.sh
|
2017-11-19 15:22:42 +01:00
|
|
|
|
|
|
|
echo "#! /bin/bash" > $a
|
|
|
|
echo "" >> $a
|
|
|
|
echo "cd .." >> $a
|
|
|
|
echo "rm -r \"$pathName\"" >> $a
|
|
|
|
|
|
|
|
chmod u+x "$a"
|
|
|
|
|
2018-02-27 13:36:00 +01:00
|
|
|
b="package_restore.sh"
|
|
|
|
|
|
|
|
echo "#! /bin/bash" > $b
|
|
|
|
echo "" >> $b
|
2018-02-27 14:43:30 +01:00
|
|
|
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
|
2018-02-27 13:36:00 +01:00
|
|
|
echo "" >> $b
|
|
|
|
echo apt-get update >> $b
|
|
|
|
echo apt-get install dselect >> $b
|
|
|
|
echo "dpkg --set-selections < "manual_package_save"" >> $b
|
|
|
|
echo apt-get dselect-upgrade >> $b
|
|
|
|
echo apt-get remove dselect >> $b
|
|
|
|
|
|
|
|
chmod u-x "$b"
|
|
|
|
|
2017-11-19 15:22:42 +01:00
|
|
|
cd -
|
|
|
|
|
2018-02-27 14:43:30 +01:00
|
|
|
exit
|