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