:: Re: [DNG] Mini init script written …
Góra strony
Delete this message
Reply to this message
Autor: Steve Litt
Data:  
Dla: dng
Temat: Re: [DNG] Mini init script written in Perl boots.
On Thu, 16 Jun 2016 22:01:32 +0200
Edward Bartolo <edbarx@???> wrote:

> Hi,
>
> The following simple Perl script successfully booted a useable
> XFCE4.10 session. Orderly shutdown was done through using "agetty tty1
> &", logging in as root in the tty1 terminal, and issuing the command:
> "/etc/init.d/rc 0".
>
> The Perl script is this. Please, note this is a very miniscule script
> that my require other statements. What I can say, is however, that it
> booted successfully without errors and loaded XFCE4.10 that was
> useable.
>
> The Perl script:
> ----------------------
>
> #!/usr/bin/perl -w
>
> if ($<) {
>     printf "Only root can run this program.\n";
>     exit 1;
> }

>
> # Now the fun begins!
>
> # Fork to generate a child process and to allow the parent to reap
> zombies my $status = 0;
> if (fork()) {
> # We are in the parent which must reap zombies.
>   while(1) {
>       $status = wait();
>     }    
> } else {
> # We are in the child which must load the operating system by
> executing a script

>
> exec("/sbin/osloader.sh");
> }


Add in the turning on and turning off of signals, and by Jove, I think
he's got it!

Bear in mind that Perl is different on every computer due to CPAN. But
as an educational thing, this is perfect. Make a
simple /sbin/osloader.sh and let us know whether you come up floating
rather than kernel panicking or looking at a blank screen.

SteveT

Steve Litt
June 2016 featured book: Troubleshooting: Why Bother?
http://www.troubleshooters.com/twb