Skip to content

Instantly share code, notes, and snippets.

@lowendscripts
Last active November 11, 2018 13:41
Show Gist options
  • Select an option

  • Save lowendscripts/9631c6070b241daefcc7d10a2fdb76a2 to your computer and use it in GitHub Desktop.

Select an option

Save lowendscripts/9631c6070b241daefcc7d10a2fdb76a2 to your computer and use it in GitHub Desktop.
# **DEBIAN WHEEZY TO DEBIAN STRETCH**
#
#
# To run this script, enter the following line (without the preceeding #) at the command line
# apt-get update;apt-get install -y screen apt-utils ca-certificates;wget https://gist.github.com/lowendscripts/9631c6070b241daefcc7d10a2fdb76a2/raw/97b76f1005927cc4a66aa0d5d8965f7867020c55/wheezy_to_stretch_installer.sh; bash wheezy_to_stretch_installer.sh
#
# 0) This is just here for the script version. If you are running the script version, and you become disconnected,
# you can resume the session upon reconnecting to SSH by entering the command screen -dr
# Delete the next two lines if you want to disable the kernel check
kernel_version=`uname -r`
if [ "$kernel_version" != 2.6.32-48-pve ]; then echo "Sorry, your kernel version has not been tested with this script. I am exiting for your own safety. If you do want to take the additional risk of testing the script on a kernel version it has not been tested with, delete the first two lines of this script."; exit 1; fi
cat >> wheezy_to_stretch.sh << EOF2
# 1) Install the debian-7.0-x86_64 or the debian-7.0-x86-minimal template from the hosts control panel.
# 2) Log in as root using an SSH session. I do not recommend using the novnc terminal for the purposes of this tutorial
# 3) Check your kernel version by running the command
uname -r
# If the kernel version is not 2.6.32-48-pve, this tutorial has not been tested with it.
# Continuing is more risky than normal. Please add a post to the thread if you find it works with a different version.
# 4) Remove the hold on the systemd package and the sasl2db file
rm /etc/apt/preferences.d/parallels; rm /etc/sasldb2
# 5) Make two folders that are needed for the vzfifo.service files or links to be deployed in
mkdir -p /etc/systemd/system
mkdir -p /lib/systemd/system
# 6) Create the vzfifo.service file (this is a multiline command)
cat >> /lib/systemd/system/vzfifo.service << EOF
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
[Unit]
Description=Tell that Container is started
ConditionPathExists=/proc/vz
ConditionPathExists=!/proc/bc
After=multi-user.target quotaon.service quotacheck.service
[Service]
Type=forking
ExecStart=/bin/touch /.vzfifo
TimeoutSec=0
RemainAfterExit=no
[Install]
WantedBy=multi-user.target
EOF
# 7) Create a symbolic link to the vzfifo.service file manually as systemd isn't installed yet.
ln -s /lib/systemd/system/vzfifo.service /etc/systemd/system/vzfifo.service
# 8) If you are using the 64bit template, remove those packages that are not needed for a minimal template. This command is not needed in a minimal image.
apt-get remove -y apache2 apache2-doc apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common bind9 bind9-host bind9utils binutils bsd-mailx bsdmainutils bzip2 cifs-utils cracklib-runtime db-util db5.1-util expat fetchmail file finger fontconfig fontconfig-config fonts-freefont-ttf ftp gettext groff-base info install-info iputils-arping iputils-tracepath isc-dhcp-client isc-dhcp-common kbd ldap-utils less libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libapt-inst1.5 libavahi-client3 libavahi-common-data libavahi-common3 libbind9-80 libcap2 libcrack2 libcroco3 libcups2 libdns88 libfile-copy-recursive-perl libfontconfig1 libfreetype6 libgeoip1 libgettextpo0 libgomp1 libgssglue1 libisc84 libisccc80 libisccfg82 liblockfile-bin liblockfile1 libltdl7 liblwres80 libmagic1 libodbc1 libpaper1 libpcap0.8 libperl5.14 libpipeline1 libpopt0 libsensors4 libsnmp-base libsnmp15 libsysfs2 libtalloc2 libtdb1 libtirpc1 libunistring0 libwbclient0 libxml2 locales-all logrotate lynx lynx-cur m4 make man-db manpages memtester mlocate mtools ncurses-term odbcinst odbcinst1debian2 openssl openssl-blacklist procmail psutils pwgen rmail rpcbind rsync samba samba-common sendmail sendmail-base sendmail-bin sendmail-cf sendmail-doc sensible-mda sharutils snmp ssl-cert sudo syslinux syslinux-common tcpdump tcsh telnet tofrodos traceroute ttf-dejavu ttf-dejavu-core ttf-dejavu-extra ttf-freefont unixodbc unzip update-inetd uuid-runtime whois wide-dhcpv6-client xinetd
# 9) Remove the plymouth package so as to avoid problems installing the jessie packages later on.
apt-get purge -y plymouth
# 10) Remove the /etc/apt.d/preferences.d/parallels file, which makes it impossible to install systemd
rm /etc/apt/preferences.d/parallels
# 11) Run apt-get update, and upgrade all the existing packages to their latest versions.
apt-get update
DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get -y -o "Dpkg::Options::=--force-confnew" upgrade
DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get -y -o "Dpkg::Options::=--force-confnew" dist-upgrade
# 12) Change the distribution used by the /etc/apt/sources.list file from wheezy to jessie.
sed -i 's/wheezy/jessie/g' /etc/apt/sources.list
# 13) Run apt-get update, and upgrade all the existing packages to their latest jessie versions.
apt-get update
DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get -y -o "Dpkg::Options::=--force-confnew" upgrade
DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get -y -o "Dpkg::Options::=--force-confnew" dist-upgrade
# 14) Apply some OpenVZ customisations
sed -i -e '/getty/d' /etc/inittab
sed -i -e 's@\([[:space:]]\)\(/var/log/\)@\1-\2@' /etc/*syslog.conf
rm -f /etc/mtab
ln -s /proc/mounts /etc/mtab
# 15) Run an apt-get autoclean and autoremove and remove the wide-dhcpv6-client package
apt-get remove wide-dhcpv6-client -y
# You can stop here unless you want to upgrade to Stretch
# 16) Change the distribution used by the /etc/apt/sources.list file from wheezy to jessie.
sed -i 's/jessie/stretch/g' /etc/apt/sources.list
# 17) Run apt-get update, and upgrade all the existing packages to their latest jessie versions.
apt-get update
DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get -y -o "Dpkg::Options::=--force-confnew" upgrade
DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get -y -o "Dpkg::Options::=--force-confnew" dist-upgrade
# 18) Apply some OpenVZ customisations
sed -i -e '/getty/d' /etc/inittab
sed -i -e 's@\([[:space:]]\)\(/var/log/\)@\1-\2@' /etc/*syslog.conf
rm -f /etc/mtab
ln -s /proc/mounts /etc/mtab
# 19) Run an apt-get autoclean and autoremove
apt-get autoclean -y
apt-get autoremove -y
apt-get remove wide-dhcpv6-client -y
# 20) This is just to finish up the script version - ignore if installing manually
echo " #########################################"
echo " ### THE SCRIPT HAS NOW FINISHED ###"
echo " ### We are now rebooting. Reconnect ###"
echo " ### using your SSH client in a minute ###"
echo " ### or two! ###"
echo " #########################################"
sleep 5
reboot -f
# 21) This is just here for the script version - ignore if installing manually
EOF2
apt-get update; apt-get install screen apt-utils -y
screen -dm bash wheezy_to_stretch.sh
sleep 1
screen -r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment