Use new options to locate.updatedb so we don't have to make the
authormillert <millert@openbsd.org>
Sat, 4 Jan 1997 01:36:52 +0000 (01:36 +0000)
committermillert <millert@openbsd.org>
Sat, 4 Jan 1997 01:36:52 +0000 (01:36 +0000)
database owned by non-root at any time.

etc/weekly

index bed9e30..17f9c72 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#      $OpenBSD: weekly,v 1.5 1997/01/03 23:33:50 millert Exp $
+#      $OpenBSD: weekly,v 1.6 1997/01/04 01:36:52 millert Exp $
 #
 
 PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/libexec
@@ -15,6 +15,7 @@ if [ -f /etc/weekly.local ];then
        . /etc/weekly.local
 fi
 
+
 #echo ""
 #echo "Removing old .o files:"
 #find /usr/src -name '*.o' -atime +21 -print -a -exec rm -f {} \;
@@ -57,11 +58,21 @@ echo ""
 
 echo ""
 if [ -f /var/db/locate.database ]; then
-       echo "Rebuilding locate database:"
-       chmod 644 /var/db/locate.database
-       chown bin /var/db/locate.database
-       echo /usr/libexec/locate.updatedb | nice -5 su -m bin 2>/dev/null
-       chown root.wheel /var/db/locate.database
+       TMP=`mktemp /var/db/locate.database.XXXXXX`
+       if [ $? -eq 0 ]; then
+               trap 'rm -f $TMP' 0 1 15
+               echo "Rebuilding locate database:"
+               echo "/usr/libexec/locate.updatedb --fcodes=-" | nice -5 su -m nobody 2>/dev/null 1>$TMP
+               if [ -s "$TMP" ]; then
+                       chmod 444 $TMP
+                       chown root.wheel $TMP
+                       mv -f $TMP /var/db/locate.database
+               else
+                       echo "Not installing locate database; zero size"
+               fi
+       else
+               echo "Not rebuilding locate database; can't create temp file"
+       fi
 else
        echo "Not rebuilding locate database; no /var/db/locate.database"
 fi