Ultima attività 6 months ago

Revisione 095a949770e532a83bf6409313cf6646144720d0

apache2.0to2.4.md Raw

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/

wheezy2jessie.sh Raw
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 $(dpkg-query -W 'linux-image-3.2.*' | cut -f1)
35
36# have a look into required and free disk space
37apt-get -o APT::Get::Trivial-Only=true dist-upgrade || df -h
38
39# record session
40script -t 2>~/upgrade-jessie.time -a ~/upgrade-jessie.script
41
42# install our preseed so libc doesn't whine
43cat > /tmp/jessie.preseed <<EOF
44libc6 glibc/upgrade boolean true
45libc6 glibc/restart-services string
46libc6 libraries/restart-without-asking boolean true
47EOF
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)
54aptitude upgrade '~U' 'sysvinit-core+'
55
56# (re)enable wheel
57if [ -f /etc/pam.d/su.dpkg-new ]; then CFG=/etc/pam.d/su.dpkg-new; else CFG=/etc/pam.d/su; fi
58sed -i "s/# auth required pam_wheel.so/auth required pam_wheel.so/" $CFG
59
60# (re)configure snmpd
61if [ -f /etc/snmp/snmpd.conf.dpkg-new ]; then CFG=/etc/snmp/snmpd.conf.dpkg-new; \
62 else CFG=/etc/snmp/snmpd.conf; fi
63sed -i "s^#rocommunity secret 10.0.0.0/16^rocommunity mycommunity^g" $CFG
64sed -i s/#agentAddress/agentAddress/ $CFG
65sed -i "s/^ rocommunity public/# rocommunity public/" $CFG
66sed -i "s/^ rocommunity6 public/# rocommunity6 public/" $CFG
67sed -i "s/agentAddress udp:127/#agentAddress udp:127/" $CFG
68
69# chrony update
70if [ -f /etc/chrony/chrony.conf.new ]; then CFG=/etc/chrony/chrony.conf.new; else CFG=/etc/chrony/chrony.conf; fi
71sed -i s/debian.pool/de.pool/g $CFG
72
73# randomize crontab
74if [ -f /etc/crontab.dpkg-new ]; then CFG=/etc/crontab.dpkg-new; else CFG=/etc/crontab; fi
75sed -i 's#root cd#root perl -e "sleep int(rand(300))" \&\& cd#' $CFG
76sed -i 's#root\ttest#root\tperl -e "sleep int(rand(3600))" \&\& test#' $CFG
77
78# phpmyadmin
79if [ -f /etc/phpmyadmin/config.inc.php.dpkg-new ]; then CFG=/etc/phpmyadmin/config.inc.php.dpkg-new; \
80 else CFG=/etc/phpmyadmin/config.inc.php; fi
81sed -i "s/\['auth_type'\] = 'cookie'/\['auth_type'\] = 'http'/" $CFG
82sed -i "s#//\$cfg\['Servers'\]\[\$i\]\['auth_type'\] = 'http';#\$cfg['Servers'][\$i]['auth_type'] = 'http';#" $CFG
83
84# maybe we want to change some shorewall config stuff again
85sed -i s/^startup=0/startup=1/ /etc/default/shorewall
86
87# full-upgrade
88aptitude full-upgrade
89
90# Apache2 config migration
91# see also /usr/share/doc/apache2/NEWS.Debian.gz
92#
93# migrate sites into new naming scheme
94perl /usr/share/doc/apache2/migrate-sites.pl
95# migrate server config snippets into new directory
96APACHE2BASEDIR="/etc/apache2"; for CONF in $(ls -l ${APACHE2BASEDIR}/conf.d/ | grep -v ^l | awk {'print $9'} | grep -v ^$); do
97 if ! [ ${CONF##*.} == "conf" ]; then
98 mv ${APACHE2BASEDIR}/conf.d/${CONF} ${APACHE2BASEDIR}/conf.d/${CONF}.conf
99 CONF="${CONF}.conf"
100 fi
101 mv ${APACHE2BASEDIR}/conf.d/${CONF} ${APACHE2BASEDIR}/conf-available/${CONF}
102 # enable this
103 CONF=$(basename ${CONF} .conf)
104 a2enconf ${CONF}
105done
106# migrate standard Options config to valid one
107sed -i "s/Options ExecCGI/Options +ExecCGI/" /etc/apache2/sites-available/*
108# fix probable Piped Logs
109sed -i 's/|exec /| /' /etc/apache2/sites-available/*
110# check for probably incompatible Apache configration statements (see https://gist.github.com/waja/86a3a055c1fedfba3c58#upstream-changes)
111rgrep -iE "(Order|Allow|Deny|Satisfy) " /etc/apache2/conf-enabled/* | grep -v ":#" && rgrep -iE "(Order|Allow|Deny|Satisfy) " /etc/apache2/sites-enabled/* | grep -v ":#"
112
113# serveral changes may be needed to adjust content of config files
114# see https://gist.github.com/waja/86a3a055c1fedfba3c58#file-apache2.0to2.4.md
115
116# migrate redmine plugins
117mv /usr/share/redmine/vendor/plugins/* /usr/share/redmine/plugins/ && rmdir /usr/share/redmine/vendor/plugins/
118# Remove inconsistent link in /usr/share/redmine/vendor/rails
119rm /usr/share/redmine/vendor/rails
120# migrate database config for mysql
121sed -i "s/adapter: mysql/adapter: mysql2/" /etc/redmine/default/database.yml
122
123# Fixing Typo bug in claav-daemon (http://bugs.debian.org/778507)
124sed -i "s/DEBCONFILE/DEBCONFFILE/" /var/lib/dpkg/info/clamav-daemon.postinst
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 | 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 | awk '{print $2}' | xargs aptitude -y purge
132dpkg -l | grep -E 'deb7|wheezy' | grep -v xen | grep -v linux-image | awk '{print $2}' | xargs aptitude -y purge
133aptitude -y install deborphan && deborphan | grep -v xen | grep -v libpam-cracklib | xargs aptitude -y purge
134dpkg -l | grep ^r | awk '{print $2}' | xargs aptitude -y purge
135
136# for the brave YoloOps crowd
137reboot && sleep 180; echo u > /proc/sysrq-trigger ; sleep 2 ; echo s > /proc/sysrq-trigger ; sleep 2 ; echo b > /proc/sysrq-trigger
138
139### not needed until now
140# mysql
141# remove anonymous mysql access
142#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;"
143
144# dont use iptables when creating xen vifs
145#cp /etc/xen/scripts/vif-bridge /etc/xen/scripts/vif-bridge-local
146#sed -i "s/^ handle_iptable/ true/g" /etc/xen/scripts/vif-bridge-local
147#sed -i "s/^(vif-script vif-bridge)/(vif-script vif-bridge-local)/" /etc/xen/xend-config.sxp
148
149# xen
150#/bin/sed -i -e 's/^[# ]*\((dom0-min-mem\).*\().*\)$/\1 512\2/' /etc/xen/xend-config.sxp
151#sed -i s/XENDOMAINS_RESTORE=true/XENDOMAINS_RESTORE=false/ /etc/default/xendomains
152#sed -i s#XENDOMAINS_SAVE=/var/lib/xen/save#XENDOMAINS_SAVE=\"\"# /etc/default/xendomains
153#dpkg-divert --divert /etc/grub.d/09_linux_xen --rename /etc/grub.d/20_linux_xen
154#echo 'GRUB_CMDLINE_XEN="dom0_mem=512M"' >> /etc/default/grub
155
156# migrate expose.ini
157#[ -f /etc/php5/conf.d/expose.ini ] && mv /etc/php5/conf.d/expose.ini \
158# /etc/php5/mods-available/local-expose.ini && php5enmod local-expose/90
159# migrate local suhosin config
160#find /etc/php5/conf.d/ -type f -name "*suhosin.ini" -exec mv '{}' \
161# /etc/php5/mods-available/local-suhosin.ini \; && php5enmod local-suhosin/90
162