home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / wizards / 3341 < prev    next >
Encoding:
Internet Message Format  |  1992-07-28  |  2.6 KB

  1. Path: sparky!uunet!stanford.edu!rutgers!cmcl2!adm!news
  2. From: Perry_Hutchison.Portland@xerox.com
  3. Newsgroups: comp.unix.wizards
  4. Subject: Re: Making ``.plan'' EXECUTE a Program ???
  5. Message-ID: <31567@adm.brl.mil>
  6. Date: 28 Jul 92 22:54:18 GMT
  7. Sender: news@adm.brl.mil
  8. Lines: 78
  9.  
  10. > Would be nice if user could have .startup file in $HOME that gets executed
  11. > after each reboot...
  12.  
  13. The following works here on SunOS 4.1.1b.  Your mileage may vary.
  14.  
  15. 1.  Create /etc/rc.users:
  16.  
  17. #!    /bin/csh
  18. #
  19. # Check everyone's home directory for a file named .boot.`hostname`,
  20. # and run it (under their user identity).
  21. #
  22. echo -n "" > /dev/console
  23. setenv TERM sun
  24. #
  25. # First, get a list of valid usernames
  26. # Assumptions:
  27. # 1.  Fields in /etc/passwd may contain any character except the colon.
  28. # 2.  The encrypted password of a valid username is exactly 13 characters long,
  29. #     or null.
  30. # 3.  A username whose UID is less than 10, or whose login shell is uucico,
  31. #     is not valid.
  32. # 4.  NIS should be consulted if it is running and the line "+::0:0:::" is
  33. #     present in /etc/passwd.
  34. #
  35. egrep -v '^\+::0:0:::$|uucico$' /etc/passwd > /tmp/userlist
  36. chmod 644 /tmp/userlist
  37. if ( { egrep -s '^\+::0:0:::$' /etc/passwd } ) then
  38.   # Try to get more names from NIS
  39.   # status of 0 from ypwhich means yp service is available on this network
  40.   if ( { ( ypwhich >>& /dev/null ) } ) then
  41.     ypcat passwd | egrep -v '^\+::0:0:::$|uucico$' >> /tmp/userlist
  42.   endif
  43. endif
  44. #
  45. ex /tmp/userlist <<E\OF
  46. g/^[^:][^:]*:[^:]:/d
  47. g/^[^:][^:]*:[^:][^:]:/d
  48. g/^[^:][^:]*:[^:][^:][^:]:/d
  49. g/^[^:][^:]*:[^:][^:][^:][^:]:/d
  50. g/^[^:][^:]*:[^:][^:][^:][^:][^:]:/d
  51. g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:]:/d
  52. g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:]:/d
  53. g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:]:/d
  54. g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
  55. g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
  56. g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
  57. g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]:/d
  58. g/^[^:][^:]*:[^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:][^:]*:/d
  59. g/^[^:][^:]*:[^:]*:[^:]:/d
  60. g/:.*$/s///
  61. x
  62. E\OF
  63. #
  64. set host=`hostname`
  65. #
  66. foreach u ( `cat /tmp/userlist` )
  67.   if ( -f ~$u/.boot.$host ) then
  68.     su -f $u < ~$u/.boot.$host &
  69.   endif
  70. end
  71.  
  72. rm -f /tmp/userlist
  73. - - - - - - - - - -- - - - end of /etc/rc.users - - - - - - - - - - - - - -
  74. 2.  Add to /etc/rc.local:
  75.  
  76. if [ -f /etc/rc.users -a -x /etc/rc.users ]; then
  77.     /etc/rc.users
  78. fi
  79. - - - - - - -- - - - end of addition to /etc/rc.local - - - - - - - - - - -
  80.  
  81. I set this up last March.  I think it took about half an hour to get it
  82. working.  The translation to Bourne shell and/or Perl is left as an
  83. exercise for the reader.
  84.  
  85. --
  86.  
  87. Disclaimer: blame me, not Xerox.
  88.