Handle hostnames with upper-case letters
[webmin.git] / makerpm.pl
index a2c27d8..9c0352b 100755 (executable)
@@ -92,6 +92,7 @@ rm -f mount/openbsd-mounts*
 rm -f mount/macos-mounts*
 rm -f webmin-gentoo-init
 rm -rf format bsdexports hpuxexports sgiexports zones rbac
+rm -rf acl/Authen-SolarisRBAC-0.1*
 chmod -R og-w .
 
 %install
@@ -167,15 +168,26 @@ if [ "\$1" != 1 ]; then
        rm -rf /etc/.webmin-backup
        cp -r /etc/webmin /etc/.webmin-backup
 fi
+# Put back old /etc/webmin saved when an RPM was removed
+if [ "\$1" = 1 -a ! -d /etc/webmin -a -d /etc/webmin.rpmsave ]; then
+       mv /etc/webmin.rpmsave /etc/webmin
+fi
 /bin/true
 
 %post
 inetd=`grep "^inetd=" /etc/webmin/miniserv.conf 2>/dev/null | sed -e 's/inetd=//g'`
+startafter=0
 if [ "\$1" != 1 ]; then
        # Upgrading the RPM, so stop the old webmin properly
        if [ "\$inetd" != "1" ]; then
+               kill -0 `cat /var/webmin/miniserv.pid 2>/dev/null` 2>/dev/null
+               if [ "\$?" = 0 ]; then
+                 startafter=1
+               fi
                /etc/init.d/webmin stop >/dev/null 2>&1 </dev/null
        fi
+else
+  startafter=1
 fi
 cd /usr/libexec/webmin
 config_dir=/etc/webmin
@@ -206,9 +218,10 @@ if [ "\$tempdir" = "" ]; then
        tempdir=/tmp/.webmin
 fi
 export config_dir var_dir perl autoos port login crypt host ssl nochown autothird noperlpath nouninstall nostart allow atboot
-./setup.sh >$tempdir/webmin-setup.out 2>&1
+./setup.sh >\$tempdir/webmin-setup.out 2>&1
+chmod 600 \$tempdir/webmin-setup.out
 rm -f /var/lock/subsys/webmin
-if [ "$inetd" != "1" ]; then
+if [ "\$inetd" != "1" -a "\$startafter" = "1" ]; then
        /etc/init.d/webmin start >/dev/null 2>&1 </dev/null
 fi
 cat >/etc/webmin/uninstall.sh <<EOFF
@@ -263,8 +276,10 @@ if [ "\$1" = 0 ]; then
        grep root=/usr/libexec/webmin /etc/webmin/miniserv.conf >/dev/null 2>&1
        if [ "\$?" = 0 ]; then
                # RPM is being removed, and no new version of webmin
-               # has taken it's place. Delete the config files
-               rm -rf /etc/webmin /var/webmin
+               # has taken it's place. Rename away the /etc/webmin directory
+               rm -rf /etc/webmin.rpmsave
+               mv /etc/webmin /etc/webmin.rpmsave
+               rm -rf /var/webmin
        fi
 fi
 /bin/true
@@ -302,4 +317,9 @@ if (-d "rpm") {
                }
        }
 
+if (!$webmail && -d "/usr/local/webadmin/rpm/yum") {
+       # Add to our repository
+       system("cp rpm/webmin-$ver-$rel.noarch.rpm /usr/local/webadmin/rpm/yum");
+       }
+