[comp.sys.att] Run levels 5 & 6

ditto@cbmvax.UUCP (Michael "Ford" Ditto) (11/22/88)

In article <254@ssbn.WLK.COM> bill@ssbn.WLK.COM (Bill Kennedy) writes:
>An article I posted earlier asks if anyone knows how to make run levels
>5 or 6 work with AT&T 386 UNIX.

Here's what I did:  Append the following to /etc/rc0:

	set `who -r`
	[ $7 = 5 ] && /etc/uadmin 2 0
	[ $7 = 6 ] && /etc/uadmin 2 1

Now, "shutdown -i5" will halt the machine and "shutdown -i6" will reboot it;
in both cases all filesystems (including root) are unmounted and marked as
"clean" so that they won't be automatically fsck'd when the system comes up.

This was actually on an Amiga, not a 386, but I suspect that it would work
if the command codes to uadmin are the same.
-- 
					-=] Ford [=-

"The number of Unix installations	(In Real Life:  Mike Ditto)
has grown to 10, with more expected."	ford@kenobi.cts.com
- The Unix Programmer's Manual,		...!sdcsvax!crash!elgar!ford
  2nd Edition, June, 1972.		ditto@cbmvax.commodore.com

bill@ssbn.WLK.COM (Bill Kennedy) (11/28/88)

In article <5284@cbmvax.UUCP>, ditto@cbmvax.UUCP (Michael "Ford" Ditto) writes:
> In article <254@ssbn.WLK.COM> bill@ssbn.WLK.COM (Bill Kennedy) writes:
> >An article I posted earlier asks if anyone knows how to make run levels
> >5 or 6 work with AT&T 386 UNIX.

First thanks to Ford for suggesting someplace else to look.

> Here's what I did:  Append the following to /etc/rc0:
> 
> 	set `who -r`
> 	[ $7 = 5 ] && /etc/uadmin 2 0
> 	[ $7 = 6 ] && /etc/uadmin 2 1

I took some license and made that
set `who -r`
if [ $7 = 6 ]
then
	/etc/uadmin 2 1
else
	/etc/uadmin 2 0
fi

The original last line in /etc/rc0 was

/etc/uadmin 2 0

Which shuts down and halts.  It turns out that if you init 6 then /etc/rc0
never gets executed :-(

> Now, "shutdown -i5" will halt the machine and "shutdown -i6" will reboot it;
> in both cases all filesystems (including root) are unmounted and marked as
> "clean" so that they won't be automatically fsck'd when the system comes up.

But only if you get to /etc/rc0.  It appears that init is the culprit.

> This was actually on an Amiga, not a 386, but I suspect that it would work
> if the command codes to uadmin are the same.

I suspect they are, /usr/include/sys/uadmin.h says that the three commands
A_SHUTDOWN=2, A_REBOOT=1, A_REMOUNT=4 and the functions that go with them
AD_HALT=0, AD_BOOT=1, AD_IBOOT=2 with the difference between the first and
second boot being whether or not you use /unix or prompt for the system name.

> 					-=] Ford [=-

So I'm farther along but still not there.  It appears that I should leave
a clue file to execute.  In other words always init 0 in order to execute
/etc/rc0 and then look at the clue file to see whether I should reboot or
not.  That seems a bit bizarre but I never claimed to be elegant.  Does
anyone have any better suggestions?
-- 
Bill Kennedy  usenet      {killer,att,rutgers,sun!daver,uunet!bigtex}!ssbn!bill
              internet    bill@ssbn.WLK.COM

ditto@cbmvax.UUCP (Michael "Ford" Ditto) (11/28/88)

In article <263@ssbn.WLK.COM> bill@ssbn.WLK.COM (Bill Kennedy) writes:
>In article <5284@cbmvax.UUCP>, ditto@cbmvax.UUCP (Michael "Ford" Ditto) writes:
>> Here's what I did:  Append the following to /etc/rc0:
 [ ... ]
>> Now, "shutdown -i5" will halt the machine and "shutdown -i6" will reboot it;
 [ ... ]
>
>But only if you get to /etc/rc0.  It appears that init is the culprit.

Make sure /etc/inittab has something like:

	rc0:056:once:/etc/rc0 < /dev/console > /dev/console 2>&1

(The above line is off the top of my head; I'm not on a SysVr3 at the moment).

-- 
					-=] Ford [=-

"The number of Unix installations	(In Real Life:  Mike Ditto)
has grown to 10, with more expected."	ford@kenobi.cts.com
- The Unix Programmer's Manual,		...!sdcsvax!crash!elgar!ford
  2nd Edition, June, 1972.		ditto@cbmvax.commodore.com