Fix distribution name in dialog message.
[carnet-upgrade.git] / src / functions.sh
index a8c9b4e..428a369 100644 (file)
@@ -22,10 +22,17 @@ pkg() {
 }
 
 log() {
+  local old_umask
   logfile=${logfile:=/var/log/carnet-upgrade.log}
-  touch $logfile
+
+  old_umask=$(umask)
+  umask 0077
+
   echo "$(date +'%Y-%m-%d %H:%M:%S') $*" >> $logfile
   echo "CN: $*"
+
+  umask $old_umask
+  chmod og= $logfile
 }
 
 # find first free uid/gid in range
@@ -440,19 +447,19 @@ check_my_version () {
   rm -f $packages
 }
 
-# if apache is installed make sure it's version 2
-check_apache_version () {
+# if php is installed make sure it's version 5
+check_php_version () {
 
-  if pkg apache-cn && ! pkg apache2-cn; then
+  if pkg php4-cn && ! pkg php5-cn; then
     notice "
-Prije prelaska na Debian Etch potrebno je napraviti nadogradnju sa Apache 1.3 na Apache 2.0.
+Prije prelaska na Debian Lenny potrebno je napraviti nadogradnju sa PHP 4 na PHP 5.
 
 Pokrenite:
   # apt-get update
-  # apt-get install apache2-cn
+  # apt-get install php5-cn
   
-Nakon toga ponovno pozovite ovu skriptu."
-    log "carnet-upgrade aborted, upgrade to apache2-cn needed."
+Nakon sto provjerite da sve web aplikacije rade ispravno, ponovno pozovite ovu skriptu."
+    log "carnet-upgrade aborted, upgrade to php5-cn needed."
     exit 1
   fi
 }
@@ -779,6 +786,7 @@ restore_configs () {
   restore_config spamassassin-cn razor 1:2.85-1 /etc/razor/razor-agent.conf
   restore_config kernel-2.6-cn libpam-modules 1.0.1-5 /etc/security/limits.conf
   restore_config samba-cn samba-common 2:3.2.5-4lenny2 /etc/samba/smb.conf
+  restore_config '' base-files 5lenny2 /etc/issue /etc/issue.net
 
   # check if monitrc is template based
   if [ -f /etc/monit/monitrc -a ! -f /etc/monit/monitrc.$backup_ext ]; then
@@ -803,8 +811,6 @@ restore_configs () {
      rm -f $config_new
   fi
 
-#  restore_config base-files 4 /etc/issue /etc/issue.net
-#  restore_config base-files 4 /etc/issue /etc/issue.net
 #  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 \
@@ -892,6 +898,12 @@ remove_skey () {
   fi
 }
 
+# remove unsupported php version
+remove_php4 () {
+  # leave the configuration just in case
+  pkgrm_only php4-common
+}
+
 # check if package is orphaned (nothing depends on it)
 is_orphaned () {
   local package deps
@@ -934,7 +946,7 @@ disable_monit () {
 
 # make a silent upgrade to new libc6
 upgrade_libc () {
-  DEBIAN_FRONTEND=noninteractive pkgadd libc6
+  DEBIAN_FRONTEND=noninteractive pkgadd libc6 tzdata
 }
 
 # upgrade apache2 to etch
@@ -1188,7 +1200,7 @@ upgrade_udev () {
                 /etc/udev/rules.d/compat.rules
   do
      if [ -e $config ]; then
-        mv -v $config /etc/udev/
+        rm -v -f $config
      fi
   done
 
@@ -1213,6 +1225,7 @@ comment_force_overwrite () {
 fix_issue () {
   cat > /etc/issue <<EOF
 Debian GNU/Linux 5.0 (CARNet Debian 5.0) \\n \\l
+
 EOF
 
   cat > /etc/issue.net <<EOF