#!/usr/bin/perl #This script adds SystemStartup functionality for OS X #CASE COUNTS!!!!!!! # Script by Chris Roberts #No warranty of any kind and all liability is expressly denied # use at your own risk #this script is FREE TO All to use/modify as long as this notice remains. #$Id: postflight,v 1.1 2003/06/01 18:05:43 chris Exp $ #where is the hostconfig script $SCRIPT='/etc/hostconfig'; #-----inforamtion on the new service---------- #specify NEW SERVICE NAME HERE $NEWSERVICE='myservicename'; #Specify the default State of the new Service YES = on NO =OFF $NEWSERVICESTATE="YES"; #-------Information on OLD services to work with------ #specify a service to disable/remove (OPTIONAL) $OLDSERVICE=''; #OLD service state NO = OFF YES = ON REMOVE = delete from hostconfig $OLDSERVICESTATE=''; #-------Now we do our work no configuration below this line ------- #open the SCRIPT and read it into memory open(INPUT, "$SCRIPT")||print "cant open for read"; @FILE=; close (INPUT); #now iterate over the file and find old service if defined #and do the changes requested if($OLDSERVICE){ foreach $LINE (@FILE){ if($LINE=~ /$OLDSERVICE/){ if($OLDSERVICESTATE eq "NO"){ $LINE=~ s/YES/NO/; } if($OLDSERVICESTATE eq "YES"){ $LINE=~ s/NO/YES/; } if($OLDSERVICESTATE eq "REMOVE"){ $LINE=""; } } } } #now iterate over the file and find if the new service is already defined #replace or insert as needed foreach $LINE (@FILE){ #a replace was required if($LINE=~ /$NEWSERVICE/){ $LINE="$NEWSERVICE=-$NEWSERVICESTATE-\n"; $EXISTS=1; } } #open the file for write open(OUTPUT, ">$SCRIPT")||print "cant open $SCRIPT for write"; foreach $LINE (@FILE){ print OUTPUT $LINE; } #an insert was required if($EXISTS ne "1"){ print OUTPUT "$NEWSERVICE=-$NEWSERVICESTATE-\n"; } close (OUTPUT); #aditional preflight commands follow-------- #examples #system('/usr/sbin/chown -R nobody.nobody /usr/local/squid/var'); #system('/usr/local/squid/sbin/squid -z'); exit(0)