wheezy2jessie.sh
· 5.9 KiB · Bash
Surowy
Please also refer to http://www.debian.org/releases/jessie/releasenotes and use your brain!
# upgrade to UTF-8 locales (http://www.debian.org/releases/jessie/amd64/release-notes/ap-old-stuff.en.html#switch-utf8)
dpkg-reconfigure locales
# remove unused config file
rm -rf /etc/network/options /etc/environment
# Transition and remove entries from older releases
sed -i s#/backports.org/debian#/ftp.de.debian.org/debian#g /etc/apt/sources.list*
sed -i s/debian-backports/debian/g /etc/apt/sources.list*
sed -i /etch/d /etc/apt/sources.list*
sed -i /lenny/d /etc/apt/sources.list*
sed -i /sarge/d /etc/apt/sources.list*
sed -i /squeeze/d /etc/apt/sources.list*
sed -i /volatile/d /etc/apt/sources.list*
sed -i /proposed-updates/d /etc/apt/sources.list*
# change distro (please move 3rd party sources to /etc/apt/sources.list.d/), maybe look into http://ftp.cyconet.org/debian/sources.list.d/
sed -i s/wheezy/jessie/g /etc/apt/sources.list*
sed -i "s/ stable/ jessie/g" /etc/apt/sources.list*
sed -i s/wheezy/jessie/g /etc/apt/preferences*
sed -i s/wheezy/jessie/g /etc/apt/sources.list.d/*wheezy*
rename s/wheezy/jessie/g /etc/apt/sources.list.d/*wheezy*
aptitude update
# check package status
dpkg --audit
aptitude search "~ahold" | grep "^.h"
dpkg --get-selections | grep hold
# unmark packages auto
aptitude unmarkauto vim
aptitude unmarkauto $(dpkg-query -W 'linux-image-3.2.*' | cut -f1)
# have a look into required and free disk space
apt-get -o APT::Get::Trivial-Only=true dist-upgrade || df -h
# record session
script -t 2>~/upgrade-jessie.time -a ~/upgrade-jessie.script
# install our preseed so libc doesn't whine
cat > /tmp/jessie.preseed <<EOF
libc6 glibc/upgrade boolean true
libc6 glibc/restart-services string
libc6 libraries/restart-without-asking boolean true
EOF
/usr/bin/debconf-set-selections /tmp/jessie.preseed
# update aptitude first
[ "$(which aptitude)" = "/usr/bin/aptitude" ] && aptitude install aptitude
# minimal system upgrade (keep sysvinit / see http://noone.org/talks/debian-ohne-systemd/debian-ohne-systemd-clt.html#%2811%29)
aptitude upgrade '~U' 'sysvinit-core+'
# (re)enable wheel
if [ -f /etc/pam.d/su.dpkg-new ]; then CFG=/etc/pam.d/su.dpkg-new; else CFG=/etc/pam.d/su; fi
sed -i "s/# auth required pam_wheel.so/auth required pam_wheel.so/" $CFG
# (re)configure snmpd
if [ -f /etc/snmp/snmpd.conf.dpkg-new ]; then CFG=/etc/snmp/snmpd.conf.dpkg-new; \
else CFG=/etc/snmp/snmpd.conf; fi
sed -i "s^#rocommunity secret 10.0.0.0/16^rocommunity mycommunity^g" $CFG
sed -i s/#agentAddress/agentAddress/ $CFG
sed -i "s/^ rocommunity public/# rocommunity public/" $CFG
sed -i "s/^ rocommunity6 public/# rocommunity6 public/" $CFG
sed -i "s/agentAddress udp:127/#agentAddress udp:127/" $CFG
# randomize crontab
if [ -f /etc/crontab.dpkg-new ]; then CFG=/etc/crontab.dpkg-new; else CFG=/etc/crontab; fi
sed -i 's#root cd#root perl -e "sleep int(rand(300))" \&\& cd#' $CFG
sed -i 's#root\ttest#root\tperl -e "sleep int(rand(3600))" \&\& test#' $CFG
# phpmyadmin
if [ -f /etc/phpmyadmin/config.inc.php.dpkg-new ]; then CFG=/etc/phpmyadmin/config.inc.php.dpkg-new; \
else CFG=/etc/phpmyadmin/config.inc.php; fi
sed -i "s/\['auth_type'\] = 'cookie'/\['auth_type'\] = 'http'/" $CFG
sed -i "s#//\$cfg\['Servers'\]\[\$i\]\['auth_type'\] = 'http';#\$cfg['Servers'][\$i]['auth_type'] = 'http';#" $CFG
# maybe we want to change some shorewall config stuff again
sed -i s/^startup=0/startup=1/ /etc/default/shorewall
# full-upgrade
aptitude full-upgrade
# Apache2 config migration
# can be done via https://gist.github.com/waja/9c6ca010bf44b7a6f99c/raw/migrate_apache22to24.sh
# or sites transition with /usr/share/doc/apache2/migrate-sites.pl
#
# More info in /usr/share/doc/apache2/NEWS.Debian.gz
# Upstream authorization changes: http://httpd.apache.org/docs/2.4/upgrading.html#run-time
# https://www.digitalocean.com/community/tutorials/migrating-your-apache-configuration-from-2-2-to-2-4-syntax
# https://www.linode.com/docs/security/upgrading/updating-virtual-host-settings-from-apache-2-2-to-apache-2-4
# http://linoxide.com/linux-how-to/apache-migration-2-2-to-2-4-ubuntu-14-04/
# remove old squeeze packages left around (keep eyes open!)
apt-get autoremove
aptitude search ?obsolete
dpkg -l | grep etch | grep -v xen | grep -v unbound | grep -v finch | awk '{print $2}' | xargs aptitude -y purge
dpkg -l | grep lenny | grep -v xen | awk '{print $2}' | xargs aptitude -y purge
dpkg -l | grep squeeze | grep -v xen | awk '{print $2}' | xargs aptitude -y purge
dpkg -l | grep -E 'deb7|wheezy' | grep -v xen | grep -v linux-image | awk '{print $2}' | xargs aptitude -y purge
aptitude -y install deborphan && deborphan | grep -v xen | grep -v libpam-cracklib | xargs aptitude -y purge
dpkg -l | grep ^r | awk '{print $2}' | xargs aptitude -y purge
### not needed until now
# mysql
# remove anonymous mysql access
#mysql -u root -p -e "DELETE FROM mysql.user WHERE User=''; DELETE FROM mysql.db WHERE Db='test' AND Host='%' OR Db='test\\_%' AND Host='%'; FLUSH PRIVILEGES;"
# dont use iptables when creating xen vifs
#cp /etc/xen/scripts/vif-bridge /etc/xen/scripts/vif-bridge-local
#sed -i "s/^ handle_iptable/ true/g" /etc/xen/scripts/vif-bridge-local
#sed -i "s/^(vif-script vif-bridge)/(vif-script vif-bridge-local)/" /etc/xen/xend-config.sxp
# xen
#/bin/sed -i -e 's/^[# ]*\((dom0-min-mem\).*\().*\)$/\1 512\2/' /etc/xen/xend-config.sxp
#sed -i s/XENDOMAINS_RESTORE=true/XENDOMAINS_RESTORE=false/ /etc/default/xendomains
#sed -i s#XENDOMAINS_SAVE=/var/lib/xen/save#XENDOMAINS_SAVE=\"\"# /etc/default/xendomains
#dpkg-divert --divert /etc/grub.d/09_linux_xen --rename /etc/grub.d/20_linux_xen
#echo 'GRUB_CMDLINE_XEN="dom0_mem=512M"' >> /etc/default/grub
# migrate expose.ini
#[ -f /etc/php5/conf.d/expose.ini ] && mv /etc/php5/conf.d/expose.ini \
# /etc/php5/mods-available/local-expose.ini && php5enmod local-expose/90
# migrate local suhosin config
#find /etc/php5/conf.d/ -type f -name "*suhosin.ini" -exec mv '{}' \
# /etc/php5/mods-available/local-suhosin.ini \; && php5enmod local-suhosin/90
| 1 | Please also refer to http://www.debian.org/releases/jessie/releasenotes and use your brain! |
| 2 | |
| 3 | |
| 4 | # upgrade to UTF-8 locales (http://www.debian.org/releases/jessie/amd64/release-notes/ap-old-stuff.en.html#switch-utf8) |
| 5 | dpkg-reconfigure locales |
| 6 | |
| 7 | # remove unused config file |
| 8 | rm -rf /etc/network/options /etc/environment |
| 9 | |
| 10 | # Transition and remove entries from older releases |
| 11 | sed -i s#/backports.org/debian#/ftp.de.debian.org/debian#g /etc/apt/sources.list* |
| 12 | sed -i s/debian-backports/debian/g /etc/apt/sources.list* |
| 13 | sed -i /etch/d /etc/apt/sources.list* |
| 14 | sed -i /lenny/d /etc/apt/sources.list* |
| 15 | sed -i /sarge/d /etc/apt/sources.list* |
| 16 | sed -i /squeeze/d /etc/apt/sources.list* |
| 17 | sed -i /volatile/d /etc/apt/sources.list* |
| 18 | sed -i /proposed-updates/d /etc/apt/sources.list* |
| 19 | # change distro (please move 3rd party sources to /etc/apt/sources.list.d/), maybe look into http://ftp.cyconet.org/debian/sources.list.d/ |
| 20 | sed -i s/wheezy/jessie/g /etc/apt/sources.list* |
| 21 | sed -i "s/ stable/ jessie/g" /etc/apt/sources.list* |
| 22 | sed -i s/wheezy/jessie/g /etc/apt/preferences* |
| 23 | sed -i s/wheezy/jessie/g /etc/apt/sources.list.d/*wheezy* |
| 24 | rename s/wheezy/jessie/g /etc/apt/sources.list.d/*wheezy* |
| 25 | aptitude update |
| 26 | |
| 27 | # check package status |
| 28 | dpkg --audit |
| 29 | aptitude search "~ahold" | grep "^.h" |
| 30 | dpkg --get-selections | grep hold |
| 31 | |
| 32 | # unmark packages auto |
| 33 | aptitude unmarkauto vim |
| 34 | aptitude unmarkauto $(dpkg-query -W 'linux-image-3.2.*' | cut -f1) |
| 35 | |
| 36 | # have a look into required and free disk space |
| 37 | apt-get -o APT::Get::Trivial-Only=true dist-upgrade || df -h |
| 38 | |
| 39 | # record session |
| 40 | script -t 2>~/upgrade-jessie.time -a ~/upgrade-jessie.script |
| 41 | |
| 42 | # install our preseed so libc doesn't whine |
| 43 | cat > /tmp/jessie.preseed <<EOF |
| 44 | libc6 glibc/upgrade boolean true |
| 45 | libc6 glibc/restart-services string |
| 46 | libc6 libraries/restart-without-asking boolean true |
| 47 | EOF |
| 48 | /usr/bin/debconf-set-selections /tmp/jessie.preseed |
| 49 | |
| 50 | # update aptitude first |
| 51 | [ "$(which aptitude)" = "/usr/bin/aptitude" ] && aptitude install aptitude |
| 52 | |
| 53 | # minimal system upgrade (keep sysvinit / see http://noone.org/talks/debian-ohne-systemd/debian-ohne-systemd-clt.html#%2811%29) |
| 54 | aptitude upgrade '~U' 'sysvinit-core+' |
| 55 | |
| 56 | # (re)enable wheel |
| 57 | if [ -f /etc/pam.d/su.dpkg-new ]; then CFG=/etc/pam.d/su.dpkg-new; else CFG=/etc/pam.d/su; fi |
| 58 | sed -i "s/# auth required pam_wheel.so/auth required pam_wheel.so/" $CFG |
| 59 | |
| 60 | # (re)configure snmpd |
| 61 | if [ -f /etc/snmp/snmpd.conf.dpkg-new ]; then CFG=/etc/snmp/snmpd.conf.dpkg-new; \ |
| 62 | else CFG=/etc/snmp/snmpd.conf; fi |
| 63 | sed -i "s^#rocommunity secret 10.0.0.0/16^rocommunity mycommunity^g" $CFG |
| 64 | sed -i s/#agentAddress/agentAddress/ $CFG |
| 65 | sed -i "s/^ rocommunity public/# rocommunity public/" $CFG |
| 66 | sed -i "s/^ rocommunity6 public/# rocommunity6 public/" $CFG |
| 67 | sed -i "s/agentAddress udp:127/#agentAddress udp:127/" $CFG |
| 68 | |
| 69 | # randomize crontab |
| 70 | if [ -f /etc/crontab.dpkg-new ]; then CFG=/etc/crontab.dpkg-new; else CFG=/etc/crontab; fi |
| 71 | sed -i 's#root cd#root perl -e "sleep int(rand(300))" \&\& cd#' $CFG |
| 72 | sed -i 's#root\ttest#root\tperl -e "sleep int(rand(3600))" \&\& test#' $CFG |
| 73 | |
| 74 | # phpmyadmin |
| 75 | if [ -f /etc/phpmyadmin/config.inc.php.dpkg-new ]; then CFG=/etc/phpmyadmin/config.inc.php.dpkg-new; \ |
| 76 | else CFG=/etc/phpmyadmin/config.inc.php; fi |
| 77 | sed -i "s/\['auth_type'\] = 'cookie'/\['auth_type'\] = 'http'/" $CFG |
| 78 | sed -i "s#//\$cfg\['Servers'\]\[\$i\]\['auth_type'\] = 'http';#\$cfg['Servers'][\$i]['auth_type'] = 'http';#" $CFG |
| 79 | |
| 80 | # maybe we want to change some shorewall config stuff again |
| 81 | sed -i s/^startup=0/startup=1/ /etc/default/shorewall |
| 82 | |
| 83 | # full-upgrade |
| 84 | aptitude full-upgrade |
| 85 | |
| 86 | # Apache2 config migration |
| 87 | # can be done via https://gist.github.com/waja/9c6ca010bf44b7a6f99c/raw/migrate_apache22to24.sh |
| 88 | # or sites transition with /usr/share/doc/apache2/migrate-sites.pl |
| 89 | # |
| 90 | # More info in /usr/share/doc/apache2/NEWS.Debian.gz |
| 91 | # Upstream authorization changes: http://httpd.apache.org/docs/2.4/upgrading.html#run-time |
| 92 | # https://www.digitalocean.com/community/tutorials/migrating-your-apache-configuration-from-2-2-to-2-4-syntax |
| 93 | # https://www.linode.com/docs/security/upgrading/updating-virtual-host-settings-from-apache-2-2-to-apache-2-4 |
| 94 | # http://linoxide.com/linux-how-to/apache-migration-2-2-to-2-4-ubuntu-14-04/ |
| 95 | |
| 96 | # remove old squeeze packages left around (keep eyes open!) |
| 97 | apt-get autoremove |
| 98 | aptitude search ?obsolete |
| 99 | dpkg -l | grep etch | grep -v xen | grep -v unbound | grep -v finch | awk '{print $2}' | xargs aptitude -y purge |
| 100 | dpkg -l | grep lenny | grep -v xen | awk '{print $2}' | xargs aptitude -y purge |
| 101 | dpkg -l | grep squeeze | grep -v xen | awk '{print $2}' | xargs aptitude -y purge |
| 102 | dpkg -l | grep -E 'deb7|wheezy' | grep -v xen | grep -v linux-image | awk '{print $2}' | xargs aptitude -y purge |
| 103 | aptitude -y install deborphan && deborphan | grep -v xen | grep -v libpam-cracklib | xargs aptitude -y purge |
| 104 | dpkg -l | grep ^r | awk '{print $2}' | xargs aptitude -y purge |
| 105 | |
| 106 | ### not needed until now |
| 107 | # mysql |
| 108 | # remove anonymous mysql access |
| 109 | #mysql -u root -p -e "DELETE FROM mysql.user WHERE User=''; DELETE FROM mysql.db WHERE Db='test' AND Host='%' OR Db='test\\_%' AND Host='%'; FLUSH PRIVILEGES;" |
| 110 | |
| 111 | # dont use iptables when creating xen vifs |
| 112 | #cp /etc/xen/scripts/vif-bridge /etc/xen/scripts/vif-bridge-local |
| 113 | #sed -i "s/^ handle_iptable/ true/g" /etc/xen/scripts/vif-bridge-local |
| 114 | #sed -i "s/^(vif-script vif-bridge)/(vif-script vif-bridge-local)/" /etc/xen/xend-config.sxp |
| 115 | |
| 116 | # xen |
| 117 | #/bin/sed -i -e 's/^[# ]*\((dom0-min-mem\).*\().*\)$/\1 512\2/' /etc/xen/xend-config.sxp |
| 118 | #sed -i s/XENDOMAINS_RESTORE=true/XENDOMAINS_RESTORE=false/ /etc/default/xendomains |
| 119 | #sed -i s#XENDOMAINS_SAVE=/var/lib/xen/save#XENDOMAINS_SAVE=\"\"# /etc/default/xendomains |
| 120 | #dpkg-divert --divert /etc/grub.d/09_linux_xen --rename /etc/grub.d/20_linux_xen |
| 121 | #echo 'GRUB_CMDLINE_XEN="dom0_mem=512M"' >> /etc/default/grub |
| 122 | |
| 123 | # migrate expose.ini |
| 124 | #[ -f /etc/php5/conf.d/expose.ini ] && mv /etc/php5/conf.d/expose.ini \ |
| 125 | # /etc/php5/mods-available/local-expose.ini && php5enmod local-expose/90 |
| 126 | # migrate local suhosin config |
| 127 | #find /etc/php5/conf.d/ -type f -name "*suhosin.ini" -exec mv '{}' \ |
| 128 | # /etc/php5/mods-available/local-suhosin.ini \; && php5enmod local-suhosin/90 |
| 129 |