Handle hostnames with upper-case letters
[webmin.git] / setup.sh
index 99e4328..57b55dd 100755 (executable)
--- a/setup.sh
+++ b/setup.sh
@@ -77,10 +77,6 @@ fi
 
 # Validate source directory
 allmods=`cd "$srcdir"; echo */module.info | sed -e 's/\/module.info//g'`
-defaultallmods=`cd "$srcdir"; echo */module.info | xargs grep -L nondefault=1 2>/dev/null | sed -e 's/\/module.info//g'`
-if [ "$defaultallmods" = "" ]; then
-       defaultallmods="$allmods"
-fi
 if [ "$allmods" = "" ]; then
        echo "ERROR: Failed to get module list"
        echo ""
@@ -177,11 +173,12 @@ if [ "$upgrading" = 1 ]; then
        $perl "$wadir/newmods.pl" $config_dir $allmods
 
        # Update miniserv.conf with new root directory and mime types file
-       grep -v "^root=" $config_dir/miniserv.conf | grep -v "^mimetypes=" >$tempdir/$$.miniserv.conf
+       grep -v "^root=" $config_dir/miniserv.conf | grep -v "^mimetypes=" | grep -v "^server=" >$tempdir/$$.miniserv.conf
        if [ $? != "0" ]; then exit 1; fi
        mv $tempdir/$$.miniserv.conf $config_dir/miniserv.conf
        echo "root=$wadir" >> $config_dir/miniserv.conf
        echo "mimetypes=$wadir/mime.types" >> $config_dir/miniserv.conf
+       echo "server=MiniServ/$ver" >> $config_dir/miniserv.conf
        grep logout= $config_dir/miniserv.conf >/dev/null
        if [ $? != "0" ]; then
                echo "logout=$config_dir/logout-flag" >> $config_dir/miniserv.conf
@@ -456,7 +453,6 @@ else
                        echo "Webmin does not support being started at boot time on your system."
                fi
        fi
-       makeboot=$atboot
 
        # Copy files to target directory
        echo "***********************************************************************"
@@ -508,6 +504,8 @@ else
        if [ "$pam" != "" ]; then
                echo "pam=$pam" >> $cfile
        fi
+       echo premodules=WebminCore >> $cfile
+       echo "server=MiniServ/$ver" >> $cfile
 
        # Append package-specific info to config file
        if [ -r "$wadir/miniserv-conf" ]; then
@@ -563,9 +561,9 @@ EOF
        afile=$config_dir/webmin.acl
        rm -f $afile
        if [ "$defaultmods" = "" ]; then
-               echo $login: $defaultallmods >> $afile
+               echo "$login: $allmods" >> $afile
        else
-               echo $login: $defaultmods >> $afile
+               echo "$login: $defaultmods" >> $afile
        fi
        chmod 600 $afile
        echo "..done"
@@ -699,8 +697,21 @@ fi
 oldthemeline=`grep "^theme=" $config_dir/config`
 oldtheme=`echo $oldthemeline | sed -e 's/theme=//g'`
 if [ "$theme" != "" ] && [ "$oldthemeline" = "" ] && [ -d "$wadir/$theme" ]; then
-       echo "theme=$theme" >> $config_dir/config
-       echo "preroot=$theme" >> $config_dir/miniserv.conf
+       themelist=$theme
+fi
+
+# Set a special overlay if none was set before
+if [ "$overlay" = "" ]; then
+       overlay=`cat "$wadir/defaultoverlay" 2>/dev/null`
+fi
+if [ "$overlay" != "" ] && [ "$theme" != "" ] && [ -d "$wadir/$overlay" ]; then
+       themelist="$themelist $overlay"
+fi
+
+# Apply the theme and maybe overlay
+if [ "$themelist" != "" ]; then
+       echo "theme=$themelist" >> $config_dir/config
+       echo "preroot=$themelist" >> $config_dir/miniserv.conf
 fi
 
 # Set the product field in the global config
@@ -746,11 +757,13 @@ EOF
 fi
 
 echo "Changing ownership and permissions .."
+# Make all config dirs non-world-readable
 for m in $newmods; do
        chown -R root $config_dir/$m
        chgrp -R bin $config_dir/$m
        chmod -R og-rw $config_dir/$m
 done
+# Make miniserv config files non-world-readable
 for f in miniserv.conf miniserv.pem miniserv.users; do
        chown -R root $config_dir/$f
        chgrp -R bin $config_dir/$f
@@ -758,16 +771,27 @@ for f in miniserv.conf miniserv.pem miniserv.users; do
 done
 chmod +r $config_dir/version
 if [ "$nochown" = "" ]; then
+       # Make program directory non-world-writable, but executable
        chown -R root "$wadir"
        chgrp -R bin "$wadir"
        chmod -R og-w "$wadir"
        chmod -R a+rx "$wadir"
 fi
 if [ $var_dir != "/var" ]; then
+       # Make log directory non-world-readable or writable
        chown -R root $var_dir
        chgrp -R bin $var_dir
        chmod -R og-rwx $var_dir
 fi
+# Fix up bad permissions from some older installs
+for m in ldap-client ldap-server ldap-useradmin mailboxes mysql postgresql servers virtual-server; do
+       if [ -d "$config_dir/$m" ]; then
+               chown root $config_dir/$m
+               chgrp bin $config_dir/$m
+               chmod og-rw $config_dir/$m
+               chmod og-rw $config_dir/$m/config 2>/dev/null
+       fi
+done
 echo "..done"
 echo ""
 
@@ -785,6 +809,14 @@ if [ "$nopostinstall" = "" ]; then
        echo ""
 fi
 
+# Enable background collection
+if [ "$upgrading" != 1 -a -r $config_dir/system-status/enable-collection.pl ]; then
+       echo "Enabling background status collection .."
+       $config_dir/system-status/enable-collection.pl 5
+       echo "..done"
+       echo ""
+fi
+
 # Run package-defined post-install script
 if [ -r "$srcdir/setup-post.sh" ]; then
        . "$srcdir/setup-post.sh"