6 ## Set global env variables
11 OS=$(uname -r | cut -c3-)
25 print -u2 "$me: Error: $1"
29 print -u2 "$me: Warning: $1"
37 display "$me: Info: $1"
41 if [ ! -z "$verbose" ]; then
47 if [ ! -z "$debug" ]; then
48 print -u2 "$me: Debug: $1"
53 display "$me [-v|verbose] [-d|debug] [-usage]"
54 display " -v|verbose: Turns on verbose mode"
55 display " -d|debug: Turns on debug mode"
56 display " -usage: Print this usage message"
58 display "The following options will be prompted for if not supplied on the"
59 display "command line. If any parameter has spaces in it then you need to"
60 display "surround it in quotes (e.g. -owners_fullname \"Andrew DeFaria\"."
61 display "You'll probably need to do this for the first 3 in the list below:"
63 display " -owners_fullname Specify owners full name"
64 display " -machine_usage Specify what this machine is to be used for"
65 display " -location Specify where this machine is located"
66 display " -owners_email Specify email address (no @cup.hp.com)"
67 display " -owners_extension Specify phone extenstion in the format of"
68 display " 7-XXXX (the t-44 will be prepended)"
69 display " -new_machine_name Specify the name of this system (REQUIRED)"
76 let step_nbr=step_nbr+1
77 display "Step #$step_nbr: $@"
80 function display_options {
81 display "Setup this machine according to the following profile:"
83 --------------------------------------------------------------------------------
85 display "Machine Name:\t\t$new_machine_name"
86 display "Machine Usage:\t\t$machine_usage"
87 display "Macine Location:\t$location"
88 display "Owner's Fullname:\t$owners_fullname"
89 display "Owner's Email:\t\t$owners_email"
90 display "Owner's Extension:\t$owners_extension"
93 # Set initial parm values
95 display "\t\tWelcome to the motd creation script"
106 if [ $(id -u) -ne 0 ]; then
107 error "Must be root to create or modify /etc/motd"
112 while [ $# -ge 1 ]; do
127 if [ $# -le 1 ]; then
128 usage "Owner's Full Name is not specified!"
135 if [ $# -le 1 ]; then
136 usage "Machine Usage was not specified!"
143 if [ $# -le 1 ]; then
144 usage "Location was not specified!"
151 if [ $# -le 1 ]; then
152 usage "Owner's Email was not specified!"
159 if [ $# -le 1 ]; then
160 usage "Owner's Extention was not specified!"
163 owners_extension="$1"
167 if [ $# -le 1 ]; then
168 usage "New Machine Name not specified!"
171 new_machine_name="$1"
175 usage "Unrecognized parameter $1"
181 # Prompt for options not specified on the command line
183 if [ "_$owners_fullname" = "_" ]; then
184 print "Owner's Fullname"
187 if [ "_$owners_fullname" = "_" ]; then
188 owners_fullname=Unknown
192 if [ "_$machine_usage" = "_" ]; then
193 print "What is this machine used for?"
196 if [ "_$machine_usage" = "_" ]; then
197 machine_usage="This machine is used by \<whom\> for \<what\>"
201 if [ "_$location" = "_" ]; then
202 print "Where is this machine located?"
205 if [ "_$location" = "_" ]; then
206 location="\<Physical Location\>"
210 if [ "_$owners_email" = "_" ]; then
211 print "Owner's Email address:"
212 print "(Should be the same as username. This script will supply the @cup.hp.com)"
215 if [ "_$owners_email" = "_" ]; then
220 if [ "_$owners_extension" = "_" ]; then
221 print "Owner's Phone extention:"
222 print "(Should be of the format 7-XXXX This script will prepend \"t-44\" to"
223 print "the entered extension)"
225 read owners_extension
226 if [ "_$owners_extension" = "_" ]; then
227 owners_extension=7-XXXX
231 until [ "_$new_machine_name" != "_" ]; do
232 new_machine_name="garbage"
233 print "New machine name:"
235 read new_machine_name
237 if [ "_$new_machine_name" = "_" ]; then
238 error "Must enter a new machine name"
245 display "Continue Installation (Y/n)?\c"
253 display "Installation aborted. Rerun $me if you wish to install again"
258 function do_installation {
261 banner $new_machine_name > /etc/motd
262 echo $unames $unamen $unamer $unamev $unamem $unamei $unamel >> /etc/motd
263 cat >> /etc/motd <<:END
265 *******************************************************************************
266 * This is a private system operated for the Hewlett-Packard Company business. *
267 * Authorization from HP management is required to use this system. *
268 * Use by unauthorized persons is prohibited. *
269 *******************************************************************************
270 For System Support: Mon-Fri 8:00-5:00 Email (site-ux@cup.hp.com)
271 Phone: t-447-1212 After hours/weekend Pre-arrange: t-447-0629
272 -------------------------------------------------------------------------------
273 Usage: $machine_usage
274 Owner: $owners_fullname ($owners_email@cup.hp.com) Phone:
275 t-44$owners_extension
277 -------------------------------------------------------------------------------
280 display "/etc/motd successfully created"
284 do_installation | tee $logfile