2 ################################################################################
4 # File: configure_machine
5 # Description: A script to set up the "admin" environment
6 # Author: Andrew@DeFaria.com
7 # Created: Tue Apr 15 14:20:02 PDT 1997
11 # (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved
13 ################################################################################
17 adm_base=${adm_base:-$HOME/adm}
19 if [ ! -d /adm ]; then
20 if [ ! -d "$adm_base" ]; then
21 print -u2 "$me: Error: Unable to find \"adm\" path! - Exiting"
27 adm_fpath=${adm_fpath:-$adm_base/functions}
32 # Source in tmpfiles function
33 tmpprefix=${TMPDIR:-/tmp}/configure_machine.$$
42 info "$ME [-v|verbose] [-d|debug] [-usage]"
43 info " -v|verbose: Turns on verbose mode"
44 info " -d|debug: Turns on debug mode"
45 info " -f|ix: Turns on fix mode"
46 info " -c|heck: Turns on check mode (default)"
47 info " -usage: Print this usage message\n"
57 if [ ! -h "$from" ]; then
58 if [ $mode = "fix" ]; then
59 verbose "Setting up symlink from $from -> $to"
62 warning "$from link is not setup properly" 0
65 verbose "$from link is OK"
71 function setup_symlinks {
72 debug "ENTER setup_symlinks"
77 print $symlinks | while read from to; do
81 debug "EXIT setup_symlinks"
84 function check_and_replace_file {
85 debug "ENTER check_and_replace_file"
91 if ! cmp -s $master_file $check_file; then
92 if [ $mode = "fix" ]; then
93 verbose "Fixing $check_file"
94 cp $master_file $check_file
95 chmod $permissions $check_file
96 chown $owner_group $check_file
98 warning "$check_file is not setup properly" 0
101 verbose "$check_file is OK"
104 debug "EXIT check_and_replace_file"
105 } # check_and_replace_file
107 function check_nsswitch_conf {
108 debug "ENTER check_nsswitch_conf"
110 sed 's/automount: files nis/automount: nis files/' \
111 /etc/nsswitch.conf > $tmpprefix.nsswitch.conf
113 check_and_replace_file $tmpprefix.nsswitch.conf /etc/nsswitch.conf 444
116 debug "EXIT check_nsswitch_conf"
117 } # check_nsswitch_conf
119 function check_automount_maps {
120 debug "ENTER check_automount_maps"
122 for map in master home direct indirect; do
123 check_and_replace_file /adm/etc/auto_$map /etc/auto_$map 444 root:adm
126 debug "EXIT check_automount_maps"
127 } # check_automount_maps
129 function setup_rcfiles {
130 debug "ENTER setup_rcfiles"
131 local_src=$ADM_PATH/etc/init.d/local
132 local_dest=/etc/init.d/local
133 local_symlink=/etc/rc3.d/S99local
135 if [ ! -x $local_dest ]; then
136 if [ $mode = "fix" ]; then
137 verbose "Creating $local_dest"
138 cp "$local_src" $local_dest
139 chown root:adm $local_dest
140 chmod 555 $local_dest
142 warning "$local_dest does not exist!" 0
145 verbose "$local_dest is OK"
148 if [ ! -h $local_symlink ]; then
149 if [ $mode = "fix" ]; then
150 verbose "Setting up $local_symlink"
151 ln -s $local_dest $local_symlink
153 warning "$local_symlink does not exist!" 0
156 verbose "$local_symlink is OK"
159 if [ ! -d /etc/Startup ]; then
160 if [ $mode = "fix" ]; then
161 verbose "Creating /etc/Startup directory"
163 chown root:adm /etc/Startup
164 # Note: Security would be better if this was 775...
165 chmod 777 /etc/Startup
167 warning "/etc/Startup does not exist!" 0
170 verbose "/etc/Startup is OK"
173 start_views_src=$ADM_PATH/clearcase/start_views
174 start_views_dest=/etc/Startup/start_views
176 if [ ! -x $start_views_dest ]; then
177 if [ $mode = "fix" ]; then
178 verbose "Creating $start_views_dest"
179 cp "$start_views_src" $start_views_dest
180 chown root:adm $start_views_dest
181 chmod 555 $start_views_dest
183 warning "$start_views_dest does not exist!" 0
186 verbose "$start_views_dest is OK"
189 views_to_start_src=$ADM_PATH/clearcase/views_to_start
190 views_to_start_dest=/etc/views_to_start
192 if [ ! -f $views_to_start_dest ]; then
193 if [ $mode = "fix" ]; then
194 verbose "Creating $views_to_start_dest"
195 cp "$views_to_start_src" $views_to_start_dest
196 chown root:adm $views_to_start_dest
197 chmod 555 $views_to_start_dest
199 warning "$views_to_start_dest does not exist!" 0
202 verbose "$views_to_start_dest is OK"
205 debug "EXIT setup_rcfiles"
208 function setup_root_rhosts {
209 debug "ENTER setup_root_rhosts"
210 root_rhosts_src="$ADM_PATH/etc/root_rhosts"
211 root_rhosts_dest="/.rhosts"
213 if [ ! -f $root_rhosts_dest ]; then
214 if [ $mode = "fix" ]; then
215 verbose "Creating $root_rhosts_dest"
216 cp "$root_rhosts_src" $root_rhosts_dest
217 chown root:adm $root_rhosts_dest
218 chmod 400 $root_rhosts_dest
220 warning "$root_rhosts_dest does not exist!" 0
224 if ! cmp -s $root_rhosts_src $root_rhosts_dest; then
225 if [ $mode = "fix" ]; then
226 verbose "Updating $root_rhosts_dest"
227 cp "$root_rhosts_src" $root_rhosts_dest
228 chown root:adm $root_rhosts_dest
229 chmod 400 $root_rhosts_dest
231 warning "Contents of $root_rhosts_dest is non standard!" 0
235 verbose "$root_rhosts_dest is present"
236 verbose "Contents not check since you're not running as root"
240 debug "EXIT setup_root_rhosts"
241 } # setup_root_rhosts
243 function setup_root_profile {
244 debug "ENTER setup_root_profile"
245 if [ "$VENDOR" = "HP" ]; then
246 debug "RETURN setup_root_profile (Skip HP machines)"
249 root_profile_src="$ADM_PATH/etc/root_profile"
250 root_profile_dest="/.profile"
252 if [ ! -f $root_profile_dest ]; then
253 if [ $mode = "fix" ]; then
254 verbose "Creating $root_profile_dest"
255 cp "$root_profile_src" $root_profile_dest
256 chown root:adm $root_profile_dest
257 chmod 444 $root_profile_dest
259 warning "$root_profile_dest does not exist!" 0
263 if ! cmp -s $root_profile_src $root_profile_dest; then
264 if [ $mode = "fix" ]; then
265 verbose "Updating $root_profile_dest"
266 cp "$root_profile_src" $root_profile_dest
267 chown root:adm $root_profile_dest
268 chmod 400 $root_profile_dest
270 warning "Contents of $root_profile_dest is non standard!" 0
274 verbose "$root_profile_dest is present"
275 verbose "Contents not check since you're not running as root"
279 debug "EXIT setup_root_profile"
280 } # setup_root_rhosts
283 while [ $# -ge 1 ]; do
306 usage "Unrecognized parameter $1"
312 if [ "$mode" = "fix" ]; then
314 error "Must be root to execute this command in fix mode!" 2
318 verbose "Starting $me..."
325 verbose "$me completed"