home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!rutgers!cmcl2!adm!news
- From: Perry_Hutchison.Portland@xerox.com
- Newsgroups: comp.unix.wizards
- Subject: Re: Making ``.plan'' EXECUTE a Program ???
- Message-ID: <31567@adm.brl.mil>
- Date: 28 Jul 92 22:54:18 GMT
- Sender: news@adm.brl.mil
- Lines: 78
-
- > Would be nice if user could have .startup file in $HOME that gets executed
- > after each reboot...
-
- The following works here on SunOS 4.1.1b. Your mileage may vary.
-
- 1. Create /etc/rc.users:
-
- #! /bin/csh
- #
- # Check everyone's home directory for a file named .boot.`hostname`,
- # and run it (under their user identity).
- #
- echo -n "" > /dev/console
- setenv TERM sun
- #
- # First, get a list of valid usernames
- # Assumptions:
- # 1. Fields in /etc/passwd may contain any character except the colon.
- # 2. The encrypted password of a valid username is exactly 13 characters long,
- # or null.
- # 3. A username whose UID is less than 10, or whose login shell is uucico,
- # is not valid.
- # 4. NIS should be consulted if it is running and the line "+::0:0:::" is
- # present in /etc/passwd.
- #
- egrep -v '^\+::0:0:::$|uucico$' /etc/passwd > /tmp/userlist
- chmod 644 /tmp/userlist
- if ( { egrep -s '^\+::0:0:::$' /etc/passwd } ) then
- # Try to get more names from NIS
- # status of 0 from ypwhich means yp service is available on this network
- if ( { ( ypwhich >>& /dev/null ) } ) then
- ypcat passwd | egrep -v '^\+::0:0:::$|uucico$' >> /tmp/userlist
- endif
- endif
- #
- ex /tmp/userlist <<E\OF
- g/^[^:][^:]*:[^:]:/d
- g/^[^:][^:]*:[^:][^:]:/d
- g/^[^:][^:]*:[^:][^:][^:]:/d
- g/^[^:][^:]*:[^:][^:][^:][^:]:/d
- g/^[^:][^:]*:[^:][^:][^:][^:][^:]:/d
- g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:]:/d
- g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:]:/d
- g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:]:/d
- g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
- g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
- g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
- g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
- g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]*:/d
- g/^[^:][^:]*:[^:]*:[^:]:/d
- g/:.*$/s///
- x
- E\OF
- #
- set host=`hostname`
- #
- foreach u ( `cat /tmp/userlist` )
- if ( -f ~$u/.boot.$host ) then
- su -f $u < ~$u/.boot.$host &
- endif
- end
-
- rm -f /tmp/userlist
- - - - - - - - - - -- - - - end of /etc/rc.users - - - - - - - - - - - - - -
- 2. Add to /etc/rc.local:
-
- if [ -f /etc/rc.users -a -x /etc/rc.users ]; then
- /etc/rc.users
- fi
- - - - - - - -- - - - end of addition to /etc/rc.local - - - - - - - - - - -
-
- I set this up last March. I think it took about half an hour to get it
- working. The translation to Bourne shell and/or Perl is left as an
- exercise for the reader.
-
- --
-
- Disclaimer: blame me, not Xerox.
-