Remove unused actions. Use new version in motd.
[carnet-upgrade.git] / src / functions.sh
index 63557fe..ac21431 100644 (file)
@@ -304,7 +304,7 @@ upgrade () {
 
 # 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
+    [ -f /etc/apt/sources.list -a ! -f /etc/apt/sources.list.cn4-upgrade ] && mv /etc/apt/sources.list /etc/apt/sources.list.cn4-upgrade
     cp /usr/share/carnet-upgrade/files/etc/apt/sources.list /etc/apt
     notice "Novi sadrzaj datoteke /etc/apt/sources.list:
 
@@ -325,16 +325,18 @@ add_group_proc () {
   if ! getent group proc > /dev/null; then
     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 -a -f /etc/default/oidentd ];
+       check_and_sed 'OIDENT_GROUP.*proc' 's/\(OIDENT_GROUP\).*/\1=proc/' \
+            /etc/default/oident && /etc/init.d/oidentd restart
     fi
   fi
 }
 
 # backup_slapd_db
 backup_slapd_db () {
-  local ldap_backup=/var/backups/slapcat.cn3-upgrade
+  local ldap_backup=/var/backups/slapcat.cn4-upgrade
 
   if [ ! -f $ldap_backup ]; then
     [ -x /etc/init.d/freeradius ] && /etc/init.d/freeradius stop || true
@@ -357,7 +359,7 @@ backup_slapd_db () {
 
 # backup etc direktorija
 backup_etc_dir () {
-  local etc_backup=/var/backups/etc.cn3-upgrade.tar.gz
+  local etc_backup=/var/backups/etc.cn4-upgrade.tar.gz
 
   if [ ! -f $etc_backup ]; then
     if tar cfz $etc_backup /etc 2> /dev/null; then
@@ -373,15 +375,15 @@ backup_etc_dir () {
 # 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.cn4-upgrade.$$
+    chown --reference=/etc/default/raid2 /etc/default/raid2.cn4-upgrade.$$
+    chmod --reference=/etc/default/raid2 /etc/default/raid2.cn4-upgrade.$$
 
-    if ! cmp -s /etc/default/raid2.cn3-upgrade.$$ /etc/default/raid2; then
+    if ! cmp -s /etc/default/raid2.cn4-upgrade.$$ /etc/default/raid2; then
       log "Fixed /etc/default/raid2 AUTOSTART option."
-      mv /etc/default/raid2.cn3-upgrade.$$ /etc/default/raid2
+      mv /etc/default/raid2.cn4-upgrade.$$ /etc/default/raid2
     else
-      rm /etc/default/raid2.cn3-upgrade.$$
+      rm /etc/default/raid2.cn4-upgrade.$$
     fi
   fi
 }
@@ -391,7 +393,7 @@ restore_config () {
   local file file_backup
 
   for file in "$@"; do
-    file_backup=$file.cn3-upgrade
+    file_backup=$file.cn4-upgrade
     if [ -e $file -a ! -e $file_backup ]; then
       # backup file
       mv $file $file_backup
@@ -436,7 +438,7 @@ restore_configs () {
 
   # 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"
+      [ ! -e "$file.cn4-upgrade" ] && mv "$file" "$file.cn4-upgrade"
       rm -f "$file"
   done
 }
@@ -470,13 +472,8 @@ upgrade_apache () {
   #pkgadd apache2-cn php5-cn aosi-aai aosi-www-aai # squirrelmail-cn
 
   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_*
-
-  pkgadd aosi-aai aosi-www-aai # squirrelmail-cn
+  pkgadd apache2-cn php4-cn
+  pkgadd aosi-aai aosi-www-aai squirrelmail-cn
 }
 
 upgrade_amavis () {
@@ -488,15 +485,17 @@ upgrade_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.cn4-upgrade ]; then
+    mv $conf $conf.cn4-upgrade
   fi
 
   pkgadd amavisd-cn amavisd-new
 
   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
+
+  /etc/init.d/amavis restart
 }
 
 # fix openldap-aai postinst user handling
@@ -508,30 +507,6 @@ upgrade_openldap () {
   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
@@ -580,11 +555,11 @@ fix_aidexfer_conf() {
 
 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
 }
 
@@ -632,16 +607,16 @@ fix_smtp_auth() {
   fi
   if [ -f $conf -a -f $tmpl ] && \
     ! cmp -s $conf $tmpl; then
-    mv $conf $conf.cn3-upgrade
+    mv $conf $conf.cn4-upgrade
     mv_in_sasl=1
   fi
   if [ -f $confdir/Sendmail.conf ]; then
-    mv $confdir/Sendmail.conf $confdir/Sendmail.conf.cn3-upgrade
+    mv $confdir/Sendmail.conf $confdir/Sendmail.conf.cn4-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 -f $confdir/sasl.m4 $confdir/sasl.m4.cn4-upgrade
     mv_in_sasl=1
   fi
   [ "$mv_in_sasl" ] && \