1
0
Fork 0
Scripts/Perso/package_save.sh

43 lines
726 B
Bash
Executable file

#! /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 be void or 'here' only"
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 .
sudo dpkg --get-selections > "manual_package_save"
a=C4.sh
echo "#! /bin/bash" > $a
echo "" >> $a
echo "cd .." >> $a
echo "rm -r \"$pathName\"" >> $a
chmod u+x "$a"
cd -
exit