最后活跃于 6 months ago

修订 4be7e11c00e246334caa6ad36c3edff47d6d512a

squeeze2wheezy.sh 原始文件
1Please also refer to http://www.debian.org/releases/wheezy/releasenotes and use your brain!
2For Roundcube and Sqlite Backend see: http://wiki.debian.org/Roundcube/DeprecationOfSQLitev2
3
4
5# upgrade to UTF-8 locales (http://www.debian.org/releases/testing/i386/release-notes/ap-old-stuff.en.html#switch-utf8)
6dpkg-reconfigure locales
7
8# remove unused config file
9rm -rf /etc/network/options /etc/environment
10
11# change distro (please move 3rd party sources to /etc/apt/sources.list.d/), maybe look into http://ftp.cyconet.org/debian/sources.list.d/
12sed -i s/squeeze/wheezy/g /etc/apt/sources.list*
13sed -i "s/ stable/ wheezy/g" /etc/apt/sources.list*
14sed -i s/squeeze/wheezy/g /etc/apt/preferences*
15sed -i /proposed-updates/d /etc/apt/sources.list*
16sed -i /volatile/d /etc/apt/sources.list*
17sed -i /etch/d /etc/apt/sources.list*
18sed -i /lenny/d /etc/apt/sources.list*
19sed -i s#/backports.org/debian#/ftp.de.debian.org/debian#g /etc/apt/sources.list*
20sed -i s/debian-backports/debian/g /etc/apt/sources.list*
21if [ "$( dpkg -l | grep "^ii.*php5-suhosin" | wc -l)" -ge "1" ]; then \
22 wget http://ftp.cyconet.org/debian/sources.list.d/wheezy-updates-cyconet.list \
23 -O /etc/apt/sources.list.d/wheezy-updates-cyconet.list
24fi
25cat >> /etc/apt/preferences <<EOF
26Package: *
27Pin: release a=squeeze-lts
28Pin-Priority: 200
29
30EOF
31aptitude 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 shorewall
40aptitude unmarkauto $(dpkg-query -W 'linux-image-2.6.*' | cut -f1)
41
42# have a look into required and free disk space
43apt-get -o APT::Get::Trivial-Only=true dist-upgrade || df -h
44
45# check if we have PAE available (http://www.debian.org/releases/testing/i386/release-notes/ch-upgrading.en.html#idp573136)
46grep -q '^flags.*\bpae\b' /proc/cpuinfo && echo "We support PAE: yes" \
47|| echo "We support PAE: no (please install linux-image-486 and remove linux-image-.*-686)"
48
49# record session
50script -t 2>~/upgrade-wheezy.time -a ~/upgrade-wheezy.script
51
52# install our preseed so libc doesn't whine
53cat > /tmp/wheezy.preseed <<EOF
54libc6 glibc/upgrade boolean true
55libc6 glibc/restart-services string
56libc6 libraries/restart-without-asking boolean true
57EOF
58/usr/bin/debconf-set-selections /tmp/wheezy.preseed
59
60# minimal system upgrade
61aptitude upgrade
62
63# randomize crontab
64if [ -f /etc/crontab.dpkg-new ]; then CFG=/etc/crontab.dpkg-new; else CFG=/etc/crontab; fi
65sed -i 's#root cd#root perl -e "sleep int(rand(300))" \&\& cd#' $CFG
66sed -i 's#root\ttest#root\tperl -e "sleep int(rand(3600))" \&\& test#' $CFG
67
68# phpmyadmin
69if [ -f /etc/phpmyadmin/config.inc.php.dpkg-new ]; then CFG=/etc/phpmyadmin/config.inc.php.dpkg-new; \
70 else CFG=/etc/phpmyadmin/config.inc.php; fi
71sed -i "s/\['auth_type'\] = 'cookie'/\['auth_type'\] = 'http'/" $CFG
72sed -i "s#//\$cfg\['Servers'\]\[\$i\]\['auth_type'\] = 'http';#\$cfg['Servers'][\$i]['auth_type'] = 'http';#" $CFG
73
74# remove anonymous mysql access
75mysql -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;"
76
77if [ -f /etc/default/xendomains.dpkg-new ]; then CFG=/etc/default/xendomains.dpkg-new; \
78 else CFG=/etc/default/xendomains; fi
79sed -i s/XENDOMAINS_RESTORE=true/XENDOMAINS_RESTORE=false/ $CFG
80sed -i s#XENDOMAINS_SAVE=/var/lib/xen/save#XENDOMAINS_SAVE=\"\"# $CFG
81
82# dont use iptables when creating xen vifs
83if [ -f /etc/xen/xend-config.sxp.dpkg-new ]; then CFG=/etc/xen/xend-config.sxp.dpkg-new; \
84 else CFG=/etc/xen/xend-config.sxp; fi
85sed -i "s/^(vif-script vif-bridge)/(vif-script vif-bridge-local)/" $CFG
86/bin/sed -i -e 's/^[# ]*\((dom0-min-mem\).*\().*\)$/\1 512\2/' $CFG
87
88cp /etc/xen/scripts/vif-bridge /etc/xen/scripts/vif-bridge-local
89sed -i "s/^ handle_iptable/ true/g" /etc/xen/scripts/vif-bridge-local
90
91# chrony update
92if [ -f /etc/chrony/chrony.conf.new ]; then CFG=/etc/chrony/chrony.conf.new; else CFG=/etc/chrony/chrony.conf; fi
93sed -i s/debian.pool/de.pool/g $CFG
94
95rm -rf /etc/grub.d/09_linux_xen
96dpkg-divert --divert /etc/grub.d/09_linux_xen --rename /etc/grub.d/20_linux_xen
97#mv /etc/grub.d/20_linux_xen /etc/grub.d/09_linux_xen
98echo 'GRUB_CMDLINE_XEN="dom0_mem=512M"' >> /etc/default/grub
99
100# maybe we want to change some shorewall config stuff again
101if [ -f /etc/default/shorewall.dpkg-new ]; then CFG=/etc/default/shorewall.dpkg-new; \
102 else CFG=/etc/default/shorewall; fi
103sed -i s/^startup=0/startup=1/ $CFG
104
105# dist-upgrade
106aptitude dist-upgrade
107
108# migrate expose.ini
109[ -f /etc/php5/conf.d/expose.ini ] && mv /etc/php5/conf.d/expose.ini \
110 /etc/php5/mods-available/local-expose.ini && php5enmod local-expose/90
111# migrate local suhosin config
112find /etc/php5/conf.d/ -type f -name "*suhosin.ini" -exec mv '{}' \
113 /etc/php5/mods-available/local-suhosin.ini \; && php5enmod local-suhosin/90
114
115# mysql
116
117# vsftpd and chroot_local_user?
118if [ "$(grep -i ^chroot_local_user=yes /etc/vsftpd.conf | wc -l)" -ge "1" ]; then \
119 aptitude update; aptitude install -t wheezy-updates vsftpd && \
120 echo "allow_writeable_chroot=YES" >> /etc/vsftpd.conf && /etc/init.d/vsftpd restart; \
121fi
122
123# install fixed quotatool
124dpkg -l | grep quotatool && aptitude update; aptitude safe-upgrade -t wheezy-updates quotatool
125
126# remove old squeeze packages left around (keep eyes open!)
127apt-get autoremove
128aptitude search ?obsolete
129dpkg -l | grep etch | grep -v xen | grep -v unbound | grep -v finch | grep -v fetch | awk '{print $2}' | xargs aptitude -y purge
130dpkg -l | grep lenny | grep -v xen | awk '{print $2}' | xargs aptitude -y purge
131dpkg -l | grep squeeze | grep -v xen | grep -v linux-image | awk '{print $2}' | xargs aptitude -y purge
132aptitude -y install deborphan && deborphan | grep -v xen | grep -v libpam-cracklib | xargs aptitude -y purge
133dpkg -l | grep ^r | awk '{print $2}' | xargs aptitude -y purge
134
135# for the brave YoloOps crowd
136reboot && sleep 180; echo u > /proc/sysrq-trigger ; sleep 2 ; echo s > /proc/sysrq-trigger ; sleep 2 ; echo b > /proc/sysrq-trigger
137