最后活跃于 6 months ago

修订 1d07843cf261449d20c92c5bbf97f8ed7e497423

wheezy2jessie.sh 原始文件
1Please 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)
5dpkg-reconfigure locales
6
7# remove unused config file
8rm -rf /etc/network/options /etc/environment
9
10# Transition and remove entries from older releases
11sed -i s#/backports.org/debian#/ftp.de.debian.org/debian#g /etc/apt/sources.list*
12sed -i s/debian-backports/debian/g /etc/apt/sources.list*
13sed -i /etch/d /etc/apt/sources.list*
14sed -i /lenny/d /etc/apt/sources.list*
15sed -i /sarge/d /etc/apt/sources.list*
16sed -i /squeeze/d /etc/apt/sources.list*
17sed -i /volatile/d /etc/apt/sources.list*
18sed -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/
20sed -i s/wheezy/jessie/g /etc/apt/sources.list*
21sed -i "s/ stable/ jessie/g" /etc/apt/sources.list*
22sed -i s/wheezy/jessie/g /etc/apt/preferences*
23sed -i s/wheezy/jessie/g /etc/apt/sources.list.d/*wheezy*
24rename s/wheezy/jessie/g /etc/apt/sources.list.d/*wheezy*
25aptitude update
26
27# check package status
28dpkg --audit
29aptitude search "~ahold" | grep "^.h"
30dpkg --get-selections | grep hold
31
32# unmark packages auto
33aptitude unmarkauto vim
34aptitude unmarkauto monitoring-plugins-standard monitoring-plugins-basic
35aptitude unmarkauto $(dpkg-query -W 'linux-image-3.2.*' | cut -f1)
36
37# have a look into required and free disk space
38apt-get -o APT::Get::Trivial-Only=true dist-upgrade || df -h
39
40# record session
41script -t 2>~/upgrade-jessie.time -a ~/upgrade-jessie.script
42
43# install our preseed so libc doesn't whine
44cat > /tmp/jessie.preseed <<EOF
45libc6 glibc/upgrade boolean true
46libc6 glibc/restart-services string
47libc6 libraries/restart-without-asking boolean true
48EOF
49/usr/bin/debconf-set-selections /tmp/jessie.preseed
50
51# update aptitude first
52[ "$(which aptitude)" = "/usr/bin/aptitude" ] && aptitude install aptitude
53
54# minimal system upgrade (keep sysvinit / see http://noone.org/talks/debian-ohne-systemd/debian-ohne-systemd-clt.html#%2811%29)
55aptitude upgrade '~U' 'sysvinit-core+'
56
57# (re)enable wheel
58if [ -f /etc/pam.d/su.dpkg-new ]; then CFG=/etc/pam.d/su.dpkg-new; else CFG=/etc/pam.d/su; fi
59sed -i "s/# auth required pam_wheel.so/auth required pam_wheel.so/" $CFG
60
61# (re)configure snmpd
62if [ -f /etc/snmp/snmpd.conf.dpkg-new ]; then CFG=/etc/snmp/snmpd.conf.dpkg-new; \
63 else CFG=/etc/snmp/snmpd.conf; fi
64sed -i "s^#rocommunity secret 10.0.0.0/16^rocommunity mycommunity^g" $CFG
65sed -i s/#agentAddress/agentAddress/ $CFG
66sed -i "s/^ rocommunity public/# rocommunity public/" $CFG
67sed -i "s/^ rocommunity6 public/# rocommunity6 public/" $CFG
68sed -i "s/agentAddress udp:127/#agentAddress udp:127/" $CFG
69
70# fix our xen modification
71rm -rf /etc/grub.d/09_linux_xen
72dpkg-divert --divert /etc/grub.d/09_linux_xen --rename /etc/grub.d/20_linux_xen
73
74# chrony update
75if [ -f /etc/chrony/chrony.conf.new ]; then CFG=/etc/chrony/chrony.conf.new; else CFG=/etc/chrony/chrony.conf; fi
76sed -i s/debian.pool/de.pool/g $CFG
77
78# randomize crontab
79if [ -f /etc/crontab.dpkg-new ]; then CFG=/etc/crontab.dpkg-new; else CFG=/etc/crontab; fi
80sed -i 's#root cd#root perl -e "sleep int(rand(300))" \&\& cd#' $CFG
81sed -i 's#root\ttest#root\tperl -e "sleep int(rand(3600))" \&\& test#' $CFG
82
83# phpmyadmin
84if [ -f /etc/phpmyadmin/config.inc.php.dpkg-new ]; then CFG=/etc/phpmyadmin/config.inc.php.dpkg-new; \
85 else CFG=/etc/phpmyadmin/config.inc.php; fi
86sed -i "s/\['auth_type'\] = 'cookie'/\['auth_type'\] = 'http'/" $CFG
87sed -i "s#//\$cfg\['Servers'\]\[\$i\]\['auth_type'\] = 'http';#\$cfg['Servers'][\$i]['auth_type'] = 'http';#" $CFG
88
89# maybe we want to change some shorewall config stuff again
90sed -i s/^startup=0/startup=1/ /etc/default/shorewall
91# nat helper needs to be install (http://shorewall.net/Helpers.html#idp8854577312)
92ucf /usr/share/shorewall/configfiles/conntrack /etc/shorewall/conntrack
93
94# full-upgrade
95aptitude full-upgrade
96
97# Apache2 config migration
98# see also /usr/share/doc/apache2/NEWS.Debian.gz
99#
100# migrate sites into new naming scheme
101perl /usr/share/doc/apache2/migrate-sites.pl
102# migrate server config snippets into new directory
103cat > /tmp/a2confmigrate << EOF
104APACHE2BASEDIR="/etc/apache2"; for CONF in \$(ls -l \${APACHE2BASEDIR}/conf.d/ | grep -v ^l | awk '{print \$9}' | grep -v ^$); do
105 if ! [ "\${CONF##*.}" == "conf" ]; then
106 mv \${APACHE2BASEDIR}/conf.d/"\${CONF}" \${APACHE2BASEDIR}/conf.d/"\${CONF}".conf
107 CONF="\${CONF}.conf"
108 fi
109 mv \${APACHE2BASEDIR}/conf.d/"\${CONF}" \${APACHE2BASEDIR}/conf-available/"\${CONF}"
110 # enable this
111 CONF=\$(basename "\${CONF}" .conf)
112 a2enconf "\${CONF}"
113done
114EOF
115sh /tmp/a2confmigrate
116# migrate standard Options config to valid one
117sed -i "s/Options ExecCGI/Options +ExecCGI/" /etc/apache2/sites-available/*
118# fix probable Piped Logs
119sed -i 's/|exec /| /' /etc/apache2/sites-available/*
120# check for probably incompatible Apache configration statements (see https://gist.github.com/waja/86a3a055c1fedfba3c58#upstream-changes)
121# Even lists conditional statements which might be not a problem
122rgrep -iE "(Order|Allow|Deny|Satisfy) " /etc/apache2/conf-enabled/* | grep -v ":#" && rgrep -iE "(Order|Allow|Deny|Satisfy) " /etc/apache2/sites-enabled/* | grep -v ":#"
123# just in case you have you DocumentRoots in /var/www, you might want to also check for .htaccess containing those
124# Even lists conditional statements which might be not a problem
125rgrep -iE "(Order|Allow|Deny|Satisfy) " --include .htaccess /var/www/ | grep -v ":#"
126
127# serveral changes may be needed to adjust content of config files
128# see https://gist.github.com/waja/86a3a055c1fedfba3c58#file-apache2.0to2.4.md
129
130# migrate redmine plugins
131mv /usr/share/redmine/vendor/plugins/* /usr/share/redmine/plugins/ && rmdir /usr/share/redmine/vendor/plugins/
132# Remove inconsistent link in /usr/share/redmine/vendor/rails
133rm /usr/share/redmine/vendor/rails
134# migrate database config for mysql
135sed -i "s/adapter: mysql/adapter: mysql2/" /etc/redmine/default/database.yml
136
137# Fixing Typo bug in claav-daemon (http://bugs.debian.org/778507)
138sed -i "s/DEBCONFILE/DEBCONFFILE/" /var/lib/dpkg/info/clamav-daemon.postinst
139
140# Upgrade postgres
141if [ "$(dpkg -l | grep "postgresql-9.1" | awk {'print $2'})" = "postgresql-9.1" ]; then \
142 aptitude install postgresql-9.4 && \
143 pg_dropcluster --stop 9.4 main && \
144 /etc/init.d/postgresql stop && \
145 pg_upgradecluster -v 9.4 9.1 main && \
146 sed -i "s/^manual/auto/g" /etc/postgresql/9.4/main/start.conf && \
147 sed -i "s/^port = .*/port = 5432/" /etc/postgresql/9.4/main/postgresql.conf && \
148 sed -i "s/^shared_buffers = .*/shared_buffers = 128MB/" /etc/postgresql/9.4/main/postgresql.conf && \
149 /etc/init.d/postgresql restart; \
150fi
151pg_dropcluster 9.1 main
152
153# remove old squeeze packages left around (keep eyes open!)
154apt-get autoremove
155aptitude search ?obsolete
156dpkg -l | grep etch | grep -v xen | grep -v unbound | grep -v finch | awk '{print $2}' | xargs aptitude -y purge
157dpkg -l | grep lenny | grep -v xen | awk '{print $2}' | xargs aptitude -y purge
158dpkg -l | grep -E 'deb6|squeeze' | grep -v xen | awk '{print $2}' | xargs aptitude -y purge
159dpkg -l | grep -E 'deb7|wheezy' | grep -v xen | grep -v -E 'linux-image|mailscanner|openswan|debian-security-support' | awk '{print $2}' | xargs aptitude -y purge
160aptitude -y install deborphan && deborphan | grep -v xen | grep -v libpam-cracklib | xargs aptitude -y purge
161dpkg -l | grep ^r | awk '{print $2}' | xargs aptitude -y purge
162
163# for the brave YoloOps crowd
164reboot && sleep 180; echo u > /proc/sysrq-trigger ; sleep 2 ; echo s > /proc/sysrq-trigger ; sleep 2 ; echo b > /proc/sysrq-trigger
165
166### not needed until now
167# mysql
168# remove anonymous mysql access
169#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;"
170
171# dont use iptables when creating xen vifs
172#cp /etc/xen/scripts/vif-bridge /etc/xen/scripts/vif-bridge-local
173#sed -i "s/^ handle_iptable/ true/g" /etc/xen/scripts/vif-bridge-local
174#sed -i "s/^(vif-script vif-bridge)/(vif-script vif-bridge-local)/" /etc/xen/xend-config.sxp
175
176# xen
177#/bin/sed -i -e 's/^[# ]*\((dom0-min-mem\).*\().*\)$/\1 512\2/' /etc/xen/xend-config.sxp
178#sed -i s/XENDOMAINS_RESTORE=true/XENDOMAINS_RESTORE=false/ /etc/default/xendomains
179#sed -i s#XENDOMAINS_SAVE=/var/lib/xen/save#XENDOMAINS_SAVE=\"\"# /etc/default/xendomains
180#dpkg-divert --divert /etc/grub.d/09_linux_xen --rename /etc/grub.d/20_linux_xen
181#echo 'GRUB_CMDLINE_XEN="dom0_mem=512M"' >> /etc/default/grub
182
183# migrate expose.ini
184#[ -f /etc/php5/conf.d/expose.ini ] && mv /etc/php5/conf.d/expose.ini \
185# /etc/php5/mods-available/local-expose.ini && php5enmod local-expose/90
186# migrate local suhosin config
187#find /etc/php5/conf.d/ -type f -name "*suhosin.ini" -exec mv '{}' \
188# /etc/php5/mods-available/local-suhosin.ini \; && php5enmod local-suhosin/90
189
x_fix_apache2.4_slash_docroot.sh 原始文件
1# when <Directory > config is applied on / instead of DocumentRoot, we need to fix that
2cat > /tmp/a2conf_dir_migrate << EOF
3grep -i "<directory />" /etc/apache2/sites-enabled/*
4for HOST in \$(grep -i "<directory />" /etc/apache2/sites-enabled/* | grep -v 000-default | awk -F':' '{print \$1}' | sed "s/.conf//" | sed "s#^/etc/apache2/sites-enabled/##"); do
5 DOCROOT=\$(grep DocumentRoot /etc/apache2/sites-enabled/\${HOST} | awk '{print \$2}');
6 sed -i "s#<Directory />#<Directory \${DOCROOT}>#" /etc/apache2/sites-available/\${HOST};
7done
8echo -e "Migration done.\nRemaining problematic configurations, please investigate:"
9grep -i "<directory />" /etc/apache2/sites-enabled/*
10EOF
11sh /tmp/a2conf_dir_migrate
12
z_apache2.0to2.4.md 原始文件

Migrating the Apache config files into new places and naming scheme

see https://gist.github.com/waja/86a3a055c1fedfba3c58#file-wheezy2jessie-sh

Upstream changes

Some more other handy resources

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/