http://paperlined.org/dev/src/pl/user-init/user-init.pl
#!/usr/bin/perl
# 'sysvinit' system, but for a specific user
#
# causes user daemons to be started after every system reboot
#
# called every 1-10 minutes from cron
my $last_init = '/home/interiot/src/pl/user-init/last_init';
my $rc_script = '/home/interiot/etc/init.d/rc';
# exit if we've run since the last reboot
if (-e $last_init) {
my $last_init_time = (stat $last_init)[9];
open FIN, "/proc/uptime" or die;
my ($uptime_seconds) = split(' ', <FIN>);
close FIN;
my $last_boot_time = int(time() - $uptime_seconds);
# ^^ may be off by one second at most (decimal seconds ignored,
# others), but this won't affect us, since cron never runs
# within the first seconds of kernel boot anyway
#print "Booted on ", scalar(localtime($last_boot_time)), "\n";
# exit if we've run since the last reboot
exit if ($last_init_time > $last_boot_time);
}
# we need to run the init scripts. record the time that we do this.
open FOUT, ">>$last_init" or die;
close FOUT;
exec $rc_script;
Generated by GNU enscript 1.6.4.