Last active
May 15, 2020 20:44
-
-
Save DILL44/6adb28854e1a7c1be370 to your computer and use it in GitHub Desktop.
backupApt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
configFile=$1 | |
#demande le nom du fichier si il n'a pas été rentrer en paramètre | |
while [ X$configFile == X ] && [ -f $configFile ] | |
do | |
read -p "give file name (can-t be empty):" configFile | |
done | |
# recupère les programmes installés dans les logs de apt | |
sudo gzip -Nd /var/log/apt/history.log.* | |
file=`egrep 'apt-get install' /var/log/apt/history.log*` | |
# transforme en une commade d'install | |
file=`echo $file | sed 's/\/var\/log\/apt\/history.log[.]\?[0-9]*:Commandline: apt-get install//g'` | |
#écrit un fichier avec la version de la distrib, les sources des logiciels et la commande d'install | |
echo "#!/bin/bash">$configFile | |
uname -v>>$configFile | |
echo " ">>$configFile | |
cat /etc/apt/sources.list>>$configFile | |
echo " ">>$configFile | |
echo " apt-get intall $file">>$configFile | |
sudo gzip -N /var/log/apt/history.log.* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment