diff options
| author | Simon Rettberg | 2013-05-23 20:17:35 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2013-05-23 20:17:35 +0200 |
| commit | 1730d8632bd7ad8899fa0396f6f872ff8607462a (patch) | |
| tree | f76a8c7cf8a3d7669561f427565a2ad78af8861f | |
| parent | Remove ldap in initial nsswitch conf, will be added after udev started up (diff) | |
| parent | fix MAC address for itnerface naming for udev (diff) | |
| download | tm-scripts-1730d8632bd7ad8899fa0396f6f872ff8607462a.tar.gz tm-scripts-1730d8632bd7ad8899fa0396f6f872ff8607462a.tar.xz tm-scripts-1730d8632bd7ad8899fa0396f6f872ff8607462a.zip | |
Merge branch 'master' of simonslx:openslx-ng/tm-scripts
Conflicts:
remote/modules/pam/data/etc/nsswitch.conf
| -rwxr-xr-x | data/openslx-ng-install | 91 | ||||
| -rwxr-xr-x | remote/rootfs/rootfs-stage31/data/bin/setup_network | 42 | ||||
| -rwxr-xr-x | remote/rootfs/rootfs-stage31/data/init | 99 | ||||
| -rw-r--r-- | remote/rootfs/rootfs-stage32/rootfs-stage32.conf.zypper | 8 |
4 files changed, 173 insertions, 67 deletions
diff --git a/data/openslx-ng-install b/data/openslx-ng-install index 0e71684e..7b8715b7 100755 --- a/data/openslx-ng-install +++ b/data/openslx-ng-install @@ -202,6 +202,97 @@ if [ "x$1" != "x--test" ] && check_password "root" "openslx-ng"; then done fi +print "" +print "Beginne Installation" + +# +# ---- Compile iPXE ---- +# +print "" +print "Erstelle iPXE Binary..." +sleep 3 +cd /opt/openslx/ipxe || error "cd /opt/openslx/ipxe failed" +cat > ipxelinux.ipxe << HEREEND +#!ipxe +set use-cached 1 +dhcp net0 +set net0.dhcp/next-server $SLX_LOCAL_ADDR +set net0.dhcp/filename ipxelinux.0 +imgload pxelinux.0 +boot pxelinux.0 +HEREEND +cd src || error "cd src failed" +[ -e "bin/undionly.kkkpxe" ] && unlink "bin/undionly.kkkpxe" +make bin/undionly.kkkpxe EMBED=../ipxelinux.ipxe,../pxelinux.0 +[ ! -e "bin/undionly.kkkpxe" -o "$(stat -c %s "bin/undionly.kkkpxe")" -lt 80000 ] && error "Error compiling ipxelinux.0" +cp "bin/undionly.kkkpxe" "/srv/openslx/tftp/ipxelinux.0" || error "Could not write to /srv/openslx/tftp/ipxelinux.0" + +# +# +# +if [[ "$SLX_VM_NFS_TYPE" == "L" ]]; then + # Write SMB Config +cat > "/etc/samba/smb.conf" << HEREEND +[global] + +workgroup = WORKGROUP +server string = OpenSLX-NG Test-Server + +wins support = no +dns proxy = no +name resolve order = host + +log file = /var/log/samba/log.%m +max log size = 100 +syslog only = no +syslog = 0 + +panic action = /usr/share/samba/panic-action %d + +security = user +encrypt passwords = true +passdb backend = tdbsam +obey pam restrictions = yes + +domain master = no + +[images] + comment = Directory where all the VMWare Images go + writeable = yes + locking = no + path = $SLX_VM_PATH + guest ok = no + valid users = vmware +HEREEND + # End SMB Config + chown -R vmware "$SLX_VM_PATH" + # NFS Config + echo "$SLX_VM_PATH *(ro,async,insecure,no_root_squash,no_subtree_check)" > "/etc/exports" + # End NFS Config + service samba restart + service nfs-kernel-server restart + # TODO: Persistent inbound blocking of tcp 139, udp 137,138 to speed up access from Windows Clients + update-rc.d samba defaults + update-rc.d nfs-kernel-server defaults +else # external NFS Server for VM Images is used. Disable NFS + Samba + service samba stop + service nfs-kernel-server stop + for LEVEL in S 0 1 2 3 4 5; do + update-rc.d samba disable "$LEVEL" + update-rc.d nfs-kernel-server disable "$LEVEL" + done +fi + +# +# ---- Create boottime system config ---- +# +print "" +print "Schreibe Bootzeit-Konfiguration für MiniLinux" +cat > "/srv/openslx/www/config" << HEREEND +SLX_VM_NFS='$SLX_VM_NFS' +HEREEND + SLX_LAST_INVOCATION="$(date)" save_defaults +print "Einrichtung abgeschlossen." diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_network b/remote/rootfs/rootfs-stage31/data/bin/setup_network new file mode 100755 index 00000000..32c1d5ef --- /dev/null +++ b/remote/rootfs/rootfs-stage31/data/bin/setup_network @@ -0,0 +1,42 @@ +#!/bin/sh + +echo "Mac address is '$MAC'" + +# setup network +NWIF="eth0" +# set up loopback networking +echo "Setting up loopback" +ip link set dev lo up 2>/dev/null +ip addr add 127.0.0.1/8 dev lo 2>/dev/null +echo "Setting up $NWIF" +ip link set dev $NWIF up 2>/dev/null || { echo "No link for $NWIF, dropping to shell.."; setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'; } + +# analyze ip information from the kernel command line and put parts +# of it into several variables +if [ -n "$IPINFO" ] ; then + getip () { + local val="$IPINFO:"; i=$(($1 - 1)); + while [ $i -gt 0 ] ; do + val=${val#*:} ; i=$(($i - 1)); + done; + echo $val|sed "s/:.*//"; + } + clientip=$(getip 1) + serverip=$(getip 2) + gateway=$(getip 3) + subnet_mask=$(getip 4) + broadcast_address=$(ipcalc -s -b $clientip $subnet_mask|sed s/.*=//) + [ -z "$broadcast_address" ] && broadcast_address=255.255.255.255 + # we might have an idea of the dns server via preboot + dns_srv=$(getip 5) + [ -n "$dns_srv" ] && echo nameserver $dns_srv >/etc/resolv.conf; + echo -e "# ip configuration written by $0 script:\nclientip=$clientip\n\ +subnet_mask=$subnet_mask\ngateway=$gateway\nserverip=$serverip\n\ +broadcast_address=$broadcast_address" >>/etc/initramfs-setup + # set static ip address + ip addr add $clientip/$(ipcalc -s -p $clientip $subnet_mask|sed s/.*=//) \ + broadcast $broadcast_address dev $NWIF 2>/dev/null + ip route add default via $gateway 2>/dev/null +else + NOIPYET="yes" +fi diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index 9bda6db1..84d1bcef 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -12,20 +12,25 @@ # First script for initial ramfs for OpenSLX linux stateless clients ############################################################################# +# debug shell +drop_shell() { + echo "Dropping debug shell. CTRL + D will continue booting." + setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1' +} + +# set PATH correctly export PATH=/bin:/sbin:/usr/bin:/usr/sbin export LD_LIBRARY_PATH=/usr/lib64 - -mount -n -t tmpfs -o 'mode=755' run "/run" - # mount the important standard directories +mount -n -t tmpfs -o 'mode=755' run "/run" [ ! -f /proc/cpuinfo ] && mount -n -t proc proc /proc [ ! -d /sys/class ] && mount -n -t sysfs sysfs /sys -echo "1" > /proc/sys/kernel/sysrq +# let kernel know that mdev is to be used for hotplug echo "/sbin/mdev" > /proc/sys/kernel/hotplug -# read graphic and network adaptor configuration (without proprietary drivers yet) +# read graphic and network adaptor configuration (without proprietary drivers yet) # TODO: must ugly hack ever... needs to be improved when we add prop drivers for DRM in /lib/modules/*/kernel/drivers/gpu/drm/*.ko /lib/modules/*/kernel/drivers/gpu/drm/*/*.ko; do DRM="$(basename "$DRM")" @@ -34,6 +39,9 @@ for DRM in /lib/modules/*/kernel/drivers/gpu/drm/*.ko /lib/modules/*/kernel/driv modprobe "$DRM" done +# discover devices +mdev -s & + # read kernel command line for debugging switch DEBUG=0 read KCL < /proc/cmdline @@ -46,82 +54,43 @@ for opts in ${KCL}; do SPLASH=1 ;; ip=*) # process IP info - ipinfo=${opts#ip=} ;; + IPINFO=${opts#ip=} ;; nfs=*) - nfs=${opts#nfs=} - nfspath=${nfs#*:} - nfsserver=${nfs%:/*} + NFS=${opts#nfs=} + NFSPATH=${nfs#*:} + NFSSERVER=${nfs%:/*} ;; BOOTIF=*) - macaddr="$( echo "$opts" | cut -b 11- | tr '-' ':' )" ;; + MAC="$( echo "$opts" | cut -b 11- | tr '-' ':' )" ;; esac done -echo "Mac address is '$macaddr'" - -mdev -s & +# suppress kernel output if DEBUG is not set +[ $DEBUG -ge 1 ] && echo "0" >/proc/sys/kernel/printk +# start plymouth if activated if [ "x$SPLASH" == "x1" -a "x$DEBUG" != "x1" ]; then - # start plymouth + echo "Starting plymouth..." plymouthd && plymouth show-splash fi -# setup network -nwif="eth0" -# set up loopback networking -echo "Setting up loopback" -ip link set dev lo up 2>/dev/null -ip addr add 127.0.0.1/8 dev lo 2>/dev/null -echo "Setting up $nwif" -ip link set dev $nwif up 2>/dev/null || { echo "No link for $nwif, dropping to shell.."; setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'; } - -# analyze ip information from the kernel command line and put parts -# of it into several variables -if [ -n "$ipinfo" ] ; then - getip () { - local val="$ipinfo:"; i=$(($1 - 1)); - while [ $i -gt 0 ] ; do - val=${val#*:} ; i=$(($i - 1)); - done; - echo $val|sed "s/:.*//"; } - clientip=$(getip 1) - serverip=$(getip 2) - gateway=$(getip 3) - subnet_mask=$(getip 4) - broadcast_address=$(ipcalc -s -b $clientip $subnet_mask|sed s/.*=//) - [ -z "$broadcast_address" ] && broadcast_address=255.255.255.255 - # we might have an idea of the dns server via preboot - dns_srv=$(getip 5) - [ -n "$dns_srv" ] && echo nameserver $dns_srv >/etc/resolv.conf; - echo -e "# ip configuration written by $0 script:\nclientip=$clientip\n\ -subnet_mask=$subnet_mask\ngateway=$gateway\nserverip=$serverip\n\ -broadcast_address=$broadcast_address" >>/etc/initramfs-setup - # set static ip address - ip addr add $clientip/$(ipcalc -s -p $clientip $subnet_mask|sed s/.*=//) \ - broadcast $broadcast_address dev $nwif 2>/dev/null - ip route add default via $gateway 2>/dev/null -else - noipyet="yes" -fi - +# preparations for mounting stage3.2 mkdir -p /dev/shm/union /dev/shm/uniontmp /rorootfs mount -n -t tmpfs none /dev/shm/uniontmp -if [ -n "$nfs" ] ; then - echo "Mounting stage 3.2 as NFS" - mount -t nfs -o ro,async,nolock ${nfsserver}:${nfspath} /rorootfs || { echo "Problem mounting NFS-Directory from ${nfsserver}:${nfspath}. Dropping to DEBUG shell."; DEBUG=1; } +# mount stage32 per NFS if activated +# or per squashfs else +if [ -n "$NFS" ]; then + echo "Setup networking..." + /bin/setup_network + echo "Mounting stage 3.2 as NFS..." + mount -t nfs -o ro,async,nolock ${NFSSERVER}:${NFSPATH} /rorootfs || { echo "Problem mounting NFS-Directory from ${NFSSERVER}:${NFSPATH}."; drop_shell; } else - echo "Mounting stage 3.2 as SquashFS" - mount -t squashfs /mnt/*.sqfs /rorootfs || { echo "Problem mounting Squashfs. Dropping to DEBUG shell."; DEBUG=1; } + echo "Mounting stage 3.2 as SquashFS..." + mount -t squashfs /mnt/*.sqfs /rorootfs || { echo "Problem mounting Squashfs."; drop_shell; } fi -if [ $DEBUG -ge 1 ]; then - echo "Starting debug shell, CTRL + D will start Stage 3.2." - setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1' -else - #Debug is not set so hide kernel debug output - echo "0" >/proc/sys/kernel/printk -fi +[ $DEBUG -ge 1 ] && drop_shell echo "Building aufs..." mv /mnt/modprobing /dev/shm/uniontmp @@ -131,7 +100,7 @@ mkdir -p /mnt/uniontmp /mnt/tmp mount -n --move /dev/shm/uniontmp /mnt/uniontmp # create udev rule for nic we booted from -echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$macaddr'", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"' > "/mnt/etc/udev/rules.d/70-net-boot-nic-name.rules" +echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$MAC'", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"' > "/mnt/etc/udev/rules.d/70-net-boot-nic-name.rules" for mnt in proc sys run ; do umount -n $mnt diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.zypper b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.zypper index dbbd4697..3f7f446e 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.zypper +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.zypper @@ -26,7 +26,10 @@ REQUIRED_BINARIES=" bash scp ssh tput - xterm" + xterm + xvidtune + bc + dirname" REQUIRED_LIBRARIES=" libcap libcidn libcom_err @@ -55,7 +58,8 @@ REQUIRED_FILES=" /etc/environment /etc/protocols /etc/services /etc/networks - /etc/netconfig" + /etc/netconfig + /usr/share/X11/app-defaults/Xvidtune" REQUIRED_KERNEL_MODULES=" kernel/drivers/cpufreq kernel/drivers/memstick kernel/drivers/mfd |
