Skip to content

Instantly share code, notes, and snippets.

@edt11x
Created January 27, 2018 23:51
Show Gist options
  • Save edt11x/2be5c3bfeebc7ba7368f73039887491e to your computer and use it in GitHub Desktop.
Save edt11x/2be5c3bfeebc7ba7368f73039887491e to your computer and use it in GitHub Desktop.
runaptgetupdate - script to update my Debian system
#!/bin/bash
# Need bash instead of just /bin/sh
#
###############################################################################
#
# Debian has multiple different, non-overlapping, mechanisms to update the
# current version. I like to run Debian Sid, the unstable rolling version. One
# of the dangers is that dependencies for big packages like gnome, can easily
# get broken or worse, uninstalled. This is a script I have that tries hard to
# do many of the possible ways to update/upgrade and tries to load the set of
# packages that I like back in. Its far from perfect but it keeps me from
# having to think too much about upgrading my Debian system.
#
###############################################################################
#
# Run apt-get update until it succeeds
#
if [[ $EUID -ne 0 ]]; then
echo "This must be run as root, sudo and try again."
exit 1
fi
keep_trying ()
{
cmd="$1"
export FAILED=1
while [ "$FAILED" -ne 0 ]
do
echo ==================================================
echo "Trying $cmd"
echo ==================================================
eval $cmd
FAILED=$?
if [ "$FAILED" -eq 0 ]
then
echo "$cmd succeeded, moving on ..."
echo ==================================================
echo " "
echo " "
else
echo "$cmd failed."
echo "Sleeping for 20 minutes."
sleep 1200
echo "Retrying."
fi
done
}
# try to do a couple recovery items first
# in case we have unconfigured packages
dpkg --configure -a
# in case we have packages that are having problems installed
apt-get -f install
# next thing is we want to try to autoremove any packages.
# kernels may have been configured that are taking up space
# in /boot that are going to prevent updates from being able
# to install new kernels
keep_trying "apt-get -y autoremove --purge"
keep_trying "apt-get update --list-cleanup"
keep_trying "apt-get update"
keep_trying "upgrade-system"
keep_trying "apt-get -y upgrade"
keep_trying "apt-get -y dist-upgrade"
keep_trying "apt -y full-upgrade"
keep_trying "apt-get -y autoclean"
keep_trying "apt-get -y clean"
keep_trying "apt-get -y autoremove --purge"
keep_trying "apt-get -y remove `deborphan` --purge"
keep_trying "apt-get -y remove cups cups-bsd cups-client cups-common --purge"
keep_trying "apt-get -y remove lirc --purge"
keep_trying "apt-get -u upgrade"
keep_trying "apt-get install apt-file"
keep_trying "apt-get install aptitude"
keep_trying "apt-file update"
apt-get install linux-headers-$(uname -r|sed 's,[^-]*-[^-]*-,,')
# tasksel install gnome-desktop --new-install
# courier-imap-ssl
# systraq
for i in \
ack-grep \
alpine \
apg \
aptitude \
avahi-daemon \
avahi-discover \
bleachbit \
build-essential \
cinnamon \
clamav \
clamav-freshclam \
clang \
courier-imap \
cpanminus \
cron-apt \
deja-dup \
desktop-base \
dkms \
echoping \
ecryptfs-utils \
ent \
fish \
fonts-inconsolata \
fping \
fwbuilder \
gamin \
git \
gnome \
golang \
task-gnome-desktop \
hashdeep \
htop \
hwloc \
i2c-tools \
iftop \
imap-client \
imap-server \
iptraf \
kde-baseapps \
kde-full \
kde-standard \
libfile-dircompare-perl \
libnss-mdns \
libreoffice \
libsasl2-modules \
libstring-random-perl \
lightdm \
lsb-base \
lsb-release \
lshw \
lxde \
lynis \
meld \
module-assistant \
mosh \
most \
mpg123 \
mplayer \
mutt \
nano \
ntfs-3g \
openbox \
openvpn \
par2 \
pcregrep \
plasma-desktop \
pv \
pyqt5-dev \
python \
python3-pyqt5 \
python3-venv \
sasl2-bin \
seahorse-nautilus \
secure-delete \
smokeping \
synaptic \
telnet \
terminator \
texlive-fonts-extra \
totem \
transmission-cli \
transmission-gtk \
trickle \
unrar \
vim \
vim-gnome \
virtualbox \
virtualbox-dkms \
virtualbox-guest-dkms \
virtualbox-guest-source \
virtualbox-guest-x11 \
virtualbox-qt \
vlc \
vnc4server \
wget \
wipe \
wireshark \
xfce4 \
xinput \
xorg
do
keep_trying "aptitude install $i --with-recommends"
done
fc-cache -fv
# /home/edt/bin/makesurepkgs
update-grub
# See if there are any packages that still have trash left behind
echo 'dpkg -l | egrep "^rc"'
dpkg -l | egrep "^rc"
echo tripwire -m i
tripwire -m i
echo all done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment