#! /bin/bash 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 only be null or 'here'" exit fi fi cd $location 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/ cp -r --copy-contents /etc/apt/sources.list.d . dpkg --get-selections > "manual_package_save" apt-key exportall > "apt_keys" a=C4.sh cat < "$a" #! /bin/bash cd .. rm -r "$pathName" EOF chmod u+x "$a" b="package_restore.sh" cat < "$b" #! /bin/bash" if [ $(id -u) -ne "0" ]; then echo "Please execute with superuser privileges" exit - 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-key add < "apt_keys" apt-get update apt-get install dselect dselect update dpkg --set-selections < "manual_package_save" apt-get dselect-upgrade -y apt-get remove dselect EOF chmod u-x "$b" cd - exit