# funkcija utrpa ispravan sources.list
create_sources_list () {
- [ -f /etc/apt/sources.list -a ! -f /etc/apt/sources.list.cn3-upgrade ] && mv /etc/apt/sources.list /etc/apt/sources.list.cn3-upgrade
- cp /usr/share/carnet-upgrade/files/etc/apt/sources.list /etc/apt
- notice "Novi sadrzaj datoteke /etc/apt/sources.list:
+ local sl sl_new
+ sl=/etc/apt/sources.list
+ sl_new=/usr/share/carnet-upgrade/files/etc/apt/sources.list
+
+ # check if already installed
+ if ! cmp $sl $sl_new >/dev/null; then
+
+ # backup old version
+ if [ -f $sl -a ! -f $sl.$backup_ext ]; then
+ cp $sl $sl.$backup_ext
+ fi
+
+ # install new version
+ cp $sl_new $sl
+ notice "Novi sadrzaj datoteke /etc/apt/sources.list:
`cat /etc/apt/sources.list`"
+ fi
}
add_group_proc () {
if ! getent group proc > /dev/null; then
+ # grsec uses gid 99 for /proc files
groupadd -g 99 proc
log "groupadd -g 99 proc"
- if [ -x /etc/init.d/oidentd -a -f /etc/default/oidentd ] && \
- egrep -q 'OIDENT_GROUP.*proc' /etc/default/oidentd; then
- /etc/init.d/oidentd restart || true
+
+ # update oidentd so it uses the proc group
+ if [ -x /etc/init.d/oidentd ]; then
+ if gpasswd -a oident proc; then
+ /etc/init.d/oidentd restart
+ fi
fi
fi
}
# backup_slapd_db
backup_slapd_db () {
- local ldap_backup=/var/backups/slapcat.cn3-upgrade
+ local ldap_backup=/var/backups/slapcat.$backup_ext
if [ ! -f $ldap_backup ]; then
[ -x /etc/init.d/freeradius ] && /etc/init.d/freeradius stop || true
# backup etc direktorija
backup_etc_dir () {
- local etc_backup=/var/backups/etc.cn3-upgrade.tar.gz
+ local etc_backup=/var/backups/etc.$backup_ext.tar.gz
if [ ! -f $etc_backup ]; then
if tar cfz $etc_backup /etc 2> /dev/null; then
# fixaj /etc/default/raid2
fix_etc_default_raid2 () {
if [ -f /etc/default/raid2 ]; then
- sed "s/^AUTOSTART.*/AUTOSTART=true/g" /etc/default/raid2 > /etc/default/raid2.cn3-upgrade.$$
- chown --reference=/etc/default/raid2 /etc/default/raid2.cn3-upgrade.$$
- chmod --reference=/etc/default/raid2 /etc/default/raid2.cn3-upgrade.$$
+ sed "s/^AUTOSTART.*/AUTOSTART=true/g" /etc/default/raid2 > /etc/default/raid2.$backup_ext.$$
+ chown --reference=/etc/default/raid2 /etc/default/raid2.$backup_ext.$$
+ chmod --reference=/etc/default/raid2 /etc/default/raid2.$backup_ext.$$
- if ! cmp -s /etc/default/raid2.cn3-upgrade.$$ /etc/default/raid2; then
+ if ! cmp -s /etc/default/raid2.$backup_ext.$$ /etc/default/raid2; then
log "Fixed /etc/default/raid2 AUTOSTART option."
- mv /etc/default/raid2.cn3-upgrade.$$ /etc/default/raid2
+ mv /etc/default/raid2.$backup_ext.$$ /etc/default/raid2
else
- rm /etc/default/raid2.cn3-upgrade.$$
+ rm /etc/default/raid2.$backup_ext.$$
fi
fi
}
-# restore distribution config file
+# restore original config file (if the new package version is not
+# installed already)
restore_config () {
- local file file_backup
+ local file file_backup file_orig
+ local pkg=$1 ver=$2
+ shift 2
+
+ # check package version
+ pkg $pkg lt $ver || return 0
+
+ # restore package files
+ for file in $*; do
+ file_orig=/usr/share/carnet-upgrade/files/$file
+ file_backup=$file.$backup_ext
+
+ if cmp $file_orig $file >/dev/null; then
+ continue # original file is already in place
+ fi
- for file in "$@"; do
- file_backup=$file.cn3-upgrade
if [ -e $file -a ! -e $file_backup ]; then
# backup file
mv $file $file_backup
# install original
log Restoring config file $file
- cp /usr/share/carnet-upgrade/files/$file $file
+ cp $file_orig $file
fi
done
}
# restore modified config to their package defaults
# so the upgrade doesn't complain so much
restore_configs () {
- restore_config /etc/bind/named.conf.options
- restore_config /etc/default/ntpdate
- restore_config /etc/default/oidentd
- restore_config /etc/default/postgrey
- restore_config /etc/default/saslauthd
- restore_config /etc/default/slapd
- restore_config /etc/dovecot/dovecot.conf
- restore_config /etc/init.d/mysql
- restore_config /etc/init.d/slapd
- restore_config /etc/issue
- restore_config /etc/issue.net
- restore_config /etc/logrotate.d/mysql-server
- restore_config /etc/mysql/my.cnf
- restore_config /etc/ntp.conf
- restore_config /etc/pam.d/login
- restore_config /etc/php4/apache/php.ini
- restore_config /etc/php4/cgi/php.ini
- restore_config /etc/php4/cli/php.ini
- restore_config /etc/postgrey/whitelist_clients
- restore_config /etc/security/limits.conf
- restore_config /etc/squirrelmail/apache.conf
- restore_config /etc/sysctl.conf
- restore_config /etc/vsftpd.conf
- restore_config /etc/xinetd.conf
+ restore_config base-files 4 /etc/issue /etc/issue.net
+ restore_config bind9 1:9.3.4 /etc/bind/named.conf.options
+ restore_config dovecot-common 1.0 /etc/dovecot/dovecot.conf
+ restore_config libapache-mod-php4 6:4.4.4 /etc/php4/apache/php.ini
+ restore_config libpam-modules 0.79 /etc/security/limits.conf
+ restore_config login 1:4.0.18.1 /etc/pam.d/login
+ restore_config mysql-server 5.0.3 /etc/init.d/mysql \
+ /etc/logrotate.d/mysql-server \
+ /etc/mysql/my.cnf
+ restore_config ntp 1:4.2.2 /etc/ntp.conf
+ restore_config ntpdate 1:4.2.2 /etc/default/ntpdate
+ restore_config oidentd 2.0.8 /etc/default/oidentd
+ restore_config php4-cgi 6:4.4.4 /etc/php4/cgi/php.ini
+ restore_config php4-cli 6:4.4.4 /etc/php4/cli/php.ini
+ restore_config postgrey 1.27 /etc/default/postgrey \
+ /etc/postgrey/whitelist_clients
+ restore_config procps 1:3.2.7 /etc/sysctl.conf
+ restore_config sasl2-bin 2.1.22 /etc/default/saslauthd
+ restore_config slapd 2.3.30 /etc/default/slapd /etc/init.d/slapd
+ restore_config squirrelmail 2:1.4.9a /etc/squirrelmail/apache.conf
+ restore_config vsftpd 2.0.5 /etc/vsftpd.conf
+ restore_config xinetd 1:2.3.14 /etc/xinetd.conf
# orphaned config file - no owner
- rm -f /etc/logcheck/ignore.d.server/imap
+ if pkg logcheck-database lt 1.2.54; then
+ rm -f /etc/logcheck/ignore.d.server/imap
+ fi
# aide switched to ucf, move old configs aside
- for file in /etc/aide/aide.conf /etc/cron.daily/aide /etc/default/aide; do
- [ ! -e "$file.cn3-upgrade" ] && mv "$file" "$file.cn3-upgrade"
- rm -f "$file"
+ if pkg aide lt 0.13.1; then
+ for file in /etc/aide/aide.conf \
+ /etc/cron.daily/aide \
+ /etc/default/aide;
+ do
+ if [ ! -e "$file.$backup_ext" ]; then
+ mv "$file" "$file.$backup_ext"
+ fi
+
+ rm -f "$file"
+ done
+ fi
+}
+
+# temporary disable listchanges packages to reduce clutter during upgrade
+apt_listchanges () {
+ local file command=$1
+
+ for file in /etc/apt/apt.conf.d/20listchanges \
+ /etc/apt/apt.conf.d/20listchanges-cn
+ do
+ case $command in
+ disable)
+ if [ -f $file ]; then
+ dpkg-divert --local --rename --divert $file.$backup_ext \
+ --add $file || true
+ fi
+ ;;
+
+ enable)
+ if [ -f $file.$backup_ext ]; then
+ dpkg-divert --remove $file || true
+ fi
+ ;;
+ esac
done
}
update
}
+# remove skey (not supported anymore)
+remove_skey () {
+ pkgrm skey-cn libpam-skey
+
+ if getent group skey > /dev/null; then
+ groupdel skey || true
+ log "groupdel skey"
+ fi
+}
+
# make a silent upgrade to new libc6
upgrade_libc () {
DEBIAN_FRONTEND=noninteractive pkgadd libc6
# upgrade apache -> apache2
upgrade_apache () {
+
# bugfix for apache2-cn postinst
mkdir -p /etc/apache2
touch /etc/apache2/httpd.conf
- pkgadd php4-odbc php4-xslt
+ # register cn changes in modules.conf
+ modules_conf=/etc/apache/modules.conf
+ if [ ! -e "$modules_conf.$backup_ext" ]; then
+ cp "$modules_conf" "$modules_conf.$backup_ext"
+ ucf $modules_conf $modules_conf
+ fi
- # apache2 conflicts with these
- pkgrm apache aosi-aai aosi-www-aai php4-cn squirrelmail-cn
+ # temporary remove packages conflicting with apache2
+ delpkg=""
+ for p in aosi-aai aosi-www-aai \
+ php4-cn php4-odbc php4-xslt \
+ squirrelmail-cn; do
- # apache2-cn postinst needs new mktemp
- #pkgadd apache2-cn php5-cn aosi-aai aosi-www-aai # squirrelmail-cn
+ # remember installed packages
+ if pkg $p; then
+ delpkg="$delpkg $p"
+ fi
+ done
- pkgadd apache2 apache2-mpm-prefork libapache2-mod-php4 ssl-cert
- apt-get install -y -d apache2-cn php4-cn
- apt-get autoclean
- dpkg -i --ignore-depends=apache2-cn \
- /var/cache/apt/archives/apache2-cn_* \
- /var/cache/apt/archives/php4-cn_*
+ # remove problematic stuff
+ if [ "$delpkg" ]; then
+ eval apt-get --yes remove $delpkg
+ fi
- pkgadd aosi-aai aosi-www-aai # squirrelmail-cn
+ # remove old apache
+ pkgrm apache apache-common
+
+ # install new packages
+ eval pkgadd apache2-cn apache2-mpm-prefork \
+ php4-cn libapache2-mod-php4 \
+ $delpkg
}
upgrade_amavis () {
- # remove diversion
+ # remove init script diversion
if [ -L /etc/init.d/amavis -a -f /etc/init.d/amavis.amavisd-new ]; then
rm -f /etc/init.d/amavis
dpkg-divert --quiet --remove /etc/init.d/amavis
# move old config aside
local conf=/etc/amavis/amavisd.conf
- if [ -e $conf -a ! -e $conf.cn3-upgrade ]; then
- mv $conf $conf.cn3-upgrade
+ if [ -e $conf -a ! -e $conf.$backup_ext ]; then
+ mv $conf $conf.$backup_ext
fi
+ # install new packages
pkgadd amavisd-cn amavisd-new
+ # fix new packages
check_and_sed '^clamd.*5.clamav.log$' \
's/^\(clamd.*\)5.clamav.log$/\14\tsocket/g' \
- /etc/inet.d/amavisd-cn || true
+ /etc/init.d/amavisd-cn || true
+
+ # start new packages
+ /etc/init.d/amavis restart
}
# fix openldap-aai postinst user handling
dpkg --configure -a # try postinst again
}
-# workaround postfix-cn dependencies
-upgrade_postfix () {
- pkgadd sasl2-bin
- pkgadd postfix postfix-cn
-}
-
-# workaround dovecot-cn dependencies
-upgrade_dovecot () {
- pkgadd dovecot-imapd dovecot-pop3d
- pkgadd dovecot-cn
-}
-
-# workaround ntp-cn dependencies
-upgrade_ntp () {
- pkgadd ntp ntpdate
- # pkgrm ntp-server
- pkgadd ntp-cn
-}
-
-# instaliraj zadnji freeradius; uvjeti u queue fileovima
-install_freeradius () {
- pkgadd --force-yes freeradius-cn freeradius=1.0.5-0 freeradius-ldap=1.0.5-0
-}
-
-# tentatively remove obsolete option in xinetd.conf
-fix_xinetd_conf () {
- if [ -f /etc/xinetd.conf ]; then
- check_and_sed 'log_on_failure.*RECORD' \
- 's/\(log_on_failure.*\)RECORD/\1/g' \
- /etc/xinetd.conf || true
- fi
-}
-
-# temporarily disable mod_ssl.conf in apache so that upgrade works
-fix_mod_ssl_include() {
- if [ -f /etc/apache/mod_ssl.conf ]; then
- check_and_sed '^Include /etc/apache/mod_ssl\.conf' \
- 's,\(^Include[ ][ ]*/etc/apache/mod_ssl\.conf\),#\1,' \
- /etc/apache/httpd.conf || true
- fi
-}
-
-fix_proftpd_conf() {
- if [ -f /etc/proftpd.conf ]; then
- check_and_sed '^LsDefaultOptions' \
- 's,^LsDefaultOptions,ListOptions,' \
- /etc/proftpd.conf || true
- fi
- [ -x /etc/init.d/proftpd ] && /etc/init.d/proftpd restart || true
-}
-
# fix /etc/dpkg/dpkg.cfg
comment_force_overwrite () {
if [ -f /etc/dpkg/dpkg.cfg ]; then
fi
}
-fix_aidexfer_conf() {
- if [ -f /etc/aide/aidexfer.conf ]; then
- check_and_sed '/usr/local/lib/aidexfer' \
- 's,/usr/local/lib/aidexfer,/usr/share/aidexfer,' \
- /etc/aide/aidexfer.conf || true
- fi
-}
-
fix_issue () {
cat > /etc/issue <<EOF
-Debian GNU/Linux 4.0 (CARNet Debian 3.0) \\n \\l
+Debian GNU/Linux 4.0 (CARNet Debian 4.0) \\n \\l
EOF
cat > /etc/issue.net <<EOF
-Debian GNU/Linux 4.0 (CARNet Debian 3.0) %h
+Debian GNU/Linux 4.0 (CARNet Debian 4.0) %h
EOF
}
exit 1
fi
}
-
-fix_webalizer_conf () {
- if [ -f /etc/webalizer.conf ]; then
- check_and_sed '^/' \
- 's,^/,#,' \
- /etc/webalizer.conf || true
- fi
-}
-
-# like in sendmail-cn
-fix_smtp_auth() {
- local tmpl conf tmpldir confdir mv_in_sasl
-
- # all of these should be installed after dist-upgrade
- # if we had SMTP AUTH previously
- if pkg sasl2-bin && pkg sasl-bin && pkg sendmail-cn ge 2:8.13.1-2; then
- :
- else
- return 0
- fi
-
- tmpldir=/usr/share/sendmail/examples/sasl
- tmpl=$tmpldir/Sendmail.conf.2
- confdir=/etc/mail/sasl
- conf=$confdir/Sendmail.conf.2
- if [ "$(sasldblistusers | wc -l)" -gt 0 ]; then
- if [ "$(sasldblistusers2 | wc -l)" -eq 0 ]; then
- echo | sasldbconverter2 /etc/sasldb
- log "Converted /etc/sasldb to /etc/sasldb2."
- else
- log "Found users in both /etc/sasldb and /etc/sasldb2, doing nothing!"
- fi
- fi
- if [ -f $conf -a -f $tmpl ] && \
- ! cmp -s $conf $tmpl; then
- mv $conf $conf.cn3-upgrade
- mv_in_sasl=1
- fi
- if [ -f $confdir/Sendmail.conf ]; then
- mv $confdir/Sendmail.conf $confdir/Sendmail.conf.cn3-upgrade
- mv_in_sasl=1
- fi
- if [ -f $confdir/sasl.m4 ] && \
- ! cmp -s $confdir/sasl.m4 $tmpldir/sasl.m4; then
- mv -f $confdir/sasl.m4 $confdir/sasl.m4.cn3-upgrade
- mv_in_sasl=1
- fi
- [ "$mv_in_sasl" ] && \
- log "Renamed old files in $confdir."
-
- # Regenerate sasl.m4 and friends.
- /usr/share/sendmail/update_auth | egrep '^(Created template)' || true
-
- # Hope noone else uses this file. (see doc/sendmail/README.Debian.gz)
- dpkg-statoverride --remove /etc/sasldb2
- dpkg-statoverride --update --add smmta smmsp 660 /etc/sasldb2
- # needed for PLAIN, LOGIN
- dpkg-statoverride --remove /var/run/saslauthd
- dpkg-statoverride --update --add root sasl 711 /var/run/saslauthd
-
- # Enable saslauthd, used by default Debian config
- if ! egrep -q '^START=yes' /etc/default/saslauthd; then
- check_and_sed START 's/#\ +START=yes$/START=yes/' /etc/default/saslauthd
- /etc/init.d/saslauthd restart
- fi
-
- /etc/init.d/sendmail reload || true
-}
-
-sources_list() {
- if [ ! -e /var/lib/carnet-upgrade/stamp-sources_list ]; then
- install-carnet-sources.list
- apt-get -y update
- touch /var/lib/carnet-upgrade/stamp-sources_list
- fi
-}