Handle hostnames with upper-case letters
[webmin.git] / makerpm.pl
index f4b9401..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,14 +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
@@ -205,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
@@ -241,6 +255,7 @@ else
        echo "Webmin install complete. You can now login to http://\$host:\$port/"
 fi
 echo "as root with your root password."
+/bin/true
 
 %preun
 if [ "\$1" = 0 ]; then
@@ -252,19 +267,22 @@ if [ "\$1" = 0 ]; then
                (cd /usr/libexec/webmin ; WEBMIN_CONFIG=/etc/webmin WEBMIN_VAR=/var/webmin LANG= /usr/libexec/webmin/run-uninstalls.pl)
                /etc/init.d/webmin stop >/dev/null 2>&1 </dev/null
                /etc/webmin/stop >/dev/null 2>&1 </dev/null
-               /bin/true
        fi
 fi
+/bin/true
 
 %postun
 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
 
 %triggerpostun -- webmin
 if [ ! -d /var/webmin -a "\$1" = 2 ]; then
@@ -281,6 +299,7 @@ if [ ! -r /etc/webmin/miniserv.conf -a -d /etc/.webmin-backup -a "\$1" = 2 ]; th
 else
        rm -rf /etc/.webmin-backup
 fi
+/bin/true
 
 EOF
 close(SPEC);
@@ -298,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");
+       }
+