home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / serveroncd / Server-on-CD.iso / socd / sbin / rc.d / rc.install.en < prev    next >
Encoding:
Text File  |  2003-10-31  |  7.5 KB  |  375 lines

  1. #!/bin/sh
  2.  
  3. ende() {
  4. IP=`cat /tmp/ip`
  5.  
  6. if [ -r /tmp/fail ]
  7.  then
  8. dialog --clear --title "Finish installation" --msgbox \
  9. "\nCongratulations!\n
  10. You probably installed Server-on-CD successfully. But with the
  11. automatical network check no workstation with fitting IP-number
  12. could be found. Please check the network wiring and the network
  13. settings at the workstations (Start -> Settings -> Control Panel
  14. -> Network). Further information can be found in the help-files 
  15. on the CD - see per webbrowser." 15 74
  16.  
  17. else
  18. dialog --clear --title "Finish installation" --msgbox \
  19. "\nCongratulations!\n 
  20. You installed Server-on-CD successfully. The further required 
  21. configurations are to enter at one of the connected workstations. 
  22. Therefore please enter into the address line of the webbrowser of 
  23. the workstation the following IP-number: 
  24. http://$IP:150" 15 72
  25. fi
  26.  
  27. rm /tmp/{setup.*,ip,ipnr,pass,fail} 2>&1 1>&/dev/null
  28.  
  29. startdienste
  30.  
  31. setterm -default
  32. setterm -blank 15
  33. }
  34.  
  35.  
  36. dhcp()
  37. {
  38.   dialog --clear --title "DHCP IP-Numbers" --inputbox \
  39. "\nPlease enter the IP-number for your DHCP-server or press <ENTER>
  40. for the IP-number 192.168.0.1. The third group of figures 
  41. (default=0) defines the network scope for the DHCP-Server, the 
  42. fourth group of figures (default=1) defines the number of the 
  43. server. The first group of figures should sound in \"192\", the 
  44. second in \"168\".\n\n" 20 72 "192.168.0.1" 2>/tmp/setup.$$
  45. antwort=$?
  46.  
  47.  
  48. if [ $antwort -eq 0 ]
  49.  then
  50.  if [ -z `cat /tmp/setup.$$` ]
  51.  then
  52.      /sbin/ifconfig eth0 192.168.0.1 2>&1 1>&/dev/null
  53.     echo -n "192.168.0.1" >/etc/IPNR
  54.     echo " 0" >>/etc/IPNR
  55.     echo "ddns-update-style ad-hoc;" >/etc/dhcpd.conf
  56.     echo "subnet $IPNR netmask 255.255.255.0 {" >>/etc/dhcpd.conf
  57.     echo "       range 192.168.0.2 192.168.0.254;">>/etc/dhcpd.conf
  58.     echo "max-lease-time 2419200;">>/etc/dhcpd.conf
  59.     echo "default-lease-time 2419200;">>/etc/dhcpd.conf
  60.     echo "}">>/etc/dhcpd.conf
  61.     echo "option netbios-node-type 1;">>/etc/dhcpd.conf
  62.     echo "option routers 192.168.0.1;">>/etc/dhcpd.conf
  63.     echo "option domain-name-servers 192.168.0.1;">>/etc/dhcpd.conf
  64.  
  65.   else 
  66.  
  67.    /bin/testip `cat /tmp/setup.$$`
  68.    if [ $?  -ne 0 ]
  69.     then
  70.     fehlernetz
  71.         return 1
  72.     fi
  73.  
  74.     IP=`cat /tmp/setup.$$`
  75.     echo $IP >/tmp/ip
  76.     NET=`awk -F. '{print $1"."$2"."$3}' /tmp/setup.$$`
  77.  
  78.     /sbin/ifconfig eth0 $IP up 2>&1 1>&/dev/null
  79.  
  80.     IPNET=`awk -F. '{print $4+0}' /tmp/setup.$$`
  81.  
  82.     if [ $IPNET  -lt 3 ]
  83.      then
  84.     IPMI=3
  85.     IPMA=254
  86.     elif [ $IPNET -gt 253 ]
  87.      then
  88.     IPMI=1
  89.     IPMA=253
  90.     else 
  91.     MAX2=`expr $IPNET - 1`
  92.     MIN2=`expr $IPNET + 1`
  93.     fi
  94.  
  95.     echo -n $IP >/etc/IPNR
  96.     echo " 0" >>/etc/IPNR
  97.  
  98.     echo "ddns-update-style ad-hoc;" >/etc/dhcpd.conf
  99.     echo "subnet $NET.0 netmask 255.255.255.0 {" >>/etc/dhcpd.conf
  100.  
  101.     if [ $MAX2 -lt $IPNET ]
  102.      then
  103.         echo "       range $NET.1 $NET.$MAX2;" >> /etc/dhcpd.conf
  104.         echo "       range $NET.$MIN2 $NET.254;" >> /etc/dhcpd.conf
  105.     else
  106.     echo "       range $NET.$IPMI $NET.$IPMA;">>/etc/dhcpd.conf
  107.     fi
  108.  
  109.     echo "max-lease-time 2419200;">>/etc/dhcpd.conf
  110.     echo "default-lease-time 2419200;">>/etc/dhcpd.conf
  111.     echo "}">>/etc/dhcpd.conf
  112.     echo "option netbios-node-type 1;">>/etc/dhcpd.conf
  113.     echo "option routers $IP;">>/etc/dhcpd.conf
  114.     echo "option domain-name-servers $IP;">>/etc/dhcpd.conf
  115.   fi 
  116.   else
  117.    /etc/rc.d/rc.install.en
  118.    exit 
  119. fi
  120.  
  121.  /usr/bin/dhcpd 2>&1 1>&/dev/null
  122.  echo "1" >/etc/DHCP
  123.  passwort
  124.  testpass
  125.  ende
  126.  init 2
  127.  exit
  128. }
  129.  
  130. ethkonfig()
  131. {
  132.     zahl=$1
  133.     IPNR=$2
  134.  
  135.     /sbin/ifconfig eth$zahl $IPNR up 2>&1 1>&/dev/null
  136.     
  137.     if [ $? -ne 0 ]
  138.     then
  139.     return 0
  140.     fi
  141.  
  142.     echo -n $IPNR >/etc/IPNR
  143.  
  144.     dialog --title "Checking netconfiguration"    --infobox "\n\n                          Please wait..." 8 72
  145.     
  146.     sleep 1
  147.  
  148.     /usr/bin/myping $IPNR
  149.  
  150.     if [ $? -ne 0 ]
  151.     then
  152.         /sbin/ifconfig eth$zahl 10.0.0.$(($zahl+1)) 2>&1 1>&/dev/null
  153.     return 0
  154.     else
  155.     echo " $zahl" >>/etc/IPNR
  156.     return 1
  157.     fi
  158. }
  159.  
  160. fehlerpass()
  161. {
  162.   dialog --clear --title "Password" --inputbox \
  163. "\nThe selected password is too short. It has to feature at 
  164. least four symbols." 20 72 2>/tmp/setup.$$
  165. antwort=$?
  166. testpass
  167. }
  168.  
  169.  
  170. passwort()
  171. {
  172.  dialog --clear --title "Password for Server-on-CD" --inputbox \
  173. "\nPlease enter a password for the administrator.  The password
  174. is required to modify the system settings. Is has to feature at
  175. least four symbols. It may be composed of only figures and
  176. letters. You are able to later modify the password at a
  177. workstation.\n" 20 72 2>/tmp/setup.$$
  178. antwort=$?
  179.  
  180.  
  181.  
  182.  
  183. if [ $antwort -eq 1 ]
  184.  then
  185.     until netz
  186.       do foo
  187.     done
  188.   passwort
  189.   testpass
  190.   return
  191. fi
  192.  
  193. }
  194.  
  195. testpass()
  196. {
  197. COUNT=$(wc -c </tmp/setup.$$)
  198. if [ $COUNT -lt 4 ]
  199.  then
  200.   fehlerpass $IPNR 1
  201.   unset COUNT
  202.   return 1
  203. fi
  204. unset COUNT
  205. writepass
  206. }
  207.  
  208. writepass()
  209. {
  210. echo -n "root:" > /tmp/pass
  211. cat /tmp/setup.$$ >> /tmp/pass
  212. echo -e "" >> /tmp/pass
  213. chpasswd </tmp/pass
  214. /usr/bin/htpasswd -bc /etc/apache/passwd supervisor `cat /tmp/setup.$$` 2>&1 1>&/dev/null
  215. rm /tmp/setup.$$
  216. rm /tmp/pass
  217. }
  218.  
  219. fehlernetz()
  220. {
  221. dialog --clear --title "Wrong input" --msgbox \
  222. "\nThe selected IP-Number is invalid. Please mind the format 
  223. information.\n" 10 72
  224. }
  225.  
  226.  
  227. testnetz()
  228. {
  229. if [ ! -r /tmp/setup.$$ ]
  230.  then
  231.   fehlernetz
  232. fi
  233. IPNR=`awk -F. '{print $1+0"."$2+0"."$3+0"."$4+0}' /tmp/setup.$$`
  234. echo $IPNR >/tmp/ipnr
  235.  
  236. /bin/testip -a $IPNR
  237. if [ $? -ne 0 ]
  238. then
  239.   fehlernetz
  240.   return 1
  241. fi
  242.  
  243. for i in 0 1 2 3 
  244.  do
  245.   ethkonfig $i $IPNR
  246.   rueck=$?
  247.   if [ $rueck -eq 1 ]
  248.    then 
  249.    break
  250.   fi
  251. done
  252.  
  253. if [ $rueck -eq 0 ]
  254.  then
  255.   dialog --title "Attention" --menu "\n
  256. The network does not answer. Maybe no any other PCs with 
  257. fitting IP-numbers are attached or switched-on. Fitting 
  258. IP-numbers match within the first three figures.
  259. Please select:\n" 17 72 2 \
  260. "1" "Continue configuration" \
  261. "2" "Re-execute the network configuration" 2>/tmp/setup.$$
  262. antwort=$?
  263.  
  264.  
  265.  
  266.  
  267. if [ $antwort = 0 ]
  268.  then
  269.   ANTWORT=`cat /tmp/setup.$$`
  270.   case $ANTWORT in
  271.     2) netz
  272.        return ;;
  273.         1)  /sbin/ifconfig eth0 $IPNR 
  274.         echo -n $IPNR >/etc/IPNR 
  275.         echo -e "1" >/tmp/fail 
  276.         echo " 0" >>/etc/IPNR ;;
  277.         
  278.   esac
  279. else
  280.  netz
  281.  return
  282. fi
  283. fi
  284.  
  285. return 0
  286. }
  287.  
  288.  
  289. netzwerk()
  290. {
  291.  dialog --clear --title "IP-number of the  servers" --inputbox \
  292. "\nPlease enter \"DHCP\" for the auto-installation of Server-on-CD.
  293. Otherwise please enter the IP-number for this PC. The format has
  294. to be: 192.168.x.y (x=0-255, y=1-254). The value for x must be
  295. the same with all PCs in the network, the value for y must be
  296. unique. If you did not enter any IP-number in the network, we
  297. suggest 192.168.0.1 (default) for the fist workstation, for the
  298. second 192.168.0.2 and so on.\n\n" 20 72 "DHCP" \
  299. 2>/tmp/setup.$$
  300.  
  301.  
  302. antwort=$?
  303. if [ $antwort -eq 0 ]
  304.  then
  305.     cp /tmp/setup.$$ /tmp/ip
  306. else 
  307.  /etc/rc.d/rc.install.en
  308.  exit
  309. fi
  310. }
  311.  
  312. netz()
  313. {
  314.     netzwerk
  315.     if [ `grep -i -c "dhcp" /tmp/ip` -eq 1 ]
  316.      then
  317.       dhcp
  318.     else
  319.      testnetz
  320.       if [ $? -ne 0 ] 
  321.        then
  322.         return 1
  323.      fi
  324.     fi
  325. }
  326.  
  327. foo()
  328. {
  329.    return
  330. }
  331.  
  332. startdienste()
  333. {
  334. /usr/sbin/apachectl start 2>&1 1>&/dev/null
  335. /usr/sbin/smbd -D -s /etc/samba/smb.conf 2>&1 1>&/dev/null
  336. /usr/sbin/nmbd -D -s /etc/samba/smb.conf 2>&1 1>&/dev/null
  337. }
  338.  
  339. dialog --clear --title "Server-on-CD" --msgbox \
  340. "\nWelcome to your new Server-on-CD. Below you have to enter some
  341. specifications. After the successful installation you can
  342. administrate the server from any workstation in the network. This 
  343. workstation only needs an actual webbrowser with activated 
  344. Java-Script." 15 72
  345.  
  346. cd /mnt/C  2>&1 1>&/dev/null
  347. if [ ! -d socd ]
  348.  then
  349.   mkdir socd  2>&1 1>&/dev/null
  350. fi
  351.  
  352. until netz
  353.  do
  354.   foo
  355. done
  356.  
  357. passwort
  358. testpass
  359. ende
  360.  
  361. if [ -e /etc/DHCP ]
  362.  then
  363.   if [ `cat /etc/DHCP` -eq 1 ]
  364.    then
  365.     /usr/bin/dhcpd
  366.   fi
  367. fi
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.