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
19 commonserver=sonscentral
21 adm=//$commonserver/$commonarea/adm
22 homeserver=sonscentral
24 ccserver=sons-clearcase
25 anonymous_ftp_server=sons-clearcase
27 printerserver=sons-mrp
35 # Current machine's OS.
36 OS=$(uname -s | cut -f2 -d-)
38 # Current machine's hostname
39 hostname=$(echo $(hostname) | tr [:upper:] [:lower:])
41 # Setup standard mounts
44 echo "Step 1 of 10: Setting up /home mount point"
45 mount -tsf //$homeserver/$homeshare /home
48 echo "Step 2 of 10: Setting up /view mount point"
49 if [ $hostname = $ccserver ]; then
50 mount -tsf C:/ClearCaseStorage/Views /view
52 mount -tsf //$ccserver/$viewshare /view
55 # Set cygdrive prefix to /dev
56 echo "Step 3 of 10: Setting cygdrive-prefix to /dev"
57 mount -s --change-cygdrive-prefix /dev
59 # Remove user level cygdrive-prefix (Need to do this with regedit
60 regedit /s \\\\$commonserver\\$commonarea\\FixCygwin.reg
63 echo "Step 4 of 10: Create common password file"
64 if [ ! -f /etc/passwd.local ]; then
65 if [ ! -L /etc/passwd ]; then
66 cp /etc/passwd /etc/passwd.local
70 if [ ! -L /etc/passwd ]; then
71 if [ "$OS" != "4.0" ]; then
73 ln -s //$commonserver/$commonarea/passwd /etc/passwd
75 cp //$commonserver/$commonarea/passwd /etc/passwd
78 if [ "$OS" = "4.0" ]; then
79 # Fix up NT 4.0 machines (they don't like symlinked /etc/passwd files!)
81 cp //$commonserver/$commonarea/passwd /etc/passwd
86 echo "Step 5 of 10: Create common group file"
87 if [ ! -f /etc/group.local ]; then
88 if [ ! -L /etc/group ]; then
89 cp /etc/group /etc/group.local
93 if [ ! -L /etc/group ]; then
95 ln -s //$commonserver/$commonarea/group /etc/group
99 echo "Step 6 of 10: Linking /etc/profile to common profile file"
100 if [ ! -f /etc/profile.orig ]; then
101 if [ ! -L /etc/profile ]; then
102 cp /etc/profile /etc/profile.orig
106 if [ ! -L /etc/profile ]; then
108 ln -s //$commonserver/$commonarea/profile /etc/profile
111 # Setup printer mount
112 echo "Step 7 of 10: Setting up printers"
113 for printer in $printers; do
114 mount -bsf //$printerserver/$printer /dev/$printer
117 # Mount default printer
118 mount -bsf //$printerserver/$defaultprinter /dev/lp
120 # Install internet services
121 echo "Step 8 of 10: Installing internet services"
123 # First save any pre-existing /etc/motd
124 if [ -f /etc/motd ]; then
125 cp /etc/motd /etc/motd.$$
128 rm -f /etc/ftpusers /etc/ftpwelcome /etc/inetd.conf /etc/motd /etc/shells
129 iu-config > /dev/null
131 # In order to allow anonymous ftp access we need to clear /etc/ftpusers.
132 # Do this only for the $anonymous_ftp_server for now
133 if [ $hostname = $anonymous_ftp_server ]; then
134 cat /dev/null > /etc/ftpusers
137 # Now replace that saved /etc/motd if it existed, otherwise remove the boring
138 # /etc/motd that iu-config creates. First check to see if the user has a
139 # personalized /etc/motd in /etc/motd.save
140 if [ -f /etc/motd.save ]; then
141 # User had a personalized motd so move it into place and remove any prior
143 mv /etc/motd.save /etc/motd
145 elif [ -f /etc/motd.$$ ]; then
146 # Reinstall previous motd
147 # First update uname -a line
150 # Remove old uname -a line if present
151 grep -ve "^cygwin" /etc/motd.$$ >> /etc/motd.$$
156 # No saved motd or previous motd. Remove /etc/motd which will cause us
157 # to prompt for the information later.
161 # Need to hardlink /usr/bin/cygwin1.dll & /usr/sbin/cygwin1.dll
162 # 12/17/2001: Stopped hardlinking cygwin1.dll. Enforcing having Windows system
163 # environment variables instead. For this we need Cygwin's bin in the path.
164 # User should also set CYGWIN=ntsec in a Windows system environment variable.
165 if [ -f /usr/sbin/cygwin1.dll ]; then
166 rm -f /usr/sbin/cygwin1.dll
167 #ln /usr/bin/cygwin1.dll /usr/sbin/cygwin1.dll
168 echo "Warning: Please make sure that you have a Windows *SYSTEM* environment"
169 echo " variable named CYGWIN set to the value of \"ntsec\" and that"
170 echo " you have <Cygwin>\bin inserted into the Windows *SYSTEM*"
171 echo " environment variable named PATH"
174 # Set up anonymous ftp iff we are on the $anonymous_ftp_server
175 if [ $hostname = $anonymous_ftp_server ]; then
176 # Toggle on write access to ~ftp/bin
179 # Remove old copies of ls and cygwin1.dll
180 rm -f ~ftp/bin/ls.exe
181 rm -f ~ftp/bin/cygwin1.dll
183 # Install new copies (Note hardlinks will not work here since ~ftp/bin is
184 # on another file system. Doing an ln simply does a copy anyway)
185 # 12/17/2001: Skipping copying of cygwin1.dll as noted above
186 cp /bin/cygwin1.dll ~ftp/bin/cygwin1.dll
187 cp /bin/ls.exe ~ftp/bin/ls.exe
190 chmod 555 ~ftp/bin/cygwin1.dll
191 chmod 111 ~ftp/bin/ls.exe
192 chown Administrator ~ftp/bin/cygwin1.dll
193 chown Administrator ~ftp/bin/ls.exe
197 # Install inetd as a service
198 /usr/sbin/inetd --install-as-service
200 # Start inetd service
201 inetd_started=$(net start | grep -i inetd)
203 if [ -z "$inetd_started" ]; then
214 echo "Step 9 of 10: Gathering machine specific information"
215 if [ ! -f /etc/motd ]; then
219 echo "Skipped: Machine info already gathered"
222 # Fixup /etc/ftpwelcome
223 host=$(hostname | tr [:upper:] [:lower:])
224 echo "Welcome to $host's ftp service" > /etc/ftpwelcome
226 # Update machines file
227 echo "Step 10 of 10: Registering this machine (This takes a few seconds)"
228 if [ ! -z "$made_motd" ]; then
229 $adm/bin/update_machine_info
231 echo "Skipped: Machine already registered"
234 # Sneaky other fixes...
235 # Link /bin/more.exe -> /bin/less.exe
236 if [ ! -L /bin/more.exe ]; then
237 ln -s /bin/less.exe /bin/more.exe