Updated package_save to use here-documents and save/restore apt keyring
This commit is contained in:
parent
0a1f908287
commit
4a754e7238
1 changed files with 33 additions and 24 deletions
|
@ -10,7 +10,7 @@ if [ $# -ne 0 ]; then
|
||||||
if [ "$2" = here -o "$1" = here ]; then
|
if [ "$2" = here -o "$1" = here ]; then
|
||||||
location="."
|
location="."
|
||||||
elif [ ! -z "$2" ]; then
|
elif [ ! -z "$2" ]; then
|
||||||
echo "Second argument can be void or 'here' only"
|
echo "Second argument can only be null or 'here'"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -19,45 +19,54 @@ cd $location
|
||||||
pathName="$name""_$(date +'%Y-%m-%d @ %Hh%M')"
|
pathName="$name""_$(date +'%Y-%m-%d @ %Hh%M')"
|
||||||
|
|
||||||
mkdir "$pathName"
|
mkdir "$pathName"
|
||||||
cd "./$pathName"
|
cd "$pathName"
|
||||||
mkdir "./preferences.d"
|
mkdir "./preferences.d"
|
||||||
|
|
||||||
cp /etc/apt/sources.list .
|
cp /etc/apt/sources.list .
|
||||||
cp /etc/apt/preferences.d/my_preferences ./preferences.d/
|
cp /etc/apt/preferences.d/my_preferences ./preferences.d/
|
||||||
cp -r --copy-contents /etc/apt/sources.list.d .
|
cp -r --copy-contents /etc/apt/sources.list.d .
|
||||||
|
|
||||||
sudo dpkg --get-selections > "manual_package_save"
|
dpkg --get-selections > "manual_package_save"
|
||||||
|
apt-key exportall > "apt_keys"
|
||||||
|
|
||||||
a=C4.sh
|
a=C4.sh
|
||||||
|
|
||||||
echo "#! /bin/bash" > $a
|
cat <<EOF > "$a"
|
||||||
echo "" >> $a
|
#! /bin/bash
|
||||||
echo "cd .." >> $a
|
|
||||||
echo "rm -r \"$pathName\"" >> $a
|
cd ..
|
||||||
|
rm -r "$pathName"
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
chmod u+x "$a"
|
chmod u+x "$a"
|
||||||
|
|
||||||
b="package_restore.sh"
|
b="package_restore.sh"
|
||||||
|
|
||||||
echo "#! /bin/bash" > $b
|
cat <<EOF > "$b"
|
||||||
echo "" >> $b
|
#! /bin/bash"
|
||||||
echo 'if [ $(id -u) -ne "0" ]; then' >> $b
|
|
||||||
echo ' echo "Please execute with superuser privileges"' >> $b
|
if [ $(id -u) -ne "0" ]; then
|
||||||
echo " exit -1" >> $b
|
echo "Please execute with superuser privileges"
|
||||||
echo fi >> $b
|
exit -
|
||||||
echo "" >> $b
|
fi
|
||||||
echo cp ./sources.list /etc/apt/sources.list >> $b
|
|
||||||
echo cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences >> $b
|
cp ./sources.list /etc/apt/sources.list
|
||||||
echo 'cp -r ./sources.list.d/* /etc/apt/sources.list.d' >> $b
|
cp ./preferences.d/my_preferences /etc/apt/preferences.d/my_preferences
|
||||||
echo "" >> $b
|
cp -r ./sources.list.d/* /etc/apt/sources.list.d'
|
||||||
echo apt-get update >> $b
|
|
||||||
echo apt-get install dselect >> $b
|
apt-key add < "apt_keys"
|
||||||
echo "dpkg --set-selections < "manual_package_save"" >> $b
|
apt-get update
|
||||||
echo apt-get dselect-upgrade >> $b
|
apt-get install dselect
|
||||||
echo apt-get remove dselect >> $b
|
dselect update
|
||||||
|
dpkg --set-selections < "manual_package_save"
|
||||||
|
apt-get dselect-upgrade -y
|
||||||
|
apt-get remove dselect
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
chmod u-x "$b"
|
chmod u-x "$b"
|
||||||
|
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
Loading…
Add table
Reference in a new issue