2 ################################################################################
5 # Description: This script will perform additional setup to configure the
6 # local machine into the cygwin enviornment for Salira
7 # Author: Andrew@DeFaria.com
8 # Created: Fri Oct 5 15:30:16 2001
10 # Language: Bash Shell
12 # (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved
14 ################################################################################
15 # Set me to command name
18 declare -i max_steps=14
21 cygwin_setup_version="2.1"
24 if [ "_$1" != "_" ]; then
28 echo "Usage: $me [US | China]"
36 if [ $step -lt 10 ]; then
42 echo "$step of $max_steps: $msg"
46 subnet=$(ipconfig | grep "IP Address" | awk '{ print $NF }' | cut -f1 -d.)
48 if [[ $subnet = 192 || $subnet = 172 ]]; then
54 if [ "$region" != "us" -a "$region" != "china" ]; then
58 # Determine what site parms to use
59 if [ "$region" = "us" ]; then
61 site_parms=/view/official/Tools/adm/etc/site_parms.US
64 # Use Shanghai site parms
65 site_parms=/view/official/Tools/adm/etc/site_parms.CN
69 adm="$SITE_TOOLS_PATH/adm"
71 # Current machine's OS
72 OS=$(uname -s | cut -f2 -d-)
74 # Current machine's hostname
75 hostname=$(echo $(hostname) | tr [:upper:] [:lower:])
78 echo "Running $me version ($cygwin_setup_version) $hostname [Windows: $OS] in region: $region"
81 ################################################################################
85 ################################################################################
86 function setup_home_mount {
87 step "Setting up home mount"
90 mount -bsf "//$SITE_HOME_SERVER/$SITE_HOME_SHARENAME" /"$SITE_REGION"
93 ################################################################################
97 ################################################################################
98 function setup_clearcase_views {
99 step "Setting up view mount points"
101 if [ $hostname = $SITE_VIEW_SERVER ]; then
102 if [ $region = "us" ]; then
103 mount -bsf E:/Views "$SITE_SNAPSHOT_VIEW_PATH"
105 mount -bsf D:/ "$SITE_SNAPSHOT_VIEW_PATH"
108 mount -bsf "$SITE_VIEW_STORAGE" "$SITE_SNAPSHOT_VIEW_PATH"
111 # Mount dynamic views
112 mount -bsf M: "$SITE_DYNAMIC_VIEW_PATH"
113 } # setup_clearcase_views
115 ################################################################################
119 ################################################################################
120 function setup_tools_mount {
121 step "Setting up tools mount point"
123 mount -bsf //$SITE_BUILD_SERVER/Tools /tools
124 } # setup_tools_mount
126 ################################################################################
128 # Setup release mount
130 ################################################################################
131 function setup_release_mount {
132 step "Set up release mount point"
134 mount -bsf //$(echo $SITE_RELEASE_SERVER |
135 cut -f1 -d' ')/$(echo $SITE_RELEASE_PATH | cut -f1 -d' ') /release
136 } # setup_release_mount
138 ################################################################################
140 # Set cygdrive prefix to /dev
142 ################################################################################
143 function set_cygdrive_prefix {
144 step "Setting cygdrive-prefix to /dev"
146 mount -s --change-cygdrive-prefix /dev
148 # Remove user level cygdrive-prefix (Need to do this with regedit)
149 regedit /s $(cygpath -w "$SITE_TOOLS_PATH/bin/FixCygwin.reg")
150 } # set_cygdrive_prefix
152 ################################################################################
156 ################################################################################
157 function link_passwd_file {
158 step "Linking to common password file"
160 if [ ! -f /etc/passwd.local ]; then
161 if [ ! -L /etc/passwd ]; then
162 cp /etc/passwd /etc/passwd.local
166 if [ ! -L /etc/passwd ]; then
167 if [ "$OS" != "4.0" ]; then
169 ln -s "$SITE_TOOLS_PATH/adm/etc/passwd.$SITE_NAME" /etc/passwd
171 cp "$SITE_TOOLS_PATH/adm/etc/passwd.$SITE_NAME" /etc/passwd
174 if [ "$OS" = "4.0" ]; then
175 # Fix up NT 4.0 machines (they don't like symlinked /etc/passwd files!)
177 cp "$SITE_TOOLS_PATH/adm/etc/passwd.$SITE_NAME" /etc/passwd
179 # Check to see if link is correct
180 linkname=$(ls -l /etc/passwd | awk '{print $NF}')
181 if [ "$linkname" != "$SITE_TOOLS_PATH/adm/etc/passwd.$SITE_NAME" ]; then
183 ln -s "$SITE_TOOLS_PATH/adm/etc/passwd.$SITE_NAME" /etc/passwd
189 ################################################################################
193 ################################################################################
194 function link_group_file {
195 step "Linking to common group file"
197 if [ ! -f /etc/group.local ]; then
198 if [ ! -L /etc/group ]; then
199 cp /etc/group /etc/group.local
203 if [ ! -L /etc/group ]; then
205 ln -s "$SITE_TOOLS_PATH/adm/etc/group" /etc/group
207 # Check to see if link is correct
208 linkname=$(ls -l /etc/group | awk '{print $NF}')
209 if [ "$linkname" != "$SITE_TOOLS_PATH/adm/etc/group" ]; then
211 ln -s "$SITE_TOOLS_PATH/adm/etc/group" /etc/group
216 ################################################################################
220 ################################################################################
221 function link_site_parms {
222 step "Linking to common site_parms file"
224 if [ ! -L /etc/site_parms ]; then
226 ln -s "$site_parms" /etc/site_parms
228 # Check to see if link is correct
229 linkname=$(ls -l /etc/site_parms | awk '{print $NF}')
230 if [ "$linkname" != "$SITE_TOOLS_PATH/adm/etc/site_parms" ]; then
232 ln -s "$site_parms" /etc/site_parms
237 ################################################################################
241 ################################################################################
242 function link_profile {
243 step "Linking to common profile file"
245 if [ ! -f /etc/profile.orig ]; then
246 if [ ! -L /etc/profile ]; then
247 cp /etc/profile /etc/profile.orig
251 if [ ! -L /etc/profile ]; then
253 ln -s "$SITE_TOOLS_PATH/adm/etc/profile" /etc/profile
255 # Check to see if link is correct
256 linkname=$(ls -l /etc/profile | awk '{print $NF}')
257 if [ "$linkname" != "$SITE_TOOLS_PATH/adm/etc/profile" ]; then
259 ln -s "$SITE_TOOLS_PATH/adm/etc/profile" /etc/profile
264 ################################################################################
266 # Setup inetutil config
268 ################################################################################
269 function setup_inetutil_config {
270 step "Setup inetutil config"
272 # First save any pre-existing /etc/motd
273 if [ -f /etc/motd ]; then
274 cp /etc/motd /etc/motd.$$
277 rm -f /etc/ftpusers /etc/ftpwelcome /etc/inetd.conf /etc/motd /etc/shells
278 iu-config > /dev/null
280 # In order to allow anonymous ftp access we need to clear /etc/ftpusers.
281 # Do this only for the $anonymous_ftp_server for now
282 if [ $hostname = $SITE_ANON_FTP_SERVER ]; then
283 cat /dev/null > /etc/ftpusers
286 # Now replace that saved /etc/motd if it existed, otherwise remove the boring
287 # /etc/motd that iu-config creates. First check to see if the user has a
288 # personalized /etc/motd in /etc/motd.save
289 if [ -f /etc/motd.save ]; then
290 # User had a personalized motd so move it into place and remove any prior
292 mv /etc/motd.save /etc/motd
294 elif [ -f /etc/motd.$$ ]; then
295 # Reinstall previous motd
296 # First update uname -a line
299 # Remove old uname -a line if present
300 grep -ve "^cygwin" /etc/motd.$$ >> /etc/motd.$$
305 # No saved motd or previous motd. Remove /etc/motd which will cause us
306 # to prompt for the information later.
310 # Need to hardlink /usr/bin/cygwin1.dll & /usr/sbin/cygwin1.dll
311 # 12/17/2001: Stopped hardlinking cygwin1.dll. Enforcing having Windows system
312 # environment variables instead. For this we need Cygwin's bin in the path.
313 # User should also set CYGWIN=ntsec in a Windows system environment variable.
314 if [ -f /usr/sbin/cygwin1.dll ]; then
315 rm -f /usr/sbin/cygwin1.dll
316 #ln /usr/bin/cygwin1.dll /usr/sbin/cygwin1.dll
317 echo "Warning: Please make sure that you have a Windows *SYSTEM* environment"
318 echo " variable named CYGWIN set to the value of \"ntsec\" and that"
319 echo " you have <Cygwin>\bin inserted into the Windows *SYSTEM*"
320 echo " environment variable named PATH"
323 # Set up anonymous ftp iff we are on the $anonymous_ftp_server
324 if [ $hostname = $SITE_ANON_FTP_SERVER ]; then
325 # Toggle on write access to ~ftp/bin
328 # Remove old copies of ls and cygwin1.dll
329 rm -f ~ftp/bin/ls.exe
330 rm -f ~ftp/bin/cygwin1.dll
332 # Install new copies (Note hardlinks will not work here since ~ftp/bin is
333 # on another file system. Doing an ln simply does a copy anyway)
334 # 12/17/2001: Skipping copying of cygwin1.dll as noted above
335 cp /bin/cygwin1.dll ~ftp/bin/cygwin1.dll
336 cp /bin/ls.exe ~ftp/bin/ls.exe
339 chmod 555 ~ftp/bin/cygwin1.dll
340 chmod 111 ~ftp/bin/ls.exe
341 chown Administrator ~ftp/bin/cygwin1.dll
342 chown Administrator ~ftp/bin/ls.exe
345 } # setup_inetutil_config
347 ################################################################################
351 ################################################################################
352 function setup_inetd {
355 # Install inetd as a service
356 /usr/sbin/inetd --install-as-service
358 # Start inetd service
359 inetd_started=$(net start | grep -i inetd)
361 if [ -z "$inetd_started" ]; then
362 net start inetd > /tmp/inetd.log 2>&1
364 if [ $? -ne 0 ]; then
365 echo "ERROR: Unable to start inetd service"
374 ################################################################################
378 ################################################################################
382 # Remove previous service (if any)
383 cygrunsrv -R sshd > /dev/null 2>&1
385 # Set up hosts configuration
386 echo "ntsec smbntsec" | ssh-host-config -y > /tmp/ssh-host-config.log 2>&1
389 if [ $? -ne 0 ]; then
390 echo "ERROR: An error occurred setting up ssh:"
391 cat /tmp/ssh-host-config.log
396 net start sshd > /tmp/ssh-host-config.log 2>&1
398 if [ $? -ne 0 ]; then
399 echo "ERROR: Unable to start ssh service:"
400 cat /tmp/ssh-host-config.log
403 rm -f /tmp/ssh-host-config.log
407 ################################################################################
411 ################################################################################
412 function setup_ssmtp {
416 $SITE_TOOLS_PATH/adm/bin/setup_ssmtp
419 ################################################################################
423 ################################################################################
424 function setup_cron {
428 $SITE_TOOLS_PATH/adm/bin/setup_cron
431 ################################################################################
435 ################################################################################
436 function create_motd {
437 step "Gathering machine specific information"
439 if [ ! -f /etc/motd ]; then
440 $SITE_TOOLS_PATH/adm/bin/make_motd
443 echo "Skipped: Machine info already gathered"
446 # Fixup /etc/ftpwelcome
447 host=$(hostname | tr [:upper:] [:lower:])
448 echo "Welcome to $host's ftp service" > /etc/ftpwelcome
451 ################################################################################
453 # Update machines file
455 ################################################################################
456 function update_machines_file {
457 step "Registering this machine"
459 if [ ! -z "$made_motd" ]; then
460 $SITE_TOOLS_PATH/adm/bin/update_machine_info
462 echo "Skipped: Machine already registered"
464 } # update_machines_file
466 ################################################################################
470 ################################################################################
473 setup_clearcase_views
481 setup_inetutil_config