288
|
1 #! bash
|
|
2
|
|
3 yorn()
|
|
4 {
|
|
5 echo -n " [y/n] "
|
|
6 read YN junk
|
|
7 if [ "$YN" = "n" ]
|
|
8 then
|
|
9 return -1;
|
|
10 else
|
|
11 return 0;
|
|
12 fi
|
|
13 }
|
|
14
|
|
15 echo -n "checking for cygwin..."
|
|
16
|
|
17 if ! uname -v
|
|
18 then
|
|
19 echo "couldn't find uname please add cygwin to your path."
|
|
20 exit -1
|
|
21 fi
|
|
22
|
|
23 OSversion="`uname -v | sed 's/^\(.\).*$/\1/'`"
|
|
24
|
|
25 shell=`type sh | sed 's/sh is //'`
|
|
26 distdir=`dirname $shell`
|
|
27
|
|
28 echo "cygwin installed in $distdir"
|
|
29
|
|
30 echo "checking paths ..."
|
|
31
|
|
32 if [ ! -d "/bin" ]; then
|
|
33 echo "You don't have /bin would like to mount cygwin as /bin ?"
|
|
34 if yorn; then
|
|
35 mkdir /bin
|
|
36 mount -b /bin $distdir
|
|
37 fi
|
|
38 elif [ "$distdir" != "/bin" ]; then
|
|
39 echo "Warning: you have /bin but it's not the cygwin installation."
|
|
40 fi
|
|
41
|
|
42 if [ ! -d "/tmp" ]; then
|
|
43 echo -n "You don't have /tmp - create it?"
|
|
44 if yorn; then
|
|
45 mkdir /tmp
|
|
46 fi
|
|
47 else
|
|
48 echo "you have /tmp"
|
|
49 fi
|
|
50
|
|
51 if [ ! -d "/etc" ]; then
|
|
52 echo -n "You don't have /etc - create it?"
|
|
53 if yorn; then
|
|
54 mkdir /etc
|
|
55 fi
|
|
56 else
|
|
57 echo "you have /etc"
|
|
58 fi
|
|
59
|
|
60 if [ -d "/etc" ]
|
|
61 then
|
|
62 if [ ! -f "/etc/termcap" ]; then
|
|
63 echo -n "You don't have /etc/termcap - create it?"
|
|
64 if yorn; then
|
|
65 if [ ! -f "$distdir/../etc/termcap" ]
|
|
66 then
|
|
67 distdir=`mount | grep "$distdir" | sed -e "s/ .*$//"`
|
|
68 echo "Retrieving termcap from $distdir/../etc"
|
|
69 fi
|
|
70 if [ -f "$distdir/../etc/termcap" ]
|
|
71 then
|
|
72 cp "$distdir/../etc/termcap" /etc
|
|
73 else
|
|
74 echo "Error: can't find termcap file"
|
|
75 fi
|
|
76 fi
|
|
77 else
|
|
78 echo "you have /etc/termcap"
|
|
79 fi
|
|
80
|
|
81 if [ ! -f "/etc/passwd" ]; then
|
|
82 echo -n "You don't have /etc/passwd - create it?"
|
|
83 if yorn; then
|
|
84 if [ "$OS" = "Windows_NT" ]
|
|
85 then
|
|
86 echo -n "Running on NT, create domain or local password file [d/l] "
|
|
87 read DL junk
|
|
88 if [ "$DL" = "d" ]
|
|
89 then
|
|
90 mkpasswd -d > /etc/passwd
|
|
91 else
|
|
92 mkpasswd -l > /etc/passwd
|
|
93 fi
|
|
94 else
|
|
95 echo "Please enter your userid e.g. andyp"
|
|
96 read userid junk
|
|
97 echo "Please enter your user name e.g. Andy Piper"
|
|
98 read username junk
|
|
99 echo "Administrator::500:513:::/bin/sh" > /etc/passwd
|
|
100 echo "$userid::1000:513:$username::/bin/sh" >> /etc/passwd
|
|
101 fi
|
|
102 fi
|
|
103 else
|
|
104 echo "you have /etc/passwd"
|
|
105 userid=`id | sed -e "s/[^(]*(\([^)]*\)).*/\1/"`
|
|
106 fi
|
|
107
|
|
108 echo "userid is $userid"
|
|
109
|
|
110 if [ ! -f "/etc/group" ]; then
|
|
111 echo -n "You don't have /etc/group - create it?"
|
|
112 if yorn; then
|
|
113 if [ "$OS" = "Windows_NT" ]
|
|
114 then
|
|
115 echo -n "Running on NT, create domain or local group file [d/l] "
|
|
116 read DL junk
|
|
117 if [ "$DL" = "d" ]
|
|
118 then
|
|
119 mkgroup -d > /etc/group
|
|
120 else
|
|
121 mkgroup -l > /etc/group
|
|
122 fi
|
|
123 else
|
|
124 echo "None::513:" > /etc/group
|
|
125 echo "Everyone::0:" >> /etc/group
|
|
126 fi
|
|
127 fi
|
|
128 else
|
|
129 echo "you have /etc/group"
|
|
130 fi
|
|
131
|
|
132 if [ ! -f "/etc/hosts" ]; then
|
|
133 echo -n "You don't have /etc/hosts - create it?"
|
|
134 if yorn; then
|
|
135 mname=`uname -n`
|
|
136 echo "Machine name is $mname"
|
|
137 echo -n "Please enter your ip address "
|
|
138 read mipaddr junk
|
|
139 echo "$mname $mipaddr" > /etc/hosts
|
|
140 echo "localhost 127.0.0.1" >> /etc/hosts
|
|
141 fi
|
|
142 else
|
|
143 echo "you have /etc/hosts"
|
|
144 fi
|
|
145 else
|
|
146 echo "Can't create /etc files because /etc does not exist"
|
|
147 fi
|
|
148
|
|
149 echo "checking environment ..."
|
|
150
|
|
151 if [ "$HOME" = "" ]; then
|
|
152 echo -n "HOME is not set, rectify?"
|
|
153 if yorn; then
|
290
|
154 if [ "$OS" = "Windows_NT" ]
|
|
155 then
|
|
156 echo "please enter your home path [/winnt/profiles/$userid]"
|
|
157 read HOME junk
|
|
158 if [ "$HOME" = "" ]; then
|
|
159 HOME="/winnt/profiles/$userid"
|
|
160 fi
|
|
161 else
|
|
162 echo "please enter your home path [/]"
|
|
163 read HOME junk
|
|
164 if [ "$HOME" = "" ]; then
|
|
165 HOME="/"
|
|
166 fi
|
288
|
167 fi
|
290
|
168
|
288
|
169 echo "HOME=$HOME; export HOME" >> $HOME/.bashrc
|
|
170 fi
|
|
171 else
|
|
172 echo "HOME is $HOME"
|
|
173 fi
|
|
174
|
|
175 if [ "$TERM" != "ansi" -a "$TERM" != "linux" ]; then
|
|
176 echo -n "TERM is not set to linux or ansi, rectify?"
|
|
177 if yorn; then
|
|
178 echo "TERM=linux; export TERM" >> $HOME/.bashrc
|
|
179 fi
|
|
180 else
|
|
181 echo "TERM is $TERM"
|
|
182 fi
|
|
183
|
290
|
184 if echo $CYGWIN32 | grep -w tty; then
|
288
|
185 echo "CYGWIN32 is $CYGWIN32"
|
|
186 else
|
|
187 echo "CYGWIN32 does not contain \"tty\" terminal may be deficient"
|
|
188 fi
|