diff options
author | Jonathan Bauer | 2013-05-07 19:33:11 +0200 |
---|---|---|
committer | Jonathan Bauer | 2013-05-07 19:33:11 +0200 |
commit | 6bf5335415273aaef78ed0a5782fde72ab646f62 (patch) | |
tree | f432fefc26d33033c28043790f8840df1947597a | |
parent | added '-openslx' suffix to kernel version to distinguish it from regular vers... (diff) | |
download | tm-scripts-6bf5335415273aaef78ed0a5782fde72ab646f62.tar.gz tm-scripts-6bf5335415273aaef78ed0a5782fde72ab646f62.tar.xz tm-scripts-6bf5335415273aaef78ed0a5782fde72ab646f62.zip |
dhcp service now requests same IP if he got one previously
-rw-r--r-- | helper/fileutil.inc | 6 | ||||
-rw-r--r-- | remote/modules/systemd/data/etc/systemd/system/activate-swap | 30 | ||||
-rw-r--r-- | remote/modules/systemd/data/etc/systemd/system/analyse-disk.sh | 120 | ||||
-rw-r--r-- | remote/modules/systemd/data/etc/systemd/system/fetch-config | 178 | ||||
-rw-r--r-- | remote/modules/systemd/data/etc/systemd/system/ip-dns-conf | 86 | ||||
-rw-r--r-- | remote/modules/systemd/data/etc/systemd/system/udhcpc@.service | 2 | ||||
-rwxr-xr-x | remote/rootfs/rootfs-stage31/data/init | 2 | ||||
-rw-r--r-- | remote/rootfs/rootfs-stage32/data/opt/openslx/bin/dhcp++ | 13 | ||||
-rwxr-xr-x | remote/rootfs/rootfs-stage32/data/opt/openslx/bin/mountexport (renamed from remote/rootfs/rootfs-stage32/data/usr/sbin/mountexport) | 0 | ||||
-rwxr-xr-x | server/export_target | 2 |
10 files changed, 20 insertions, 419 deletions
diff --git a/helper/fileutil.inc b/helper/fileutil.inc index d37d546e..24b50a5f 100644 --- a/helper/fileutil.inc +++ b/helper/fileutil.inc @@ -132,7 +132,8 @@ generate_initramfs() { [ "x${PS[1]}" != "x0" ] && perror "cpio create failed." [ "x${PS[2]}" != "x0" ] && perror "gzip to '$3' failed." cd - &> /dev/null - pinfo "Created initramfs of $1 at $3. Size: $(du -bsh "$3" | awk 'END {print $1}')" + pinfo "Created initramfs of $1 at $3" + pinfo "Size: $(du -bsh "$3" | awk 'END {print $1}')" } # generates squashfs of directory @@ -143,5 +144,6 @@ generate_squashfs() { [ -d "$1" ] || perror "$1 is not a directory." mksquashfs "$1" "$2" -comp xz -b 1M -no-recovery >&6 \ || perror "mksquashfs failed ($?)." - pinfo "Created squashfs of $1 at $2. Size: $(du -bsh "$2" | awk 'END {print $1}')" + pinfo "Created squashfs of $1 at $2" + pinfo "Size: $(du -bsh "$2" | awk 'END {print $1}')" } diff --git a/remote/modules/systemd/data/etc/systemd/system/activate-swap b/remote/modules/systemd/data/etc/systemd/system/activate-swap deleted file mode 100644 index 10cb42e9..00000000 --- a/remote/modules/systemd/data/etc/systemd/system/activate-swap +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# Copyright (c) 2013 - OpenSLX GmbH -# -# This program is free software distributed under the GPL version 2. -# See http://openslx.org/COPYING -# -# If you have any feedback please consult http://openslx.org/feedback and -# send your feedback to feedback@openslx.org -# -# General information about OpenSLX can be found under http://openslx.org -# -# Initialize swap for OpenSLX linux stateless clients, both for swap on local -# disk partitions as well as compressed ramzswap or similar - -############################################################################# - -# depends on mount-disk.sh -# depends on availability of the appropriate kernel module/functionality - -# try to enable compressed RAM SWAP / ZRAM -if modprobe ${MODPRV} ramzswap 2>/dev/null && [ -f /usr/bin/rzscontrol ] ; then - rzscontrol /dev/ramzswap0 --init - swapon /dev/ramzswap0 2>/dev/null - #hdswap="# disk swap disabled because of enabled compressed ramswap" -elif modprobe ${MODPRV} zram 2>/dev/null ; then - # assign a quarter of total mem to zram - echo $(( $(free -k | awk '/^Mem:/ { print $2 }') * 256 )) > /sys/block/zram0/disksize - mkswap /dev/zram0 2>/dev/null - swapon /dev/zram0 2>/dev/null -fi diff --git a/remote/modules/systemd/data/etc/systemd/system/analyse-disk.sh b/remote/modules/systemd/data/etc/systemd/system/analyse-disk.sh deleted file mode 100644 index 0c152dbf..00000000 --- a/remote/modules/systemd/data/etc/systemd/system/analyse-disk.sh +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/sh -# Copyright (c) 2013 - OpenSLX GmbH -# -# This program is free software distributed under the GPL version 2. -# See http://openslx.org/COPYING -# -# If you have any feedback please consult http://openslx.org/feedback and -# send your feedback to feedback@openslx.org -# -# General information about OpenSLX can be found under http://openslx.org -# -# Local hard disk autoconfiguration script for OpenSLX linux stateless -# clients, detecting swap and special partitions - -############################################################################# - -# Todo: -# * This script should be run just once per boot! -# * The activation of swap could/should be handled in separate script!? -# * The mounting of /tmp could/should be done separately? -# * Same for other partitions, use information of /etc/fstab for that? -# * Should we just install xfs in the source system and boil down everything -# onto that? - -# General formatter for the /tmp partition on a local harddisk -diskfm () { -local target=$1 -local mntpnt=$2 -local fs -local path -for fs in xfs reiserfs ext2 ; do - if strinfile "$fs" /proc/filesystems || modprobe ${MODPRV} $fs ; then - unset $found - for path in /sbin /bin /usr/sbin /usr/bin ; do - if test -x /mnt/$path/mkfs.$fs ; then - found=yes - case mkfs.$fs in - mkfs.xfs) - fopt="-f" - mopt="-o noexec" - ;; - mkfs.ext2) - fopt="-Fq" - mopt="-o nocheck,noexec" - ;; - mkfs.reiserfs) - fopt="-f" - mopt="-o noexec" - ;; - esac - mkfs.$fs $fopt $target >/dev/null 2>&1 #|| error - if [ -z $mntpnt ] ; then - umount /tmp 2>/dev/null - if mount -t $fs -n $mopt $target /tmp 2>/dev/null; then - return 0 - else - mount -n -t tmpfs none /tmp - fi - else - mkdir -p $mntpnt - mount -t $fs -n -o loop $target $mntpnt 2>/dev/null - return 0 - fi - fi - done - [ -z $found ] && continue - else break - fi -done -} - -# Check for local harddisks and appropriate partitions -fdisk -l /dev/$hd|sed -n "/^\/dev\//p" >/etc/disk.partition - -# Check for standard swap partitions and make them available to the system -for hdpartnr in $(cat /etc/disk.partition | \ - sed -n -e "/ 82 /p"|sed -e "s/[[:space:]].*//") ; do - echo -e "$hdpartnr\tswap\t\tswap\t\tdefaults\t 0 0" >>/etc/fstab -done - -# We use special non assigned partition type (id44) for harddisk scratch -# space, thus no normal filesystem will be incidentally deleted or -# corrupted -for hdpartnr in $(cat /etc/disk.partition | \ - sed -n -e "/ 44 /p"|sed -e "s/[[:space:]].*//") ; do - # check for supported filesystem and formatter - ( if diskfm $hdpartnr ; then - echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready - echo -e "$hdpartnr\t/tmp\t\tauto\t\tdefaults\t 0 0" >>/etc/fstab - else - echo "formatting failed for some reason ($(sysup))" >/tmp/tmpready - fi ) & - break -done - -# Put detected linux partitions (83) into /etc/fstab with "noauto", special -# partition 45 (persistent scratch) to /var/scratch and 46 to /var/openslx -for partid in 83 45 46 ; do - for hdpartnr in $(cat /etc/disk.partition | \ - sed -n -e "/ ${partid} /p"|sed -e "s/[[:space:]].*//") ; do - mkdir -p /media/${hdpartnr#/dev/*} 2>/dev/null - if [ ${partid} -eq 83 ] ; then - echo -e "$hdpartnr\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,\ -noexec\t 0 0" >>/tmp/fstab - elif [ ${partid} -eq 45 ] ; then - #mount -t auto ${hdpartnr} /media/${hdpartnr#/dev/*} - #ln -sf /media/${hdpartnr#/dev/*} /var/scratch - echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\ -\t\t 0 0" >>/tmp/fstab - elif [ ${partid} -eq 46 ] ; then - # Mount a home directory to (/mnt)/var/home - #mount -t auto ${hdpartnr} /mnt/media/${hdpartnr#/dev/*} \n\ - #test -d /mnt/media/${hdpartnr#/dev/*}/home && \ - # ln -sf /media/${hdpartnr#/dev/*} /var/home - echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\ -\t\t 0 0" >>/tmp/fstab - fi - done -done - diff --git a/remote/modules/systemd/data/etc/systemd/system/fetch-config b/remote/modules/systemd/data/etc/systemd/system/fetch-config deleted file mode 100644 index 556f0f41..00000000 --- a/remote/modules/systemd/data/etc/systemd/system/fetch-config +++ /dev/null @@ -1,178 +0,0 @@ -#!/bin/sh -# Copyright (c) 2013 - OpenSLX GmbH -# -# This program is free software distributed under the GPL version 2. -# See http://openslx.org/COPYING -# -# If you have any feedback please consult http://openslx.org/feedback and -# send your feedback to feedback@openslx.org -# -# General information about OpenSLX can be found under http://openslx.org -# -# Fetch configuration from server ... - -############################################################################# - -# Depends on configured networking, provides configuration - - -# Todo: rewrite for next-gen system - principle would be the same ... - -# Function for retrieving configuration file (machine-setup) via tftp from a -# predefined server or given source (file=tftp-server:/path via kernel -# command line) -unpack () { -# $1 is config file name to get, $2 IP of server to get file from -local dst=$1 -if [ -s $dst ] ; then - # fixme: handle different types of packaging (gzip/bzip2)?? - if ! tar -xpzf $dst 2> /tmp/ConfTGZ-tar-error ; then - cat /tmp/ConfTGZ-tar-error - error "$unpack_ConfTGZ" nonfatal - rm /tmp/ConfTGZ-tar-error - fi - [ "$DEBUGLEVEL" -le 2 -o "$DEBUGLEVEL" -eq 8 ] && rm $dst - return 0 -else - return 1 -fi -} - -# tftp wrapper -# usage tftp_get <path> <tftpdserver> [count] -# count is optional - default is 3 - use -1 for indefinit -tftp_get () { - local file="$1" - local file_server="$2" - local download_successful=0 - local countdown="$3" - - if [ -z "$1" -o -z "$2" ]; then - [ $DEBUGLEVEL -ge 1 ] && \ - echo "[tftp_get] Usage: tftp_get <path> <server> [count]" - return 1; - fi - - [ "$countdown" = "" ] && countdown=3 - - until [ $download_successful -eq 1 ] - do - if [ "$countdown" = "0" ]; then - [ $DEBUGLEVEL -ge 1 ] && \ - echo "[tftp_get] download of \"$file\" from \"$file_server\" ... failed" - return 0; - fi - tftp -g -r "/$file" -l /tmp/$(basename $file) $file_server - [ -s /tmp/$(basename $file) ] && download_successful=1 - countdown=$(expr $countdown - 1) - usleep 200000 - done - [ $DEBUGLEVEL -ge 1 ] && \ - echo "[tftp_get] download of \"$file\" from \"$file_server\" ... successful" - return 0; -} - - -# wget wrapper -# usage wget_get <path> <ftp/httpserver> [count] -# count is optional - default is 3 - use -1 for indefinit -wget_get () { - local file="$1" - local file_server="$2" - local download_successful=0 - local countdown="$3" - - if [ -z "$1" -o -z "$2" ]; then - [ $DEBUGLEVEL -ge 1 ] && \ - echo "[wget_get] Usage: wget_get <path> <server> [count]" - return 1; - fi - - [ "$countdown" = "" ] && countdown=3 - - until [ $download_successful -eq 1 ] - do - if [ "$countdown" = "0" ]; then - [ $DEBUGLEVEL -ge 1 ] && \ - echo "[wget_get] download of \"$file\" from \"$file_server\" ... failed" - return 0; - fi - wget -q $file_server$file -O /tmp/$(basename $file) - [ -s /tmp/$(basename $file) ] && download_successful=1 - countdown=$(expr $countdown - 1) - usleep 200000 - done - [ $DEBUGLEVEL -ge 1 ] && \ - echo "[wget_get] download of \"$file\" from \"$file_server\" ... successful" - return 0; -} - - -fileget () { -# normally tftp would be used, alternatively use wget for ftp or http -# if local device file is specified - mount and unmount after copying -local cfgfile -[ "x$fileprot" = "x" ] && fileprot=tftp -if [ "x$filepath" != "x" ] ; then - cfgfile=${filepath} - [ "x$fileserv" = "x" ] && fileserv=$(checkip ${serverip}) - # wait for dns if "fileserv" is a name and not lbd device - [ "$fileprot" != "lbd" ] && \ - echo ${fileserv} | grep -qi [a-z] - [ $DEBUGLEVEL -ge 1 ] && echo "fileget - fileprot:$fileprot, filepath:\ -$filepath, fileserv:$fileserv" >>$LOGFILE - case "$fileprot" in - ftp|http) - wget_get $cfgfile $fileprot://$fileserv \ - && { unpack /tmp/$(basename $cfgfile) && break; } 2>>$LOGFILE - ;; - lbd) - local ldev=$fileserv - echo "Waiting for configuration file ${cfgfile} ...." - [ $DEBUGLEVEL -ge 1 ] && echo "fileget - fileprot:$fileprot, filepath:\ -$filepath, fileserv:$fileserv" >>$LOGFILE - waitfor /mnt/${cfgfile} 10000 - if [ -f /mnt/${cfgfile} ]; then - unpack /mnt/$cfgfile - else - error "$init_errlfg" - fi - ;; - *) - tftp_get $cfgfile $fileserv \ - && unpack /tmp/$(basename $cfgfile) 2>>$LOGFILE - ;; - esac -else - # predefined value for OpenSLX environment; it is expected that this - # directory is just below the tftpboot (path to which the daemon is - # restricted to) - filepath="client-config" - [ "x$fileserv" = "x" ] && fileserv=$(checkip ${serverip}) - [ $DEBUGLEVEL -ge 1 ] && echo "fileget - fileprot:$fileprot, filepath:\ -$filepath, fileserv:$fileserv" >>$LOGFILE - # try to get configuration files successively; start with distro client - # and try last distro default ... - mac=$(echo $macaddr|sed "s/:/-/g") - for cfgfile in ${filepath}/${SYSTEM_NAME}/01-$mac.tgz \ - ${filepath}/${SYSTEM_NAME}/default.tgz ; do - case "$fileprot" in - ftp|http) - wget $fileprot://$fileserv/$cfgfile -O /tmp/$(basename $cfgfile) \ - 2>>$LOGFILE && { unpack /tmp/$(basename $cfgfile) && break; } - ;; - tftp) - tftp_get $cfgfile $fileserv \ - 2>>$LOGFILE && { unpack /tmp/$(basename $cfgfile) && break; } - ;; - esac - done - echo -e "\n## Configuration via fileget from ${fileprot}://${fileserv}/\ -${cfgfile}\n# Hierarchy is distro client and as last distro/default" \ - >>/tmp/confviafile -fi -cat /initramfs/machine-setup >>/tmp/confviafile 2>/dev/null || \ - error "$nomachsetup" -echo "fileget via $fileprot from $fileserv/$cfgfile finished" >/tmp/file-done -[ $DEBUGLEVEL -ge 1 ] && echo "fileget from $cfgfile finished" >>$LOGFILE -} diff --git a/remote/modules/systemd/data/etc/systemd/system/ip-dns-conf b/remote/modules/systemd/data/etc/systemd/system/ip-dns-conf deleted file mode 100644 index f14ecd88..00000000 --- a/remote/modules/systemd/data/etc/systemd/system/ip-dns-conf +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh -# Copyright (c) 2013 - OpenSLX GmbH -# -# This program is free software distributed under the GPL version 2. -# See http://openslx.org/COPYING -# -# If you have any feedback please consult http://openslx.org/feedback and -# send your feedback to feedback@openslx.org -# -# General information about OpenSLX can be found under http://openslx.org -# -# Set IP and DNS configuration ... - -############################################################################# - -# Depends on running network interface, provides IP and DNS configuration - -# Dns and ip configuration, hostname of the machine --> to be merged with udhcpc.default.script!! -echo "$host_name" >/proc/sys/kernel/hostname -echo -e "# /etc/hosts - file generated by $0 during OpenSLX stage3\ -\n#\n# IP-Address Full-Qualified-Hostname Short-Hostname\n#\n\ -127.0.0.1\tlocalhost\n::1\t\tlocalhost ipv6-localhost ipv6-loopback\n\ -fe00::0\t\tipv6-localnet\nff00::0\t\tipv6-mcastprefix\nff02::1\ -\t\tipv6-allnodes\nff02::2\t\tipv6-allrouters\nff02::3\t\t\ -ipv6-allhosts\n" >/etc/hosts -if [ -n "${domain_name}" ]; then - echo -en "${clientip}\t" >>/etc/hosts - for name in ${domain_name}; do - echo -en "${host_name}.${name} " >>/etc/hosts - done - echo -e "${host_name}" >>/etc/hosts -else - echo -e "${clientip}\t${host_name}" >>/etc/hosts -fi -# set up domainname and resolving -#rm -rf /etc/resolv.conf - -out=/etc/resolv.conf -echo -e "# /etc/resolv.conf - file generated by\n#\t$0:\n\ -#\t${date}\n#options timeout:1 attempts:1 rotate" > $out - -[ "x${domain_name}" != "x" ] && echo -e "domain ${domain_name}" >> $out -[ "x${domain_search}" != "x" ] && echo -e "search ${domain_search}" >> $out -# fallback -[ "x${domain_search}" == "x" ] && [ "x${domain_name}" != "x" ] && \ - echo -e "search ${domain_name}" >> $out - -[ -n "${domain_name_servers}" ] && { - for name in ${domain_name_servers}; do - echo nameserver ${name} >> $out; - done; } - -# Create hostname file -[ -n ${host_name} ] && [ -n ${domain_name} ] && \ - echo "${host_name}.${domain_name}" > /etc/hostname - - -# Set greeting and add information on booted system -len=$(expr length ${SLXVERSION}${SYSTEM_NAME}) -if [ $len -le 28 ] ; then - vdstr="Stateless Workstation (V${SLXVERSION}/${SYSTEM_NAME})" - smax=28 -else - vdstr="V${SLXVERSION}/${SYSTEM_NAME}" - smax=52 -fi -while [ $len -le $smax ] ; do - vdstr="$vdstr " - len=$(($len + 1)) -done -len=$(expr length ${host_name}) -while [ $len -le 30 ] ; do - space="$space " - len=$(($len + 1)) -done -echo " - WELCOME TO $space \n (\l) - _____ ______ ______ __ __ _______ __ __ __ - / _ | _ | ___| | | | | ____| | | | | | - | | | | |_| | |_ | | | | |___ | | / / - | | | | ___/| _| | | ____ | | | | - | |_| | | | |___| | | | ____| | |___ / / - _____/|__| |______|__| |__| |_______|______|__| |__| - - $vdstr (c) <OpenSLX.ORG> -" >/etc/issue diff --git a/remote/modules/systemd/data/etc/systemd/system/udhcpc@.service b/remote/modules/systemd/data/etc/systemd/system/udhcpc@.service index af4c70bb..db67c6b6 100644 --- a/remote/modules/systemd/data/etc/systemd/system/udhcpc@.service +++ b/remote/modules/systemd/data/etc/systemd/system/udhcpc@.service @@ -3,7 +3,7 @@ Description=DHCP Client [Service] Type=simple -ExecStart=/opt/openslx/sbin/udhcpc -O domain -O nissrv -O nisdomain -O wpad -t 8 -s /etc/udhcpc.openslx.script -i %I +ExecStart=/opt/openslx/bin/dhcp++ %I [Install] WantedBy=multi-user.target diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index 81b045b5..2e679dad 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -130,7 +130,7 @@ mkdir -p /mnt/uniontmp /mnt/tmp mount -n --move /dev/shm/uniontmp /mnt/uniontmp # create udev rule for nic we booted from -[ -e "/mnt/etc/udev/rules.d/70-net-boot-nic-name.rules" ] && 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}=="'$macaddr'", 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/data/opt/openslx/bin/dhcp++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/dhcp++ new file mode 100644 index 00000000..f3d1f76a --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/dhcp++ @@ -0,0 +1,13 @@ +#!/bin/bash + +export PATH=$PATH:/opt/openslx/bin:/opt/openslx/sbin:/opt/openslx/usr/bin:/opt/openslx/usr/sbin + +NET_IF=$1 +NET_IP=$(ip addr show dev ${NET_IF} | grep "inet " | awk -F " " '{print $2}' | awk -F "/" '{print $1}') + +echo "NET_IP: $NET_IP" >> /root/foo +echo "NET_IF: $NET_IF" >> /root/foo + +UDHCPC_OPTS="" +[ ! -z "$NET_IP" ] && UDHCPC_OPTS=" -r $NET_IP " +/opt/openslx/sbin/udhcpc $UDHCPC_OPTS -O domain -O nissrv -O nisdomain -O wpad -t 8 -s /etc/udhcpc.openslx.script -i $NET_IF diff --git a/remote/rootfs/rootfs-stage32/data/usr/sbin/mountexport b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/mountexport index cc08728e..cc08728e 100755 --- a/remote/rootfs/rootfs-stage32/data/usr/sbin/mountexport +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/mountexport diff --git a/server/export_target b/server/export_target index 80ffd7ae..f177bbfd 100755 --- a/server/export_target +++ b/server/export_target @@ -88,7 +88,7 @@ generate_addons() { export_target() { initial_checks -#copy_kernel +copy_kernel TARGET=$1 [ -d ${SERVER_BUILD_DIR}/${TARGET} ] || perror "Given target directory does not exist: ${SERVER_BUILD_DIR}/${TARGET}" |