#!/bin/sh # # Script to setup a new production server. # This script should be called from the "install" program as a menu option. # # $Id: setup-server,v 1.9 2000/06/05 14:09:58 stewart Exp $ # # Rod m. Stewart # stewart@netwinder.org # if [ "" = "$1" -o "" = "$2" ]; then echo "Usage: $0 <10-250 -- server number> [server_IP -- eth0]" exit 1 fi if [ "" != "$3" ]; then SERVER_eth0=$3 BASE_eth0=`echo $3 | cut -f 1-3 --delimiter=. - ` else SERVER_eth0="192.168.254.$2" BASE_eth0="192.168.254" fi BASE_DIR="$1" SERVER_NO="$2" SERVER_eth1="192.168.$2.254" BASE_eth1="192.168.$2" GW="192.168.254.254" CLIENT_eth1="192.168.253.$SERVER_NO" BASE_CLIENT_eth1="192.168.253" SERVER_plip=10.3.84.84 CLIENT_plip=10.3.84.83 ## BASE_IP=192.168.`echo $SERVER_IP| cut -f 3 --delimiter=. - `. echo -e "base_dir $BASE_DIR \n\tserver_eth0 $SERVER_eth0" \ " \n\tbase_eth0 $BASE_eth0" \ " \n\tserver_eth1 $SERVER_eth1 \n\tbase_eth1 $BASE_eth1 " \ " \n\tserver_no $SERVER_NO" mkdir -p $BASE_DIR/etc/ntp mkdir -p $BASE_DIR/etc/sysconfig/network-scripts mkdir -p $BASE_DIR/vncroot/etc/ntp mkdir -p $BASE_DIR/vncroot/etc/sysconfig/network-scripts ## # etc/hosts (vncroot/etc/hosts) ## HOSTS=$BASE_DIR/etc/hosts echo "Creating etc/hosts (vncroot/etc/hosts) files" name=`echo $SERVER_eth0 \ | sed "s/\./-/" | sed "s/\./-/" | sed "s/\./-/" ` echo -e "127.0.0.1\t\tlocalhost.netwinder.org\t\tlocalhost\n" > $HOSTS echo -e "$SERVER_plip\t\tplip-server.netwinder.org\tplip-server" >> $HOSTS echo -e "$CLIENT_plip\t\tplip-client.netwinder.org\tplip-client\n" >> $HOSTS echo -e "$SERVER_eth1\t\tserver\tnfs-server\teth1-server" >> $HOSTS echo -e "$SERVER_eth0\t\tserver0\tback-server\teth0-server\n" >> $HOSTS echo -e "192.168.254.1\t\tbase-gw.netwinder.org\tbase-gw\ttest-100\n" >> $HOSTS echo -e "#" >> $HOSTS echo -e "# External Servers on eth0" >> $HOSTS echo -e "#" >> $HOSTS i=1 while [ $i != 255 ]; do echo -e \ "192.168.254.$i\t\tproduction-$i.netwinder.org\t" \ "production-$i p$i" \ >> $HOSTS i=$[$i+1] done echo -e "#" >> $HOSTS echo -e "# Ping tests IPs " >> $HOSTS echo -e "#" >> $HOSTS i=1 while [ $i != 255 ]; do echo -e \ "192.168.253.$i\t\t192-168-253-$i.netwinder.org\t" \ "192-168-253-$i" \ >> $HOSTS i=$[$i+1] done echo -e "#" >> $HOSTS echo -e "# Internal clients which nfs boot off eth1" >> $HOSTS echo -e "#" >> $HOSTS i=1 name=`echo $BASE_eth1 \ | sed "s/\./-/" | sed "s/\./-/" ` while [ $i != 255 ]; do echo -e \ "$BASE_eth1.$i\t\t$name-$i.netwinder.org\t" \ "$name-$i" \ >> $HOSTS i=$[$i+1] done cp -af $HOSTS $BASE_DIR/vncroot/etc ## # etc/dhcpd.conf ## ## Set router to an unused IP address. We do not want accidental ## data being routed through the default gw ## Use: 192.168.X.253 echo "Creating etc/dhcpd.conf file" echo -e "subnet $BASE_eth1.0 netmask 255.255.255.0 {\n" \ "\trange $BASE_eth1.1 $BASE_eth1.250;\n" \ "\tdefault-lease-time 120;\n" \ "\tmax-lease-time 120;\n\n" \ "\toption subnet-mask 255.255.255.0;\n" \ "\toption routers $BASE_eth1.253;\n" \ "\toption domain-name \"netwinder.org\";\n" \ "\toption broadcast-address $BASE_eth1.255;\n\n" \ "\tserver-name \"$SERVER_eth1\";\n" \ "\tfilename \"vmlinux_vnc.rev4\";\n" \ "\toption root-path \"$SERVER_eth1:/vncroot\";\n"\ "}" > $BASE_DIR/etc/dhcpd.conf ## # etc/exports ## echo "Creating etc/exports file" echo -e "/\t\t$BASE_eth1.0/255.255.255.0(rw,no_root_squash)\n" \ > $BASE_DIR/etc/exports ## # etc/ntp.conf # We simply tag our time server on to the end of the file ## echo "Creating etc/ntp.conf file" echo -e "server 192.168.254.1 minpoll 4 maxpoll 9\n"\ "server 10.8.54.9 minpoll 4 maxpoll 9\n" \ >> $BASE_DIR/etc/ntp.conf ## # vncroot/etc/ntp.conf # We simply tag our time server on to the end of the file ## echo "Creating vncroot/etc/ntp.conf file" echo -e "server $SERVER_eth1 minpoll 4 maxpoll 9\n"\ >> $BASE_DIR/vncroot/etc/ntp.conf ## # etc/ntp/step-tickers ## echo "Creating etc/ntp/step-tickers file" echo -e "192.168.254.1\n"\ "10.8.54.9" \ >> $BASE_DIR/etc/ntp/step-tickers ## # vncroot/etc/ntp/step-tickers ## echo "Creating vncroot/etc/ntp/step-tickers file" echo -e "$SERVER_eth1" \ >> $BASE_DIR/vncroot/etc/ntp/step-tickers ## # etc/redhat-release ## echo "Creating etc/redhat-release file" echo -e "\nRebel.com Inc.\n"\ "Production Server $SERVER_NO -- Shipping\n" \ >> $BASE_DIR/etc/redhat-release ## # vncroot/etc/redhat-release ## echo "Creating vncroot/etc/redhat-release file" echo -e "\nRebel.com Inc.\n"\ "NFS booted client off server $SERVER_NO -- Shipping\n" \ >> $BASE_DIR/vncroot/etc/redhat-release ## # etc/sysconfig/network ## echo "Creating etc/sysconfig/network file" echo -e "NETWORKING=yes\n"\ "FORWARD_IPV4=no\n"\ "HOSTNAME=production-$SERVER_NO\n"\ "DOMAINNAME=netwinder.org\n"\ "GATEWAY=$GW\n"\ "GATEWAYDEV=eth0"\ > $BASE_DIR/etc/sysconfig/network ## # vncroot/etc/sysconfig/network ## echo "Creating vncroot/etc/sysconfig/network file" echo -e "NETWORKING=yes\n"\ "FORWARD_IPV4=no\n"\ "HOSTNAME=nfs-client\n"\ "DOMAINNAME=netwinder.org\n"\ > $BASE_DIR/vncroot/etc/sysconfig/network ## # etc/sysconfig/network-scripts/ifcfg-eth0 ## echo "Creating etc/sysconfig/network-scripts/ifcfg-eth0 file" echo -e "DEVICE=eth0\n"\ "IPADDR=$SERVER_eth0\n"\ "NETMASK=255.255.255.0\n"\ "NETWORK=$BASE_eth0.0\n"\ "BROADCAST=$BASE_eth0.255\n"\ "ONBOOT=yes" \ > $BASE_DIR/etc/sysconfig/network-scripts/ifcfg-eth0 ## # vncroot/etc/sysconfig/network-scripts/ifcfg-eth0 ## echo "Creating vncroot/etc/sysconfig/network-scripts/ifcfg-eth0 file" echo -e "DEVICE=eth0\n"\ "IPADDR=\n"\ "NETMASK=\n"\ "NETWORK=\n"\ "BROADCAST=\n"\ "ONBOOT=no" \ > $BASE_DIR/vncroot/etc/sysconfig/network-scripts/ifcfg-eth0 ## # etc/sysconfig/network-scripts/ifcfg-eth1 ## echo "Creating etc/sysconfig/network-scripts/ifcfg-eth1 file" echo -e "DEVICE=eth1\n"\ "IPADDR=$SERVER_eth1\n"\ "NETMASK=255.255.255.0\n"\ "NETWORK=$BASE_eth1.0\n"\ "BROADCAST=$BASE_eth1.255\n"\ "ONBOOT=yes" \ > $BASE_DIR/etc/sysconfig/network-scripts/ifcfg-eth1 ## # vncroot/etc/sysconfig/network-scripts/ifcfg-eth1 ## echo "Creating vncroot/etc/sysconfig/network-scripts/ifcfg-eth1 file" echo -e "DEVICE=eth1\n"\ "IPADDR=$BASE_CLIENT_eth1.$SERVER_NO\n"\ "NETMASK=255.255.255.0\n"\ "NETWORK=$BASE_CLIENT_eth1.0\n"\ "BROADCAST=$BASE_CLIENT_eth1.255\n"\ "ONBOOT=no" \ > $BASE_DIR/vncroot/etc/sysconfig/network-scripts/ifcfg-eth1 ## # etc/sysconfig/network-scripts/ifcfg-plip0 ## echo "Creating etc/sysconfig/network-scripts/ifcfg-plip0 file" echo -e "DEVICE=plip0\n"\ "IPADDR=$SERVER_plip\n"\ "REMID=$CLIENT_plip\n"\ "NETMASK=255.255.255.255\n"\ "NETWORK=$SERVER_plip\n"\ "BROADCAST=$SERVER_plip\n"\ "ONBOOT=yes" \ > $BASE_DIR/etc/sysconfig/network-scripts/ifcfg-plip0 ## # vncroot/etc/sysconfig/network-scripts/ifcfg-plip0 ## echo "Creating vncroot/etc/sysconfig/network-scripts/ifcfg-plip0 file" echo -e "DEVICE=plip0\n"\ "IPADDR=$CLIENT_plip\n"\ "REMID=$SERVER_plip\n"\ "NETMASK=255.255.255.255\n"\ "NETWORK=$CLIENT_plip\n"\ "BROADCAST=$CLIENT_plip\n"\ "ONBOOT=no" \ > $BASE_DIR/vncroot/etc/sysconfig/network-scripts/ifcfg-plip0 ## # etc/fstab ## echo "Creating etc/fstab file" echo -e \ "# \n"\ "/dev/hda1 / ext2 defaults,usrquota 1 1\n"\ "/dev/hda2 none swap swap 0 0\n"\ "/dev/hda3 /home/ftp ext2 defaults,usrquota 1 2\n"\ "none /proc proc defaults 0 0\n"\ "none /dev/pts devpts gid=5,mode=620 0 0\n"\ > $BASE_DIR/etc/fstab ## # vncroot/etc/fstab ## echo "Creating vncroot/etc/fstab file" echo -e \ "# \n"\ "$SERVER_eth1:/vncroot / nfs defaults 0 0\n"\ "/dev/hda1 /mnt/hda1 ext2 defaults,noauto 0 0\n"\ "/dev/hda2 /mnt/hda2 ext2 defaults,noauto 0 0\n"\ "/dev/hda3 /mnt/hda3 ext2 defaults,noauto 0 0\n"\ "/dev/hda4 /mnt/hda4 ext2 defaults,noauto 0 0\n"\ "none /proc proc defaults 0 0\n"\ "none /dev/pts devpts gid=5,mode=620 0 0\n"\ > $BASE_DIR/vncroot/etc/fstab ## # etc/sysconfig/static-routes ## echo "Creating etc/sysconfig/static-routes" echo -e "eth0 net 192.168.253.0 netmask 255.255.255.0\n"\ "plip0 host $CLIENT_plip"\ >> $BASE_DIR/etc/sysconfig/static-routes ## # vncroot/etc/sysconfig/static-routes ## echo "Creating vncroot/etc/sysconfig/static-routes" echo -e "eth1 net 192.168.254.0 netmask 255.255.255.0\n"\ "plip0 host $SERVER_plip"\ >> $BASE_DIR/vncroot/etc/sysconfig/static-routes ## # etc/modules.conf ## echo "Appending to etc/modules.conf file" echo -e "options parport_pc io=0x378 irq=7"\ >> $BASE_DIR/etc/modules.conf ## # vncroot/etc/modules.conf ## echo "Appending to vncroot/etc/modules.conf file" echo -e "options parport_pc io=0x378 irq=7"\ >> $BASE_DIR/vncroot/etc/modules.conf # Leave the sound stuff in the modules file ## get rid of the sound in the modules for the nfs root ###egrep -v "sound|adlib" $BASE_DIR/vncroot/etc/modules.conf \ ### > $BASE_DIR/vncroot/etc/modules.conf.$$ ###mv -f $BASE_DIR/vncroot/etc/modules.conf.$$ \ ### $BASE_DIR/vncroot/etc/modules.conf ## # etc/inetd.conf ## echo "Fixing etc/inetd.conf file" sed -e "s|^#tftp|tftp|" $BASE_DIR/etc/inetd.conf > $BASE_DIR/etc/inetd.conf.$$ mv -f $BASE_DIR/etc/inetd.conf.$$ $BASE_DIR/etc/inetd.conf ## # vncroot/etc/rc.d/init.d/xntpd ## # Work around a bug with some units which get a time prior to the epoch # ie, time < Dec. 31, 1969 echo "Fixing vncroot/etc/rc.d/init.d/xntpd" sed -e 's/\/usr\/sbin\/ntpdate/date 0531000000\ \/usr\/sbin\/ntpdate/' $BASE_DIR/vncroot/etc/rc.d/init.d/xntpd \ > $BASE_DIR/vncroot/etc/rc.d/init.d/xntpd.$$ mv -f $BASE_DIR/vncroot/etc/rc.d/init.d/xntpd.$$ \ $BASE_DIR/vncroot/etc/rc.d/init.d/xntpd chmod +x $BASE_DIR/vncroot/etc/rc.d/init.d/xntpd ## # etc/rc.d/init.d/dhcpd ## echo "Fixing etc/rc.d/init.d/dhcpd" sed -e "s|eth0|eth1|" $BASE_DIR/etc/rc.d/init.d/dhcpd > $BASE_DIR/etc/rc.d/init.d/dhcpd.$$ sed -e "s|daemon /usr/sbin/dhcpd|daemon /usr/sbin/dhcpd -lf /var/state/dhcpd/dhcpd.leases -cf /etc/dhcpd.conf eth1|" $BASE_DIR/etc/rc.d/init.d/dhcpd.$$ > $BASE_DIR/etc/rc.d/init.d/dhcpd mkdir -p $BASE_DIR/var/state/dhcpd touch $BASE_DIR/var/state/dhcpd/dhcpd.leases rm -f $BASE_DIR/etc/rc.d/init.d/dhcpd.$$ chmod +x $BASE_DIR/etc/rc.d/init.d/dhcpd ## # vncroot/etc/inittab ## echo "Fixing vncroot/etc/inittab" sed -e "s|1:2345:respawn:/sbin/mingetty tty1|1:2345:respawn:/usr/bin/perl /root/install >/dev/tty1 /dev/tty1|" \ $BASE_DIR/vncroot/etc/inittab > $BASE_DIR/vncroot/etc/inittab.$$ sed -e "s|2:2345:respawn:/sbin/mingetty tty2|2:2345:off:/sbin/mingetty tty2|" \ $BASE_DIR/vncroot/etc/inittab.$$ > $BASE_DIR/vncroot/etc/inittab rm -f $BASE_DIR/vncroot/etc/inittab.$$ ## # vncroot/etc/shadow ## echo "Fixing root password in vncroot/etc/shadow" egrep -v "^root" $BASE_DIR/vncroot/etc/shadow > $BASE_DIR/vncroot/etc/shadow.$$ # set the root password in the vncroot (nfs root) to rebel echo "root:Vy5KPCVEBwBLk:10917:0:99999:7:-1:-1:33620176" > \ $BASE_DIR/vncroot/etc/shadow cat $BASE_DIR/vncroot/etc/shadow.$$ >> $BASE_DIR/vncroot/etc/shadow ## # etc/shadow etc/passwd ## echo "Fixing etc/passwd and etc/shadow adding service user" chroot /mnt/hda1 adduser service egrep -v "^root|^service" $BASE_DIR/etc/shadow > $BASE_DIR/etc/shadow.$$ # set the root password This is a private password see Rod Stewart # you don't actually need to know it echo "root:Vy5KPCVEBwBLk:10917:0:99999:7:-1:-1:33620176" > \ $BASE_DIR/etc/shadow cat $BASE_DIR/etc/shadow.$$ >> $BASE_DIR/etc/shadow # set the root password This is a private password see Rod Stewart # you don't actually need to know it echo "service:Vy5KPCVEBwBLk:10917:0:99999:7:-1:-1:33620176" >> \ $BASE_DIR/etc/shadow # add in minicom user # use minicom with color on and use the Meta-Z key sequence echo -e '#!/bin/sh\n\n'\ '/usr/bin/minicom -c on -m\n' > $BASE_DIR/usr/bin/minicom-user chmod 755 $BASE_DIR/usr/bin/minicom-user chmod 666 $BASE_DIR/dev/ttyS0 chroot /mnt/hda1 adduser -s /usr/bin/minicom-user minicom chroot /mnt/hda1 passwd -d minicom ## # etc/minirc.dfl ## echo -e '# Machine-generated file - use "minicom -s" to change parameters.\n'\ 'pu baudrate 115200\n'\ 'pu rtscts No\n'\ 'pu mbcolor BLUE\n'\ 'pu sound No' > $BASE_DIR/etc/minirc.dfl ## # etc/rc.d/rc.sysinit ## echo "fix etc/rc.d/rc.sysinit" # if checking harddrive pass -y to fsck sed -e 's|initlog -c "fsck| initlog -c "fsck -y |' \ $BASE_DIR/etc/rc.d/rc.sysinit \ > $BASE_DIR/etc/rc.d/rc.sysinit.$$ mv -f $BASE_DIR/etc/rc.d/rc.sysinit.$$ \ $BASE_DIR/etc/rc.d/rc.sysinit chmod a+x $BASE_DIR/etc/rc.d/rc.sysinit ## # vncroot/etc/rc.d/rc.sysinit ## echo "fix vncroot/etc/rc.d/rc.sysinit" sed -e 's|^# Add /proc to /etc/mtab|\ # Get rid of any old mtab* files\ rm -fr /etc/mtab* \ \ # Add /proc to /etc/mtab|' \ $BASE_DIR/vncroot/etc/rc.d/rc.sysinit \ > $BASE_DIR/vncroot/etc/rc.d/rc.sysinit.$$ mv -f $BASE_DIR/vncroot/etc/rc.d/rc.sysinit.$$ \ $BASE_DIR/vncroot/etc/rc.d/rc.sysinit chmod a+x $BASE_DIR/vncroot/etc/rc.d/rc.sysinit ## # nfsflash/tmp/nfsflash_cmdline ## echo "Fixing nfsflash/tmp/nfsflash_cmdline to boot off the correct server" sed -e "s|192.168.4|192.168.$SERVER_NO|" \ $BASE_DIR/nfsflash/tmp/nfsflash_cmdline | \ sed -e "s|192.168.4|192.168.$SERVER_NO|" | \ sed -e "s|192.168.4|192.168.$SERVER_NO|" \ > $BASE_DIR/nfsflash/tmp/nfsflash_cmdline.$$ mv -f $BASE_DIR/nfsflash/tmp/nfsflash_cmdline.$$ \ $BASE_DIR/nfsflash/tmp/nfsflash_cmdline ## # vncroot/etc/rc.d/rc.local ## echo "Removing the welecom sound in vncroot/etc/rc.d/rc.local file" ## get rid of the sound playing egrep -v "etc/welcome.au" $BASE_DIR/vncroot/etc/rc.d/rc.local \ > $BASE_DIR/vncroot/etc/rc.d/rc.local.$$ mv -f $BASE_DIR/vncroot/etc/rc.d/rc.local.$$ \ $BASE_DIR/vncroot/etc/rc.d/rc.local chmod a+x $BASE_DIR/vncroot/etc/rc.d/rc.local ## # vncroot/sbin/fsck.nfs ## echo "Creating vncroot/sbin/fsck.nfs" echo -e '#!/bin/sh\n\n'\ '/bin/true' > $BASE_DIR/vncroot/sbin/fsck.nfs chmod a+x $BASE_DIR/vncroot/sbin/fsck.nfs mkdir -p $BASE_DIR/vncroot/mnt/hda1 mkdir -p $BASE_DIR/vncroot/mnt/hda2 mkdir -p $BASE_DIR/vncroot/mnt/hda3 mkdir -p $BASE_DIR/vncroot/mnt/hda4 mkdir -p $BASE_DIR/vncroot/mnt/ftp mkdir -p $BASE_DIR/vncroot/server-root ## # Removing running of redundant services ## echo "Removing running of redundant services" chroot /mnt/hda1 chkconfig --level 35 sendmail off chroot /mnt/hda1 chkconfig --level 35 atd off chroot /mnt/hda1 chkconfig --level 35 xfs off chroot /mnt/hda1 chkconfig --level 35 xntpd on chroot /mnt/hda1/vncroot chkconfig --level 35 sendmail off chroot /mnt/hda1/vncroot chkconfig --level 35 atd off chroot /mnt/hda1/vncroot chkconfig --level 35 nfs off chroot /mnt/hda1/vncroot chkconfig --level 35 netfs off chroot /mnt/hda1/vncroot chkconfig --level 35 crond off chroot /mnt/hda1/vncroot chkconfig --level 35 inet off chroot /mnt/hda1/vncroot chkconfig --level 35 gpm off chroot /mnt/hda1/vncroot chkconfig --level 35 syslog off # make certain xntpd is running chroot /mnt/hda1 chkconfig --level 35 xntpd on chroot /mnt/hda1/vncroot chkconfig --level 35 xntpd on exit 0