#!@PERL@
+#
+# cnid_maint: A script to maintain the consistency of CNID databases.
+#
+# $Id: cnid_maint.in,v 1.5 2002-02-09 20:29:40 jmarcus Exp $
+#
+
use strict;
use Getopt::Std;
use vars qw(
# Below is the example of a BSD ps. A SYSV example is:
# /bin/ps -eflouid,pid,ppid,comm
$PS_CMD = '@PS@ -axouser,pid,ppid,command';
-$GREP = '@GREP@';
-$DB_STAT = '@DB3_PATH@db3_stat';
-$DB_RECOVER = '@DB3_PATH@bin/db3_recover';
-$DB_VERIFY = '@DB3_PATH@db3_verify';
+$DB_STAT = '@DB3_PATH@bin/db_stat';
+$DB_RECOVER = '@DB3_PATH@bin/db_recover';
+$DB_VERIFY = '@DB3_PATH@bin/db_verify';
$APPLE_VOLUMES_FILE = '@PKGCONFDIR@/AppleVolumes.default';
## End edit section
$VERSION = '1.0';
+$GREP = '@GREP@';
$START_NETATALK = 0;
-$LOCK_FILE = '/tmp/cnid_maint.LOCK';
+$LOCK_FILE = tmpdir() . '/cnid_maint.LOCK';
$HOLDING_LOCK = 0;
sub LOCK_SH { 1 }
unless ( open( LOCK, ">" . $LOCK_FILE ) ) {
error( 2, "Unable to create $LOCK_FILE: $!" );
-}
+}
flock( LOCK, LOCK_EX );
$HOLDING_LOCK = 1;
end();
+sub tmpdir {
+ my $tmpdir;
+
+ foreach ( $ENV{TMPDIR}, "/tmp" ) {
+ next unless defined && -d && -w _;
+ $tmpdir = $_;
+ last;
+ }
+ $tmpdir = '' unless defined $tmpdir;
+ return $tmpdir;
+}
+
sub error {
my ( $code, $msg ) = @_;