Kode: Vælg alt
#!/bin/sh
# Oprydning og opdatering af Ubuntu 12.04.
# Skrevet af Christian Arvai.
# Scriptet placeres i hjemmemappen, og aktiveres med denne kommando:
# sudo mv ~/opryd.sh /usr/local/bin && sudo chmod +x /usr/local/bin/opryd.sh
# Køres med denne kommando i terminalen:
# opryd.sh
# Kommando til at udskifte dette script med en nyere udgave (med samme navn):
# sudo rm -rf /usr/local/bin/opryd.sh && sudo mv ~/opryd.sh /usr/local/bin && sudo chmod +x /usr/local/bin/opryd.sh
dato=$(date)
mkdir -p ~/Updates
echo "" > ~/Updates/"$dato"
echo "Tidspunkt for denne opdatering $dato" >> ~/Updates/"$dato"
echo "" >> ~/Updates/"$dato"
echo "" >> ~/Updates/"$dato"
echo "Opdatering af systempakker starter." >> ~/Updates/"$dato"
sudo dpkg --configure -a >> ~/Updates/"$dato"
sudo apt-get check -y >> ~/Updates/"$dato"
sudo updatedb >> ~/Updates/"$dato"
sudo aptitude safe-upgrade -y >> ~/Updates/"$dato"
sudo apt-get update -y -m >> ~/Updates/"$dato"
sudo apt-get upgrade -y --force-yes -m >> ~/Updates/"$dato"
echo "Opdatering af systempakker er færdig" >> ~/Updates/"$dato"
echo "" >> ~/Updates/"$dato"
echo "" >> ~/Updates/"$dato"
echo "Oprydning i pakkearkiver starter" >> ~/Updates/"$dato"
sudo apt-get autoremove -y --force-yes >> ~/Updates/"$dato"
sudo apt-get clean -y --force-yes >> ~/Updates/"$dato"
sudo aptitude clean -y >> ~/Updates/"$dato"
sudo aptitude purge ~b >> ~/Updates/"$dato"
echo "Oprydning i pakkearkiver er færdig" >> ~/Updates/"$dato"
echo "" >> ~/Updates/"$dato"
echo "" >> ~/Updates/"$dato"
echo "Sletning af filer ift. script. starter" >> ~/Updates/"$dato"
rm -rf ~/.adobe/*
rm -rf ~/.bash_history
rm -rf ~/.bash_history~
rm -rf ~/.cache/*
rm -rf ~/.cddbslave/*
rm -rf ~/.config/libreoffice/*/user/registrymodifications.xcu
rm -rf ~/.dvdcss/*
rm -rf ~/.goutputstream-*
rm -rf ~/.local/share/Trash
rm -rf ~/.macromedia/*
rm -rf ~/.mozilla/firefox/*/Cache/*
rm -rf ~/.shotwell/thumbs
rm -rf ~/.thumbnails/*
rm -rf ~/brasero-session.log
rm -rf ~/danid.log
rm -rf ~/nohup.out
rm -rf /media/*/.Trash*
rm -rf /media/*/*RECYCLE.BIN
rm -rf /media/*/System*Volume*Information
sudo rm -rf /root/.cache/dconf
sudo rm -rf /root/.local/share/recently-used.xbel.*
sudo rm -rf /root/.local/share/Trash
sudo rm -rf /root/.thumbnails
sudo rm -rf /usr/share/locale/*/LC_MESSAGES
sudo rm -rf /var/backups/*gz
sudo rm -rf /var/cache/apt/archives/*.deb
sudo rm -rf /var/cache/fontconfig/*
sudo rm -rf /var/log/*
echo "Sletning af filer er færdig" >> ~/Updates/"$dato"
echo "" >> ~/Updates/"$dato"
echo "" >> ~/Updates/"$dato"
echo "" >> ~/Updates/"$dato"
echo "Opdateringen og oprydningen af Ubuntu er færdig nu." >> ~/Updates/"$dato"
echo "Det er muligt at pc'en skal genstartes." >> ~/Updates/"$dato"
echo "" >> ~/Updates/"$dato"
exit