Skip to content

Instantly share code, notes, and snippets.

@nexus166
Last active November 25, 2020 01:19
Show Gist options
  • Select an option

  • Save nexus166/70d2117f67ddffc357282db6af976678 to your computer and use it in GitHub Desktop.

Select an option

Save nexus166/70d2117f67ddffc357282db6af976678 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -xeo pipefail
mem_clean() {
for i in {1..3}; do
sync
echo $i > /proc/sys/vm/drop_caches
done
}
_refresh() {
mem_clean
apt-get clean
apt-get autoclean
dpkg --configure -a
[[ ! -z ${1} ]] && apt-get autoremove --purge -y || true
}
rel_sources() {
local RELEASE="${1}"
mv -v /etc/apt/sources.list /etc/apt/sources.list.bk
cat <<EOASL | tee /etc/apt/sources.list
deb http://deb.debian.org/debian ${RELEASE} main
deb http://security.debian.org/debian-security ${RELEASE}/updates main
deb http://deb.debian.org/debian ${RELEASE}-updates main
EOASL
}
NEXT_RELEASE=${1}
[[ -z $NEXT_RELEASE ]] && exit 127
export NEXT_RELEASE
CURR_RELEASE=${2:-$(lsb_release -cs)}
export CURR_RELEASE
DEBIAN_FRONTEND=noninteractive
export DEBIAN_FRONTEND
echo -e "nameserver 1.1.1.1\\nnameserver 1.0.0.1" | tee /etc/resolv.conf
_refresh
rel_sources ${CURR_RELEASE}
apt-get update
yes | apt-get -o APT::Get::AutomaticRemove=true remove -y --purge $(dpkg -l | awk '/apache2/ || /samba/ || /x11/ || /xserver/ || /gparted/ || /qemu/ || /bonnie/ || /nmap/ || /vorbis/ || /flac/ || /sound/ || /ipmi/ || /iperf/ || /afflib-tools/ || /build-essential/ || /ckermit/ || /fail2ban/ || /ftp/ || /lynx/ || /lynx-cur/ || /recoverjpeg/ || /tcpdump/ || /telnet/ || /vsftpd/ || /yara/ || /duplicity/ || /manpages/ || /myrescue/ || /rifiuti2/ || /safecopy/ || /scalpel/ || /sshfs/ || /tftp/ {print $2}') || true
_refresh 1
yes | apt-get upgrade -y
_refresh
yes | apt-get -o APT::Get::AutomaticRemove=true -o APT::Acquire::Retries=1 dist-upgrade -y || true
_refresh 1
rel_sources ${NEXT_RELEASE}
apt-get update
yes | apt-get -o APT::Get::AutomaticRemove=true -o APT::Acquire::Retries=1 upgrade -y
_refresh 1
yes | apt-get -o APT::Get::AutomaticRemove=true -o APT::Acquire::Retries=1 dist-upgrade -y
_refresh 1
@nexus166
Copy link
Copy Markdown
Author

nexus166 commented Sep 24, 2019

raw_gist='https://gist.github.com/nexus166/70d2117f67ddffc357282db6af976678/raw/882794054511e9e928291e1d20d4dafc216fa853/kimsufi-rescue-upgrade.sh'
wget -qO- "$raw_gist" | bash -s - stretch jessie

@nexus166
Copy link
Copy Markdown
Author

@nexus166
Copy link
Copy Markdown
Author

export DEBIAN_FRONTEND=noninteractive; set -xv; apt-get clean;apt-get autoclean; sed -i 's/jessie/stretch/g' /etc/apt/sources.list; yes | apt-get -o APT::Get::AutomaticRemove=true remove -y --purge $(dpkg -l | awk '/apache2/ || /samba/ || /x11/ || /xserver/ || /gparted/ || /qemu/ || /bonnie/ || /nmap/ || /vorbis/ || /flac/ || /sound/ || /ipmi/ || /iperf/ || /afflib-tools/ || /build-essential/ || /ckermit/ || /fail2ban/ || /ftp/ || /lynx/ || /lynx-cur/ || /recoverjpeg/ || /tcpdump/ || /telnet/ || /vsftpd/ || /yara/ || /duplicity/ || /manpages/ || /myrescue/ || /rifiuti2/ || /safecopy/ || /scalpel/ || /sshfs/ || /tftp/ {print $2}') || true; mv -f /var/cache/apt /dev/shm; ln -vs /dev/shm/apt /var/cache/apt; apt-get update; apt-get dist-upgrade -y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment