Last active
November 25, 2020 01:19
-
-
Save nexus166/70d2117f67ddffc357282db6af976678 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/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
commented
Nov 25, 2020
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment