Ultima attività 6 months ago

Revisione 31e9ae4fae4d54a7835e9e54969699dfce706aad

stretch2buster.sh Raw
1Please also refer to http://www.debian.org/releases/buster/releasenotes and use your brain!
2
3
4# upgrade to UTF-8 locales (http://www.debian.org/releases/buster/amd64/release-notes/ap-old-stuff.en.html#switch-utf8)
5dpkg-reconfigure locales
6
7# remove unused config file
8rm -rf /etc/network/options /etc/environment
9
10# are there 3rd party packages installed? (https://www.debian.org/releases/buster/amd64/release-notes/ch-upgrading.de.html#system-status)
11aptitude search '~i(!~ODebian)'
12
13# check for ftp protocol in sources lists (https://www.debian.org/releases/buster/amd64/release-notes/ch-information.en.html#deprecation-of-ftp-apt-mirrors)
14rgrep --color "deb ftp" /etc/apt/sources.list*
15
16# Transition and remove entries from older releases
17sed -i /lenny/d /etc/apt/sources.list*
18sed -i /sarge/d /etc/apt/sources.list*
19sed -i /squeeze/d /etc/apt/sources.list*
20sed -i /wheezy/d /etc/apt/sources.list*
21sed -i /jessie/d /etc/apt/sources.list*
22sed -i /volatile/d /etc/apt/sources.list*
23sed -i /proposed-updates/d /etc/apt/sources.list*
24# change distro (please move 3rd party sources to /etc/apt/sources.list.d/), maybe look into http://ftp.cyconet.org/debian/sources.list.d/
25sed -i s/stretch/buster/g /etc/apt/sources.list*
26sed -i "s/ stable/ buster/g" /etc/apt/sources.list*
27sed -i s/stretch/buster/g /etc/apt/preferences*
28sed -i s/stretch/buster/g /etc/apt/sources.list.d/*stretch*
29rename s/stretch/buster/g /etc/apt/sources.list.d/*stretch*
30rgrep --color stretch /etc/apt/sources.list*
31apt-get update
32
33# check package status
34dpkg --audit
35aptitude search "~ahold" | grep "^.h"
36dpkg --get-selections | grep hold
37
38# unmark packages auto
39aptitude unmarkauto vim net-tools && \
40aptitude unmarkauto libapache2-mpm-itk && \
41aptitude unmarkauto $(dpkg-query -W 'linux-image-4.9.0*' | cut -f1)
42
43# have a look into required and free disk space
44apt-get -o APT::Get::Trivial-Only=true dist-upgrade || df -h
45
46# record session
47script -t 2>~/upgrade-buster.time -a ~/upgrade-buster.script
48
49# install our preseed so libc doesn't whine
50cat > /tmp/stretch.preseed <<EOF
51libc6 glibc/upgrade boolean true
52libc6 glibc/restart-services string
53libc6 libraries/restart-without-asking boolean true
54EOF
55/usr/bin/debconf-set-selections /tmp/stretch.preseed
56
57# update aptitude first
58[ "$(which aptitude)" = "/usr/bin/aptitude" ] && aptitude install aptitude
59
60# minimal system upgrade
61aptitude upgrade
62
63# chrony update
64if [ -f /etc/chrony/chrony.conf.new ]; then CFG=/etc/chrony/chrony.conf.new; else CFG=/etc/chrony/chrony.conf; fi
65sed -i s/2.debian.pool/0.de.pool/g $CFG
66
67# migrate unattended-upgrades config
68if [ -f /etc/apt/apt.conf.d/50unattended-upgrades.dpkg-new ]; then CFG=/etc/apt/apt.conf.d/50unattended-upgrades.dpkg-new; \
69 else CFG=/etc/apt/apt.conf.d/50unattended-upgrades; fi
70sed -i s/stretch/buster/g $CFG
71sed -i s/crontrib/contrib/g $CFG
72sed -i "s#// If automatic reboot is enabled and needed, reboot at the specific#// Automatically reboot even if there are users currently logged in.\n//Unattended-Upgrade::Automatic-Reboot-WithUsers \"true\";\n\n// If automatic reboot is enabled and needed, reboot at the specific#" $CFG
73cat >> $CFG <<EOF
74
75// Enable logging to syslog. Default is False
76// Unattended-Upgrade::SyslogEnable "false";
77
78// Specify syslog facility. Default is daemon
79// Unattended-Upgrade::SyslogFacility "daemon";
80
81EOF
82
83
84# Fix our ssh pub key package configuration
85[ -x /var/lib/dpkg/info/config-openssh-server-authorizedkeys-core.postinst ] && \
86 /var/lib/dpkg/info/config-openssh-server-authorizedkeys-core.postinst configure
87
88## phpmyadmin
89if [ -f /etc/phpmyadmin/config.inc.php.dpkg-new ]; then CFG=/etc/phpmyadmin/config.inc.php.dpkg-new; \
90 else CFG=/etc/phpmyadmin/config.inc.php; fi
91sed -i "s/\['auth_type'\] = 'cookie'/\['auth_type'\] = 'http'/" $CFG
92sed -i "s#//\$cfg\['Servers'\]\[\$i\]\['auth_type'\] = 'http';#\$cfg['Servers'][\$i]['auth_type'] = 'http';#" $CFG
93
94# full-upgrade
95apt-get dist-upgrade
96
97# remove old squeeze packages left around (keep eyes open!)
98apt autoremove && \
99apt purge $(dpkg -l | awk '/gcc-4.9/ { print $2 }') && \
100apt purge $(aptitude search ?obsolete | grep -v -E 'linux-image|mailscanner' | awk '/^i *A/ { print $3 }') && \
101apt purge $(aptitude search ?obsolete | grep -v -E 'linux-image|mailscanner' | awk '/^i/ { print $2 }') && \
102apt purge $(dpkg -l | grep etch | grep -v xen | grep -v unbound | grep -v finch | awk '/^rc/ { print $2 }') && \
103apt purge $(dpkg -l | grep lenny | grep -v xen | awk '/^rc/ { print $2 }') && \
104apt purge $(dpkg -l | grep -E 'deb6|squeeze' | grep -v xen | awk '/^rc/ { print $2 }') && \
105apt purge $(dpkg -l | grep -E 'deb7|wheezy' | grep -v xen | grep -v -E 'linux-image|mailscanner|openswan|debian-security-support' | awk '/^rc/ { print $2 }') && \
106apt purge $(dpkg -l | grep -E 'deb8|jessie' | grep -v xen | grep -v -E 'linux-image|debian-security-support' | awk '{ print $2 }') && \
107apt purge $(dpkg -l | grep -E 'deb9|stretch' | grep -v xen | grep -v -E 'linux-image|debian-security-support' | awk '{ print $2 }') && \
108apt -y install deborphan && apt purge $(deborphan | grep -v xen | grep -v -E 'libpam-cracklib|libapache2-mpm-itk')
109apt purge $(dpkg -l | awk '/^rc/ { print $2 }')
110
111# for the brave YoloOps crowd
112reboot && sleep 180; echo u > /proc/sysrq-trigger ; sleep 2 ; echo s > /proc/sysrq-trigger ; sleep 2 ; echo b > /proc/sysrq-trigger
113
114### not needed until now
115# Upgrade postgres
116# See also https://www.debian.org/releases/stretch/amd64/release-notes/ch-information.de.html#plperl
117if [ "$(dpkg -l | grep "postgresql-9.4" | awk {'print $2'})" = "postgresql-9.4" ]; then \
118 aptitude install postgresql-9.6 && \
119 pg_dropcluster --stop 9.6 main && \
120 /etc/init.d/postgresql stop && \
121 pg_upgradecluster -v 9.6 9.4 main && \
122 sed -i "s/^manual/auto/g" /etc/postgresql/9.6/main/start.conf && \
123 sed -i "s/^port = .*/port = 5432/" /etc/postgresql/9.6/main/postgresql.conf && \
124 sed -i "s/^shared_buffers = .*/shared_buffers = 128MB/" /etc/postgresql/9.6/main/postgresql.conf && \
125 /etc/init.d/postgresql restart; \
126fi
127pg_dropcluster 9.4 main
128