]>
git.proxmox.com Git - dab.git/blob - scripts/init.pl
4 use POSIX qw
(:sys_wait_h strftime
);
9 1 while waitpid(-1, WNOHANG
) > 0;
12 print "stopping init\n";
20 my $logfile = "/var/log/init.log";
23 open (STDOUT
, ">>$logfile");
25 open STDERR
, ">&STDOUT";
27 select STDERR
; $| = 1; # make unbuffered
28 select STDOUT
; $| = 1; # make unbuffered
30 my $args = join (" ", @ARGV);
35 if (defined ($l) && $l eq '0') {
36 print "initctl $args\n";
39 print "initctl $args (ignored)\n";
45 print "starting init $args\n";
47 # only start once when pid == 1
48 # ignore runlevel change requests
51 if (! -d
"/proc/$$") {
52 system ("mount -t proc proc /proc") == 0 ||
53 die "unable to mount proc filesystem\n";
56 system ("hostname localhost") == 0 ||
57 die "unable to set hostname\n";
60 # start one child doing nothing - to avoid that we get killed
67 # provide simple syslog
69 my $sock = IO
::Socket
::UNIX-
>new (Local
=> "/dev/log", Listen
=> 5) ||
70 die "can't open socket /dev/log - $!\n";
72 while ((my $fd = $sock->accept()) ||($! == EINTR
)) {
76 while (defined (my $line = <$fd>)) {
79 $line =~ s/^<\d+>//mg;
80 next if $line =~ m/^\s*$/;
87 print "exit init: $!\n";