From 195dc51a5a5c489f634feaec532679039d123ab4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 18:21:43 +0200 Subject: [setup_target] Make sure /var/run is just a symlink to /run --- remote/setup_target | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/remote/setup_target b/remote/setup_target index 60cf23b5..8160de3e 100755 --- a/remote/setup_target +++ b/remote/setup_target @@ -408,6 +408,20 @@ post_process_target() { ldconfig -v -r "${TARGET_BUILD_DIR}" -f "/ldconf-temp" unlink "$LDTEMP" + # Hacky way of making sure /run and /var/run are actually the same directory + local DIR_RUN="$TARGET_BUILD_DIR/run" + local DIR_VAR_RUN="$TARGET_BUILD_DIR/var/run" + [ -L "$DIR_RUN" ] && perror "$DIR_RUN is a symbolic link, refusing to work!" + if [ -d "$DIR_RUN" -o -d "$DIR_VAR_RUN" ]; then + mkdir -p "$DIR_RUN" || perror "Could not create $DIR_RUN" + if [ -d "$DIR_VAR_RUN" -a ! -L "$DIR_VAR_RUN" ]; then + mv "$DIR_VAR_RUN/"* "$DIR_RUN/" || perror "Could not move contents of $DIR_VAR_RUN to $DIR_RUN" + rmdir "$DIR_VAR_RUN" || perror "Could not delete $DIR_VAR_RUN after moving contents to $DIR_RUN" + fi + if [ ! -L "$DIR_VAR_RUN" ]; then + ln -sf "../run" "$DIR_VAR_RUN" || perror "Could not create symbolic link $DIR_VAR_RUN to ../run" + fi + fi } clean_modules() { -- cgit v1.2.3-55-g7522 From 5c209729e7e3fa4858513c525ff4c4bdad309519 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 18:22:48 +0200 Subject: [dnbd3] update requested commit --- remote/modules/dnbd3/dnbd3.build | 2 ++ remote/modules/dnbd3/dnbd3.conf | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/remote/modules/dnbd3/dnbd3.build b/remote/modules/dnbd3/dnbd3.build index 5dd2769f..e285788b 100644 --- a/remote/modules/dnbd3/dnbd3.build +++ b/remote/modules/dnbd3/dnbd3.build @@ -32,6 +32,8 @@ build() { cd "$MODULE_BUILD_DIR/opt/openslx/bin" || perror "Could not cd to build dir for client binary" cmake "$MODULE_DIR/src/dnbd3" || perror "Could not cmake" make dnbd3-client || perror "Could not make dnbd3-client" + chown root:root "dnbd3-client" + chmod +xs "dnbd3-client" cd "$MODULE_DIR" } diff --git a/remote/modules/dnbd3/dnbd3.conf b/remote/modules/dnbd3/dnbd3.conf index c1a3eb2e..31c411d0 100644 --- a/remote/modules/dnbd3/dnbd3.conf +++ b/remote/modules/dnbd3/dnbd3.conf @@ -2,7 +2,7 @@ #REQUIRED_CONTENT_PACKAGES="libgconf-2-4 fontconfig-config" REQUIRED_MODULES="kernel" REQUIRED_GIT="git://git.openslx.org/dnbd3.git" -REQUIRED_COMMIT="37868b9e5f7c26c61a928a61b7cc705eedb7e5a6" +REQUIRED_COMMIT="89a7af0ceb1cdc13f7d3a4ffac54f32576e1138d" REQUIRED_BINARIES=" dnbd3-client " -- cgit v1.2.3-55-g7522 From 42f3e47bc5124df57c30cdd127e9c01ae47d929b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 19:42:20 +0200 Subject: [dnbd3] add systemd service + script to load the module and launch the user space daemon --- .../dnbd3/data/etc/systemd/system/setup-dnbd3.service | 12 ++++++++++++ .../systemd/system/sysinit.target.wants/setup-dnbd3.service | 1 + .../dnbd3/data/opt/openslx/scripts/systemd-setup_dnbd3 | 9 +++++++++ 3 files changed, 22 insertions(+) create mode 100644 remote/modules/dnbd3/data/etc/systemd/system/setup-dnbd3.service create mode 120000 remote/modules/dnbd3/data/etc/systemd/system/sysinit.target.wants/setup-dnbd3.service create mode 100755 remote/modules/dnbd3/data/opt/openslx/scripts/systemd-setup_dnbd3 diff --git a/remote/modules/dnbd3/data/etc/systemd/system/setup-dnbd3.service b/remote/modules/dnbd3/data/etc/systemd/system/setup-dnbd3.service new file mode 100644 index 00000000..97f6703d --- /dev/null +++ b/remote/modules/dnbd3/data/etc/systemd/system/setup-dnbd3.service @@ -0,0 +1,12 @@ +[Unit] +Description=Setup dnbd3 kernel module and user space daemon +After=sysinit.target +Before=shutdown.target +DefaultDependencies=no + +[Service] +Type=service +ExecStart=/opt/openslx/scripts/systemd-setup_dnbd3 +ExecStop=/opt/openslx/bin/dnbd3-client --kill +ExecStopPost=/bin/rm /var/run/dnbd3.socket +Restart=on-abort diff --git a/remote/modules/dnbd3/data/etc/systemd/system/sysinit.target.wants/setup-dnbd3.service b/remote/modules/dnbd3/data/etc/systemd/system/sysinit.target.wants/setup-dnbd3.service new file mode 120000 index 00000000..05dd4ac2 --- /dev/null +++ b/remote/modules/dnbd3/data/etc/systemd/system/sysinit.target.wants/setup-dnbd3.service @@ -0,0 +1 @@ +../setup-dnbd3.service \ No newline at end of file diff --git a/remote/modules/dnbd3/data/opt/openslx/scripts/systemd-setup_dnbd3 b/remote/modules/dnbd3/data/opt/openslx/scripts/systemd-setup_dnbd3 new file mode 100755 index 00000000..9c76bfa6 --- /dev/null +++ b/remote/modules/dnbd3/data/opt/openslx/scripts/systemd-setup_dnbd3 @@ -0,0 +1,9 @@ +#!/bin/sh + +insmod /lib/modules/dnbd3/dnbd3.ko +[ -e "/dev/dnbd0" ] || exit 1 +for i in 0 1 2 3 4 5 6 7; do + echo 8192 > "/sys/block/dnbd${i}/queue/nr_requests" +done +exec -- dnbd3-client --daemon + -- cgit v1.2.3-55-g7522 From 5ecba3429f3c5d75550137eb2c815ebb62dfdffb Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 20:03:34 +0200 Subject: Switch to using /etc/tmpfiles.d for creating files/dirs in /run Also added a sanity check after processing each module, which will abort if anything is placed in /run directly --- remote/modules/kdm/data/etc/tmpfiles.d/kdm.conf | 2 ++ remote/modules/kdm/kdm.build | 1 - remote/modules/pam/data/etc/tmpfiles.d/pipefs.conf | 2 ++ remote/modules/pam/pam.build | 15 +-------------- .../modules/plymouth/data/etc/tmpfiles.d/plymouth.conf | 2 ++ remote/modules/plymouth/plymouth.conf | 3 ++- remote/modules/sshd/data/etc/tmpfiles.d/sshd.conf | 2 ++ remote/rootfs/rootfs-stage32/rootfs-stage32.build | 4 +++- remote/setup_target | 18 ++++-------------- 9 files changed, 18 insertions(+), 31 deletions(-) create mode 100644 remote/modules/kdm/data/etc/tmpfiles.d/kdm.conf create mode 100644 remote/modules/pam/data/etc/tmpfiles.d/pipefs.conf create mode 100644 remote/modules/plymouth/data/etc/tmpfiles.d/plymouth.conf create mode 100644 remote/modules/sshd/data/etc/tmpfiles.d/sshd.conf diff --git a/remote/modules/kdm/data/etc/tmpfiles.d/kdm.conf b/remote/modules/kdm/data/etc/tmpfiles.d/kdm.conf new file mode 100644 index 00000000..64f02ed3 --- /dev/null +++ b/remote/modules/kdm/data/etc/tmpfiles.d/kdm.conf @@ -0,0 +1,2 @@ +D /var/run/kdm 0755 root root + diff --git a/remote/modules/kdm/kdm.build b/remote/modules/kdm/kdm.build index b5d1be08..feac30cb 100644 --- a/remote/modules/kdm/kdm.build +++ b/remote/modules/kdm/kdm.build @@ -16,7 +16,6 @@ build () { post_copy() { #create static kdm folders in stage3.2 mkdir -p "${TARGET_BUILD_DIR}/var/lib/kdm" - mkdir -p "${TARGET_BUILD_DIR}/var/run/kdm" # link kdm config as opensuse wants in in another place ln -s "/etc/kde4" "$TARGET_BUILD_DIR/usr/share/kde4/config" diff --git a/remote/modules/pam/data/etc/tmpfiles.d/pipefs.conf b/remote/modules/pam/data/etc/tmpfiles.d/pipefs.conf new file mode 100644 index 00000000..7c422623 --- /dev/null +++ b/remote/modules/pam/data/etc/tmpfiles.d/pipefs.conf @@ -0,0 +1,2 @@ +D /var/run/rpc_pipefs 0755 root root + diff --git a/remote/modules/pam/pam.build b/remote/modules/pam/pam.build index 063c0065..34319ce8 100644 --- a/remote/modules/pam/pam.build +++ b/remote/modules/pam/pam.build @@ -23,18 +23,5 @@ build() { } post_copy() { - if [ ! -d "${TARGET_BUILD_DIR}/run/rpc_pipefs" ]; then - mkdir -p "${TARGET_BUILD_DIR}/run/rpc_pipefs" || pwarning "Could not mkdir ${TARGET_BUILD_DIR}/run/rpc_pipefs" - fi - - # find libnfsidmap run-time library directory - #local COPYLIST="$MODULE_BUILD_DIR/list_packet_files" - #local SEARCH=$(grep "/libsnfsidmap/" "$COPYLIST" | head -1) - #[ -z "$SEARCH" ] && perror "Hä" - #SEARCH=$(dirname "$SEARCH") - #if [ -d "${SEARCH}" ]; then - # tarcopy "${SEARCH}" "${TARGET_BUILD_DIR}" || pinfo "Something went wrong copying $SEARCH" - #fi - - + : } diff --git a/remote/modules/plymouth/data/etc/tmpfiles.d/plymouth.conf b/remote/modules/plymouth/data/etc/tmpfiles.d/plymouth.conf new file mode 100644 index 00000000..211c61f6 --- /dev/null +++ b/remote/modules/plymouth/data/etc/tmpfiles.d/plymouth.conf @@ -0,0 +1,2 @@ +D /var/run/plymouth 0755 root root + diff --git a/remote/modules/plymouth/plymouth.conf b/remote/modules/plymouth/plymouth.conf index 26e123e4..ec6f8571 100644 --- a/remote/modules/plymouth/plymouth.conf +++ b/remote/modules/plymouth/plymouth.conf @@ -9,5 +9,6 @@ REQUIRED_DIRECTORIES=" /etc /lib /sbin - /var + /var/lib + /var/spool " diff --git a/remote/modules/sshd/data/etc/tmpfiles.d/sshd.conf b/remote/modules/sshd/data/etc/tmpfiles.d/sshd.conf new file mode 100644 index 00000000..d4aa9a67 --- /dev/null +++ b/remote/modules/sshd/data/etc/tmpfiles.d/sshd.conf @@ -0,0 +1,2 @@ +D /var/run/sshd 0755 root root + diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build index f9749740..99cb86f7 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build @@ -65,7 +65,9 @@ post_copy() { [ ! -e "$TARGET_BUILD_DIR/bin/mount" ] && ln -s /usr/bin/mount "$TARGET_BUILD_DIR/bin/mount" # make basic directory structure - mkdir -p "${TARGET_BUILD_DIR}"/{bin,dev,proc,lib,etc,mnt,sys,var/run,var/lock,var/log,run/lock,run/shm,opt/openslx/mnt} + mkdir -p "$TARGET_BUILD_DIR"/{bin,dev,proc,lib,etc,mnt,sys,var,opt/openslx/mnt} + ln -sf "/run/lock" "$TARGET_BUILD_DIR/var/lock" + ln -sf "/run" "$TARGET_BUILD_DIR/var/run" # make openslx log directory mkdir -p "${TARGET_BUILD_DIR}"/var/log/openslx diff --git a/remote/setup_target b/remote/setup_target index 8160de3e..1b857eda 100755 --- a/remote/setup_target +++ b/remote/setup_target @@ -362,6 +362,10 @@ process_module() { copy_static_data pinfo "## Post copy" post_copy + # Sanity checks + [ -e "$TARGET_BUILD_DIR/var/run" -a ! -L "$TARGET_BUILD_DIR/var/run" ] && perror "Messup datected: $TARGET_BUILD_DIR/var/run exists and is not a symlink!" + [ -e "$TARGET_BUILD_DIR/var/lock" -a ! -L "$TARGET_BUILD_DIR/var/lock" ] && perror "Messup datected: $TARGET_BUILD_DIR/var/lock exists and is not a symlink!" + [ -n "$(ls -A "$TARGET_BUILD_DIR/run")" ] && perror "Messup detected: $TARGET_BUILD_DIR/run is not empty. You cannot place static files there, use /etc/tmpfiles.d instead!" # set MODULE_BUILD_SIZE calc_size pinfo "Module completed. Total size: ${MODULE_BUILD_SIZE}" @@ -408,20 +412,6 @@ post_process_target() { ldconfig -v -r "${TARGET_BUILD_DIR}" -f "/ldconf-temp" unlink "$LDTEMP" - # Hacky way of making sure /run and /var/run are actually the same directory - local DIR_RUN="$TARGET_BUILD_DIR/run" - local DIR_VAR_RUN="$TARGET_BUILD_DIR/var/run" - [ -L "$DIR_RUN" ] && perror "$DIR_RUN is a symbolic link, refusing to work!" - if [ -d "$DIR_RUN" -o -d "$DIR_VAR_RUN" ]; then - mkdir -p "$DIR_RUN" || perror "Could not create $DIR_RUN" - if [ -d "$DIR_VAR_RUN" -a ! -L "$DIR_VAR_RUN" ]; then - mv "$DIR_VAR_RUN/"* "$DIR_RUN/" || perror "Could not move contents of $DIR_VAR_RUN to $DIR_RUN" - rmdir "$DIR_VAR_RUN" || perror "Could not delete $DIR_VAR_RUN after moving contents to $DIR_RUN" - fi - if [ ! -L "$DIR_VAR_RUN" ]; then - ln -sf "../run" "$DIR_VAR_RUN" || perror "Could not create symbolic link $DIR_VAR_RUN to ../run" - fi - fi } clean_modules() { -- cgit v1.2.3-55-g7522 From 8548d0869109a56f5afaeffb222dc688df1d3c60 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 20:06:39 +0200 Subject: Better make this relative... --- remote/rootfs/rootfs-stage32/rootfs-stage32.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build index 99cb86f7..0b7398af 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build @@ -66,8 +66,8 @@ post_copy() { # make basic directory structure mkdir -p "$TARGET_BUILD_DIR"/{bin,dev,proc,lib,etc,mnt,sys,var,opt/openslx/mnt} - ln -sf "/run/lock" "$TARGET_BUILD_DIR/var/lock" - ln -sf "/run" "$TARGET_BUILD_DIR/var/run" + ln -sf "../run/lock" "$TARGET_BUILD_DIR/var/lock" + ln -sf "../run" "$TARGET_BUILD_DIR/var/run" # make openslx log directory mkdir -p "${TARGET_BUILD_DIR}"/var/log/openslx -- cgit v1.2.3-55-g7522 From c1bfa1880e6180466f7542cf1aa18d37b98c1644 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 20:09:09 +0200 Subject: FIXfgdksjfgkldjfg --- remote/rootfs/rootfs-stage32/rootfs-stage32.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build index 0b7398af..dc53c237 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build @@ -65,7 +65,7 @@ post_copy() { [ ! -e "$TARGET_BUILD_DIR/bin/mount" ] && ln -s /usr/bin/mount "$TARGET_BUILD_DIR/bin/mount" # make basic directory structure - mkdir -p "$TARGET_BUILD_DIR"/{bin,dev,proc,lib,etc,mnt,sys,var,opt/openslx/mnt} + mkdir -p "$TARGET_BUILD_DIR"/{bin,dev,proc,lib,etc,mnt,run,sys,var,opt/openslx/mnt} ln -sf "../run/lock" "$TARGET_BUILD_DIR/var/lock" ln -sf "../run" "$TARGET_BUILD_DIR/var/run" -- cgit v1.2.3-55-g7522 From f6f820615a88a4943403cdcd5111a07bba6205df Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 20:21:44 +0200 Subject: Fix /run stuff for the 25th time.... --- remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf | 2 ++ remote/rootfs/rootfs-stage32/rootfs-stage32.build | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf diff --git a/remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf b/remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf new file mode 100644 index 00000000..ef610bdc --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf @@ -0,0 +1,2 @@ +D /run/lock 1777 root root + diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build index dc53c237..02f238de 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build @@ -66,8 +66,7 @@ post_copy() { # make basic directory structure mkdir -p "$TARGET_BUILD_DIR"/{bin,dev,proc,lib,etc,mnt,run,sys,var,opt/openslx/mnt} - ln -sf "../run/lock" "$TARGET_BUILD_DIR/var/lock" - ln -sf "../run" "$TARGET_BUILD_DIR/var/run" + ln -s -n -f -t "$TARGET_BUILD_DIR/var" "../run/lock" "../run" # make openslx log directory mkdir -p "${TARGET_BUILD_DIR}"/var/log/openslx -- cgit v1.2.3-55-g7522 From b3bd794b4f4b2d6dcc8f42e871a463facb8786da Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 21:12:03 +0200 Subject: [vmchooser] Add support for dnbd3 (if servers are specified in config) Also add fallback if MAC address is not present in config --- .../data/opt/openslx/scripts/systemd-vmchooser_env | 6 ++- .../data/opt/openslx/scripts/vmchooser-run_virt | 46 +++++++++++++++++++--- .../data/opt/openslx/etc/vmware/run-virt.include | 19 +++++---- 3 files changed, 57 insertions(+), 14 deletions(-) diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env b/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env index 50eace20..4119ad9c 100755 --- a/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env @@ -91,7 +91,11 @@ if grep -q ^flags.*\\\ /proc/cpuinfo; then fi # write mac -echo "hostmacaddr=${SLX_PXE_MAC}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf +if [ -n "$SLX_PXE_MAC" ]; then + echo "hostmacaddr=${SLX_PXE_MAC}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf +else ## Fallback: + echo "hostmacaddr=$(ip a | grep ether | grep -o -E -i '([0-9a-f]{2}:){5}[0-9a-f]{2}' | head -n 1)" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf +fi # ip addr echo "hostip=${SLX_PXE_CLIENT_IP}" >> ${VMCHOOSER_CONF_DIR}/virtualization.conf # hostname diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt index 979db35a..f6e4e491 100755 --- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt @@ -23,11 +23,11 @@ ################################################################################ # include general configuration from vmchooser -[ -f /opt/openslx/etc/vmchooser/vmchooser.conf ] && \ -. /opt/openslx/etc/vmchooser/vmchooser.conf +[ -f /opt/openslx/etc/vmchooser/vmchooser.conf ] && . /opt/openslx/etc/vmchooser/vmchooser.conf # load general virtualization information -[ -f /opt/openslx/etc/vmchooser/virtualization.conf ] && \ -. /opt/openslx/etc/vmchooser/virtualization.conf +[ -f /opt/openslx/etc/vmchooser/virtualization.conf ] && . /opt/openslx/etc/vmchooser/virtualization.conf +# Load general openslx config +[ -f /opt/openslx/config ] && . /opt/openslx/config ################################################################################ ### Functions used throughout the script @@ -359,8 +359,9 @@ hostmem="$[ $totalmem - $mem ]" # last two bytes are taken from the bridge of the host # define one MAC per guest macguestpart="00:50:56:${VM_ID}" -machostpart=$(echo ${hostmacaddr} | awk -F ":" '{print $(NF-1)":"$NF}') +machostpart=$(echo "${hostmacaddr}" | awk -F ":" '{print $(NF-1)":"$NF}') macaddr=$(echo "${macguestpart}:${machostpart}" | tr "[a-z]" "[A-Z]") +macaddrsuffix=$(echo "${VM_ID}:${machostpart}" | tr "[a-z]" "[A-Z]") # Virtual fd/cd/dvd and drive devices, floppy b: for configuration # if $floppy_0 from run-virt.include set then fdtest="TRUE" @@ -432,6 +433,32 @@ cp "$xmlfile" "/opt/openslx/etc/vmchooser/fd-loop/config.xml" # Add another file with resolution information xrandr | grep -o -E 'current\s*[0-9]+\s*x\s*[0-9]+' | cut -c 8- | sed -r 's/(\s|\t|\n)//g' | head -n 1 > "/opt/openslx/etc/vmchooser/fd-loop/hostres.txt" +# Try to use dnbd3 to access the image +unset vm_diskfile +unset vm_revision +unset dnbd3 +if [ -n "$SLX_DNBD3_SERVERS" ]; then + if [ -e "/dev/dnbd0" -a -e "/var/run/dnbd3.socket" ]; then + for SRV in $SLX_DNBD3_SERVERS; do + dnbd3=$(dnbd3-client -h "$SRV" -i "${vmpath#/mnt/vmstore/}" -r 0) + RET=$? + if [ "$RET" = "0" ]; then + vm_diskfile="$dnbd3" + vm_revision=$(cat "/sys/block/${dnbd3#/dev/}/net/rid") + writelog "DNBD3: $vm_diskfile on $dnbd3 with rid $vm_revision" + break + fi + done + [ -z "$vm_diskfile" ] && writelog "No working dnbd3 server found :-(" + else + writelog "Won't use dnbd3 as it's not loaded, or the daemon is not running..." + fi +else + writelog "Won't use dnbd3 as no servers are given in config" +fi +[ -z "$vm_diskfile" ] && vm_diskfile="$vmpath" +writelog "Used diskfile: $vm_diskfile" + # Get all virtual machine specific stuff from the respective include file if [ -e /opt/openslx/etc/"${xmlvirt}"/run-virt.include ] ; then self="${xmlvirt}" @@ -463,6 +490,15 @@ if [ -e /opt/openslx/etc/"${xmlvirt}"/run-virt.include ] ; then if [ -n "${POSTRUN}" ]; then eval ${POSTRUN} >/dev/null 2>&1 fi + + # Disconnect dnbd3 device + if [ -n "$dnbd3" ]; then + for timeout in 1 1 2; do + dnbd3-client -c "$dnbd3" && break + writelog "dnbd3 still busy...." + sleep "$timeout" + done + fi cleanexit 0 else diff --git a/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include b/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include index 084828ff..b755133f 100755 --- a/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include +++ b/remote/modules/vmplayer/data/opt/openslx/etc/vmware/run-virt.include @@ -229,7 +229,7 @@ MemTrimRate = "-1" # ide-disks ide0:0.present = "$ide" -ide0:0.fileName = "$diskfile" +ide0:0.fileName = "$vm_diskfile" ## Edited for persistent mode. ide0:0.mode = "independent-${diskmode}" ## @@ -245,7 +245,7 @@ ide1:1.deviceType = "cdrom-raw" # scsi-disks scsi0.present = "$scsi" scsi0:0.present = "$scsi" -scsi0:0.fileName = "$diskfile" +scsi0:0.fileName = "$vm_diskfile" scsi0.virtualDev = "$hddrv" ## Edited for persistent mode. scsi0:0.mode = "independent-${diskmode}"$stateFileConfiguration @@ -270,7 +270,7 @@ $network_virtualDev ethernet0.connectionType = "$network_kind" #ethernet1.connectionType = "custom" #ethernet1.vnet = "/dev/vmnet2" -ethernet0.address = "00:50:56:$VM_ID:$machostpart" +ethernet0.address = "00:50:56:$macaddrsuffix" ethernet0.wakeOnPcktRcv = "FALSE" # sound @@ -627,11 +627,14 @@ writelog "" ################################################################################ # configure and start samba service to provide user's home directory -if [ -f /usr/sbin/smbd ] ; then - sudo /opt/openslx/bin/sed -i /etc/vmware/smb.conf -e "s,USER,$USER," - sudo /usr/sbin/nmbd -s /etc/vmware/smb.conf - sudo /usr/sbin/smbd -s /etc/vmware/smb.conf -fi +#if [ -f /usr/sbin/smbd ] ; then +# sudo /opt/openslx/bin/sed -i /etc/vmware/smb.conf -e "s,USER,$USER," +# sudo /usr/sbin/nmbd -s /etc/vmware/smb.conf +# sudo /usr/sbin/smbd -s /etc/vmware/smb.conf +#fi + +# For debugging +cp "$conffile" "/tmp/vmware-last-config" # using the modified version of the wrapper script VIRTCMD="/opt/openslx/bin/vmplayer" -- cgit v1.2.3-55-g7522 From f85fb3947b61e0def1ed69d945c408e56f1bbc3d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 21:13:12 +0200 Subject: Fix typo in shebang --- .../rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue index c09162dc..8fbd5c8b 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh # Set greeting and add information on booted system # Fixme (add version string and distro name) -- cgit v1.2.3-55-g7522 From 282ab9dfe046b3eaecf84c06658492c4c83d2849 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Aug 2013 12:30:23 +0200 Subject: [systemd] Fix path of 'ip' in service file --- .../modules/systemd/data/etc/systemd/system/network-interface@.service | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/remote/modules/systemd/data/etc/systemd/system/network-interface@.service b/remote/modules/systemd/data/etc/systemd/system/network-interface@.service index 13a30bbc..77bbd287 100644 --- a/remote/modules/systemd/data/etc/systemd/system/network-interface@.service +++ b/remote/modules/systemd/data/etc/systemd/system/network-interface@.service @@ -5,4 +5,5 @@ Before=udhcpc@%i.service [Service] Type=simple -ExecStart=/opt/openslx/bin/ip link set dev %I up +ExecStart=/opt/openslx/sbin/ip link set dev %I up + -- cgit v1.2.3-55-g7522 From ac68d9d7ba82bd69a8d153e487cccd7eb0caf32a Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Aug 2013 13:00:17 +0200 Subject: [export_target] Fix creation of squashFS --- server/export_target | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/server/export_target b/server/export_target index 7ab7a11d..92b6fdcb 100755 --- a/server/export_target +++ b/server/export_target @@ -22,9 +22,6 @@ SERVER_BOOT_DIR="${MODE_DIR}/boot/${REMOTE_IP}" # builds from remote server SERVER_BUILD_DIR="${MODE_DIR}/local_builds/${REMOTE_IP}" -# stage32 sqfs directory -STAGE32_SQFS_DIR="${SERVER_BOOT_DIR}/stage32_sqfs/mnt" - # target directory SERVER_CONFIGS_DIR="${MODE_DIR}/configs" @@ -58,8 +55,7 @@ sync_remote() { generate_stage32() { local TOOL_STR="${TOOL_STR} generate_stage32:" - [ ! -d "${STAGE32_SQFS_DIR}" ] && mkdir -p "${STAGE32_SQFS_DIR}" - [ -e "${STAGE32_SQFS_DIR}/${TARGET}.sqfs" ] && rm "${STAGE32_SQFS_DIR}/${TARGET}.sqfs" + rm -f "${SERVER_BOOT_DIR}/${TARGET}.sqfs" pinfo "Writing '${TARGET}.sqfs' to '${SERVER_BOOT_DIR}/${TARGET}.sqfs'" mksquashfs "${SERVER_BUILD_DIR}/${TARGET}" "${SERVER_BOOT_DIR}/${TARGET}.sqfs" -comp xz -b 1M -no-recovery >&6 || perror "mksquashfs failed ($?)." pinfo "Created '${SERVER_BOOT_DIR}/${TARGET}.sqfs'." -- cgit v1.2.3-55-g7522 From 010bdb776fa495a1fdd317ea43e622847fe712d7 Mon Sep 17 00:00:00 2001 From: Christian Rößler Date: Wed, 21 Aug 2013 13:39:13 +0200 Subject: [mltk] Script: New Function 'check-devtools', check for devtools now later in running to not impede script help (when invoked witout or wrong parameters). --- mltk | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/mltk b/mltk index 24de8d33..73de3601 100755 --- a/mltk +++ b/mltk @@ -20,13 +20,6 @@ SELF="$(readlink -f $0)" ROOT_DIR="$(dirname "${SELF}")" MLTK_PID="$$" -# Checking for needed development tools, compilers etc. -# Required: m4 make gcc g++ binutils -DEVTOOLS="gcc c++ g++ make m4 strip git depmod patch mksquashfs" # 'strip' as marker for binutils -for i in $DEVTOOLS; do - which "$i" 2>/dev/null 1>&2 || { echo "Essential development tool $i not found - exiting."; exit 1; } -done - # Make apt-get install non-interactive when it comes to postinstall questions # ie. kdm asking which dm you want to set as default export DEBIAN_FRONTEND=noninteractive @@ -94,6 +87,16 @@ print_usage() { echo -e "" } + +check_devtools() { + # Checking for needed development tools, compilers etc. + # Required: m4 make gcc g++ binutils + DEVTOOLS="gcc c++ g++ make m4 strip git depmod patch mksquashfs" # 'strip' as marker for binutils + for i in $DEVTOOLS; do + which "$i" 2>/dev/null 1>&2 || { echo "Essential development tool $i not found - exiting."; exit 1; } + done +} + initial_checks() { if [ "x$(whoami)" != "xroot" ]; then perror "ERROR: You need to have root rights to install packages." @@ -284,4 +287,6 @@ REMOTE_AUTOMATIC_BUILD=0 initial_checks read_params $@ +check_devtools + run -- cgit v1.2.3-55-g7522 From c9c0dffa05c00428595b5ddebbeeb396418d3f65 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Aug 2013 13:43:56 +0200 Subject: [remote] Renamed functions to functions.inc; make setup-addons not fail if no addons are configured; try random server order when downloading --- remote/rootfs/rootfs-stage31/data/etc/functions | 90 --------------------- .../rootfs/rootfs-stage31/data/etc/functions.inc | 92 ++++++++++++++++++++++ remote/rootfs/rootfs-stage31/data/init | 4 +- .../opt/openslx/scripts/systemd-setup_slx_addons | 10 ++- 4 files changed, 100 insertions(+), 96 deletions(-) delete mode 100644 remote/rootfs/rootfs-stage31/data/etc/functions create mode 100644 remote/rootfs/rootfs-stage31/data/etc/functions.inc diff --git a/remote/rootfs/rootfs-stage31/data/etc/functions b/remote/rootfs/rootfs-stage31/data/etc/functions deleted file mode 100644 index 37bb7d89..00000000 --- a/remote/rootfs/rootfs-stage31/data/etc/functions +++ /dev/null @@ -1,90 +0,0 @@ -######################################################################### -# -# COMMON HELPER FUNCTIONS -# - -######################################################################### -# -# Function to drop a debug shell with an error message. -# -# Usage: -# drop_shell "This is your error message." -# -drop_shell() { - [ $# -gt 0 ] && echo $@ - echo "CTRL + D will continue booting." - setsid sh -c 'exec sh /dev/tty1 2>&1' -} - -######################################################################### -# -# Helper function to parse parameter named OPTION from the kernel command line (/proc/cmdline) -# -# Usage: -# read_from_cmdline OPTION -# -read_from_cmdline(){ - [ $# -ne 1 ] && echo "Error - 'read_from_cmdline' requires 1 argument, $# given." && exit 1 - - local OPTION="$1" - local VALUE="" - - VALUE="$(grep -o -E "${OPTION}=\S+" /proc/cmdline | cut -c $((${#OPTION}+2))-)" - if [ -z "$VALUE" ]; then - echo "Error - '${OPTION}=' not found in command line, or empty" - return 1 - else - echo "$VALUE" - fi -} - -######################################################################### -# -# Helper function to download given FILE_URL from servers in 'slxsrv' -# as given through the kernel command line. File will be saved under TARGET_PATH -# -# Usage: -# download FILE_URL TARGET_PATH -# -# Example: -# download "config" "/opt/openslx/config" -# -# Note: -# FILE_URL can have subpath, e.g. "ubuntu-13.04-x64/config" -# -download() { - [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguments, $# given." && return 1 - - if [ -e "${FUTURE_ROOT}/opt/openslx/config" ]; then - . "${FUTURE_ROOT}/opt/openslx/config" || echo "Error - could not source '${FUTURE_ROOT}/opt/openslx/config'" - else - # read SLX_KCL_SERVERS from cmdline since we didn't get it from the config file. - SLX_KCL_SERVERS="$(read_from_cmdline "slxsrv" | tr ',' ' ')" - echo "SLX_KCL_SERVERS='$SLX_KCL_SERVERS'" >> "${FUTURE_ROOT}/opt/openslx/config" - fi - - local FILE_URL="$1" - local TARGET_PATH="$2" - - for TIMEOUT in 1 2 3 4 5; do - for SERVER in $SLX_CONFIG_SERVERS $SLX_KCL_SERVERS; do - wget -T 5 -q -O "$TARGET_PATH" "http://${SERVER}/${FILE_URL}" - RET=$? - if [ "x$RET" != "x0" ]; then - echo "Error - downloading 'http://$SERVER/$FILE_URL' via wget failed. Exit Code: $RET" - echo "Trying again in $(($TIMEOUT * 500)) ms..." - [ $TIMEOUT -eq 5 ] && drop_shell "Max timeouts reached. Dropping shell..." - usleep $(($TIMEOUT * 500000)) - else - [ "x$DEBUG" != "x" ] && echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'." - return 0 - fi - done - done - - # check if it actually worked - if [ ! -e $TARGET_PATH ]; then - echo "Error - $TARGET_PATH does not exists. Downloading '$FILE_URL' from '$SERVER_LIST' failed." - return 1 - fi -} diff --git a/remote/rootfs/rootfs-stage31/data/etc/functions.inc b/remote/rootfs/rootfs-stage31/data/etc/functions.inc new file mode 100644 index 00000000..362943ae --- /dev/null +++ b/remote/rootfs/rootfs-stage31/data/etc/functions.inc @@ -0,0 +1,92 @@ +######################################################################### +# +# COMMON HELPER FUNCTIONS +# + +######################################################################### +# +# Function to drop a debug shell with an error message. +# +# Usage: +# drop_shell "This is your error message." +# +drop_shell() { + [ $# -gt 0 ] && echo $@ + echo "CTRL + D will continue booting." + setsid sh -c 'exec sh /dev/tty1 2>&1' +} + +######################################################################### +# +# Helper function to parse parameter named OPTION from the kernel command line (/proc/cmdline) +# +# Usage: +# read_from_cmdline OPTION +# +read_from_cmdline(){ + [ $# -ne 1 ] && echo "Error - 'read_from_cmdline' requires 1 argument, $# given." && exit 1 + + local OPTION="$1" + local VALUE="" + + VALUE="$(grep -o -E "${OPTION}=\S+" /proc/cmdline | cut -c $((${#OPTION}+2))-)" + if [ -z "$VALUE" ]; then + echo "Error - '${OPTION}=' not found in command line, or empty" + return 1 + else + echo "$VALUE" + fi +} + +######################################################################### +# +# Helper function to download given FILE_URL from servers in 'slxsrv' +# as given through the kernel command line. File will be saved under TARGET_PATH +# +# Usage: +# download FILE_URL TARGET_PATH +# +# Example: +# download "config" "/opt/openslx/config" +# +# Note: +# FILE_URL can have subpath, e.g. "ubuntu-13.04-x64/config" +# +download() { + [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguments, $# given." && return 1 + + if [ -e "${FUTURE_ROOT}/opt/openslx/config" ]; then + . "${FUTURE_ROOT}/opt/openslx/config" || echo "Error - could not source '${FUTURE_ROOT}/opt/openslx/config'" + else + # read SLX_KCL_SERVERS from cmdline since we didn't get it from the config file. + SLX_KCL_SERVERS="$(read_from_cmdline "slxsrv" | tr ',' ' ')" + echo "SLX_KCL_SERVERS='$SLX_KCL_SERVERS'" >> "${FUTURE_ROOT}/opt/openslx/config" + fi + + local FILE_URL="$1" + local TARGET_PATH="$2" + + local SERVERS=$(for SERVER in $SLX_CONFIG_SERVERS $SLX_KCL_SERVERS; do echo "$RANDOM $SERVER"; done | sort -u | sed -r 's/^[0-9]+ //') + + for TIMEOUT in 1 2 3 4 5; do + for SERVER in $SERVERS; do + wget -T 5 -q -O "$TARGET_PATH" "http://${SERVER}/${FILE_URL}" + RET=$? + if [ "x$RET" != "x0" ]; then + echo "Error - downloading 'http://$SERVER/$FILE_URL' via wget failed. Exit Code: $RET" + echo "Trying again in $(($TIMEOUT * 500)) ms..." + [ $TIMEOUT -eq 5 ] && drop_shell "Max timeouts reached. Dropping shell..." + usleep $(($TIMEOUT * 500000)) + else + [ "x$DEBUG" != "x" ] && echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'." + return 0 + fi + done + done + + # check if it actually worked + if [ ! -e $TARGET_PATH ]; then + echo "Error - $TARGET_PATH does not exists. Downloading '$FILE_URL' from '$SERVER_LIST' failed." + return 1 + fi +} diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index 35e898b5..db4ef484 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -17,7 +17,7 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin export LD_LIBRARY_PATH=/usr/lib64 # import common functions -. /etc/functions +. /etc/functions.inc # mount the important standard directories mount -n -t tmpfs -o 'mode=755' run "/run" @@ -91,7 +91,7 @@ fi # copy files needed for stage3.2 to FUTURE_ROOT [ $DEBUG -ge 1 ] && echo "Copying busybox etc. to stage32..." -tar -cp "/bin" "/sbin" "/usr/bin" "/usr/sbin" "/etc/functions" | tar -xp -C "${FUTURE_ROOT}/opt/openslx/" +tar -cp "/bin" "/sbin" "/usr/bin" "/usr/sbin" "/etc/functions.inc" | tar -xp -C "${FUTURE_ROOT}/opt/openslx/" #echo 'blacklist pcspkr' >> /mnt/etc/modprobe.d/blacklist.conf # one last debug shell if activated diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons index a3350424..70a09924 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons @@ -6,12 +6,14 @@ # # -. /opt/openslx/etc/functions +. /opt/openslx/config || { echo "Could not source config!"; exit 23; } +[ -z "${SLX_ADDONS}" ] && { echo "No addons configured. Nothing to do :-)."; exit 0; } + +. /opt/openslx/etc/functions.inc || { echo "functions.inc not found!"; exit 1337; } + export FUTURE_ROOT="/" # read openslx config -. /opt/openslx/config -[ -z "${SLX_ADDONS}" ] && { echo "SLX_ADDONS is not set in /opt/openslx/config." && exit 1; } if [ -z "${SLX_CONFIG_SERVERS}" ]; then echo "SLX_CONFIG_SERVERS is not set in /opt/openslx/config. Will only try the base servers from the cmdline." if [ -z "${SLX_KCL_SERVERS}" ]; then @@ -31,7 +33,7 @@ for ADDON in ${SLX_ADDONS}; do download "${SLX_BASE_PATH}/${ADDON}.sqfs" "${ADDON_TARGET_PATH}" # now mount it to $SLX_MNT/ - ADDON_MOUNT_POINT="${SLX_BASE_MNT}/$(basename $(echo ${ADDON})|awk -F "." '{print $1}')" + ADDON_MOUNT_POINT="${SLX_BASE_MNT}/$(basename $(echo ${ADDON}) | awk -F "." '{print $1}')" mkdir -p "$ADDON_MOUNT_POINT" echo "Mounting ${ADDON_TARGET_PATH} to ${ADDON_MOUNT_POINT}" mount -t squashfs "$ADDON_TARGET_PATH" ${ADDON_MOUNT_POINT} || { echo "Failed to mount." && exit 1; } -- cgit v1.2.3-55-g7522 From 72dcfc61bf3159c9e5ddd4207fbb75685677f91d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Aug 2013 13:48:31 +0200 Subject: [sshd] don't touch /var/run! --- remote/modules/sshd/sshd.build | 1 - 1 file changed, 1 deletion(-) diff --git a/remote/modules/sshd/sshd.build b/remote/modules/sshd/sshd.build index 89dcd386..ebf42c12 100644 --- a/remote/modules/sshd/sshd.build +++ b/remote/modules/sshd/sshd.build @@ -14,7 +14,6 @@ build() { } post_copy() { - mkdir -p "${TARGET_BUILD_DIR}/var/run/sshd" # ubuntu mkdir -p "${TARGET_BUILD_DIR}/var/lib/empty" # suse chmod go-rwx "${TARGET_BUILD_DIR}/etc/ssh/"* # no space, " before * -- cgit v1.2.3-55-g7522 From 3a0da91477cfafdbeb2286874eb78a782cebfcc8 Mon Sep 17 00:00:00 2001 From: Christian Rößler Date: Wed, 21 Aug 2013 15:35:50 +0200 Subject: [system.inc] Two new variables for system description / information: AMD64_I386 (can contain amd64 or i386), X86_64_I586 (x86_64 or i586). These will be serving download url construction, mostly. --- helper/system.inc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/helper/system.inc b/helper/system.inc index 0796c974..5697de2a 100644 --- a/helper/system.inc +++ b/helper/system.inc @@ -22,7 +22,11 @@ export MAKEFLAGS="-j$CPU_CORES" # Determine if we have lib64 if [ "$(uname -m)x" = "x86_64x" ]; then LIB64="lib64" + AMD64_I386=amd64 + X86_64_I586=x86_64 else LIB64="lib" + AMD64_I386=i386 + X86_64_I586=i586 fi -- cgit v1.2.3-55-g7522 From 162ec39050129361b77837ee1cabaf78595bdf40 Mon Sep 17 00:00:00 2001 From: Christian Rößler Date: Wed, 21 Aug 2013 15:38:49 +0200 Subject: [setup-target] New Var SYS_VERSION (version number of a distribution) --- remote/setup_target | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/remote/setup_target b/remote/setup_target index 1b857eda..281f91bd 100755 --- a/remote/setup_target +++ b/remote/setup_target @@ -77,7 +77,8 @@ initial_checks () { ;; esac # Get version - we mangle this quite a bit. first make sure it has no spaces, then split version at period (.), underscore (_) and dash (-) - local VERSION=$(lsb_release -rs | tolower | sed -r 's/\s//g;s/[\._]/ /g;s/-//g') + SYS_VERSION=$(lsb_release -rs | tolower) + local VERSION=$(echo $SYS_VERSION | sed -r 's/\s//g;s/[\._]/ /g;s/-//g') local STRTMP="" PRINT_SYS_VERSIONS="*.conf.$SYS_DISTRIBUTION" SYS_VERSIONS="$SYS_DISTRIBUTION" -- cgit v1.2.3-55-g7522 From 4abc79f57054f34301eeb5a4d5cf2e1f9fc19337 Mon Sep 17 00:00:00 2001 From: Christian Rößler Date: Wed, 21 Aug 2013 16:18:53 +0200 Subject: [system.inc] Added case / var PACKET_HANDLER (dpkg, rpm) for packet manipulation on single packet file level. --- remote/setup_target | 3 +++ 1 file changed, 3 insertions(+) diff --git a/remote/setup_target b/remote/setup_target index 281f91bd..c19113df 100755 --- a/remote/setup_target +++ b/remote/setup_target @@ -65,12 +65,15 @@ initial_checks () { case "$SYS_DISTRIBUTION" in ubuntu|debian) PACKET_MANAGER="apt" + PACKET_HANDLER="dpkg" ;; opensuse) PACKET_MANAGER="zypper" + PACKET_HANDLER="rpm" ;; scientific) PACKET_MANAGER="yum" + PACKET_HANDLER="rpm" ;; *) perror "Unknown Distribution: $SYS_DISTRIBUTION - Please specify its packet manager in remote/setup_target" -- cgit v1.2.3-55-g7522 From 65971818a573c47f182de461092d60bf1c63cc2b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Aug 2013 16:28:42 +0200 Subject: [rootfs-stage32] Make it possible to run a script after adding an addon to the aufs stack. Call it addon-init and place it in the root directory of your addon [vmplayer] Add such an addon-init script that will take care of setting up the vmplayer environment --- remote/modules/vmplayer/data/addon-init | 5 +++++ remote/rootfs/rootfs-stage31/data/bin/setup_stage32 | 4 ++++ .../data/opt/openslx/scripts/systemd-setup_slx_addons | 19 ++++++++++++++----- 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100755 remote/modules/vmplayer/data/addon-init diff --git a/remote/modules/vmplayer/data/addon-init b/remote/modules/vmplayer/data/addon-init new file mode 100755 index 00000000..01acb3b4 --- /dev/null +++ b/remote/modules/vmplayer/data/addon-init @@ -0,0 +1,5 @@ +#!/bin/sh + +systemctl daemon-reload +systemctl start vmware + diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 index 151617bc..bc00b830 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 +++ b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 @@ -45,3 +45,7 @@ mount -n -t aufs -o "br:${FUTURE_ROOT}:${STAGE32_MOUNT_POINT}=ro" none /mnt || d mkdir -p /mnt/opt/openslx/uniontmp /mnt/tmp mount -n --move "$FUTURE_ROOT" /mnt/opt/openslx/uniontmp || drop_shell "Problem moving uniontmp." FUTURE_ROOT="/mnt" + +# "Delete" addon hook-script in aufs view +touch "/mnt/opt/openslx/uniontmp/.wh.addon-init" + diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons index 70a09924..a5dc9965 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons @@ -25,20 +25,29 @@ fi SLX_BASE_PATH=$(read_from_cmdline "slxbase") SLX_BASE_MNT="/opt/openslx/mnt" -SYS_TMP="/tmp" +SYS_TMP="/tmp/addons" +mkdir -p "$SYS_TMP" || { echo "Failed to create $SYS_TMP"; exit 1; } for ADDON in ${SLX_ADDONS}; do # download the addon from the given URL - ADDON_TARGET_PATH="${SYS_TMP}/$(basename $(echo ${ADDON})).sqfs" + ADDON_TARGET_PATH="${SYS_TMP}/$(basename "$ADDON").sqfs" download "${SLX_BASE_PATH}/${ADDON}.sqfs" "${ADDON_TARGET_PATH}" # now mount it to $SLX_MNT/ - ADDON_MOUNT_POINT="${SLX_BASE_MNT}/$(basename $(echo ${ADDON}) | awk -F "." '{print $1}')" + ADDON_MOUNT_POINT="${SLX_BASE_MNT}/$(basename "$ADDON")" mkdir -p "$ADDON_MOUNT_POINT" echo "Mounting ${ADDON_TARGET_PATH} to ${ADDON_MOUNT_POINT}" - mount -t squashfs "$ADDON_TARGET_PATH" ${ADDON_MOUNT_POINT} || { echo "Failed to mount." && exit 1; } + mount -t squashfs "$ADDON_TARGET_PATH" "$ADDON_MOUNT_POINT" || { echo "Failed to mount." && exit 1; } # now append it to / echo "Appending ${ADDON_MOUNT_POINT} to /" - mount -o remount,append:${ADDON_MOUNT_POINT}=ro / || { echo "Fail." && exit 1; } + mount -o "remount,append:${ADDON_MOUNT_POINT}=ro" / || { echo "Fail." && exit 1; } + + # Run post-hook if available + if [ -x "$ADDON_MOUNT_POINT/addon-init" ]; then + echo "Running addon initialization script..." + "$ADDON_MOUNT_POINT/addon-init" || echo "Warning: Could not execute addon-init of $ADDON" + fi done +exit 0 + -- cgit v1.2.3-55-g7522 From ada35e7544bd25cb6beba9949910ed0476034152 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Aug 2013 16:30:44 +0200 Subject: [rootfs-stage32] Mount a 10G tmpfs to /tmp if no ID44 partition was found --- .../opt/openslx/scripts/systemd-setup_partitions | 136 +++++++++++---------- 1 file changed, 73 insertions(+), 63 deletions(-) diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions index f162ec3a..bc5ce9c1 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions @@ -17,38 +17,48 @@ # General formatter for the /tmp partition on a local harddisk diskfm () { -local target="$1" -local fs -local path -for fs in xfs ext3 ext2 ; do - unset available - case $(cat /proc/filesystems) in - *${fs}*) available=yes;; - *) modprobe "${fs}" && available=yes;; - esac - if [ -n "${available}" ]; then - unset found - if which "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}" - fi - [ -n "$found" ] && break - fi -done + local target="$1" + local fs + local path + for fs in xfs ext3 ext2 ; do + unset available + case $(cat /proc/filesystems) in + *${fs}*) available=yes;; + *) modprobe "${fs}" && available=yes;; + esac + if [ -n "${available}" ]; then + unset found + if which "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}" + fi + [ -n "$found" ] && break + fi + done +} + +function mount_temp () { + mkdir -p /tmptmp + mv /tmp/* /tmp/.* /tmptmp/ 2> /dev/null + mount $@ /tmp || return 1 + chmod a+rwxt /tmp + mv /tmptmp/* /tmptmp/.* /tmp/ + rmdir /tmptmp + return 0 } # Check for local harddisks and appropriate partitions @@ -66,46 +76,46 @@ for hdpartnr in $(sed -n -e "/ 82 /p" "/etc/disk.partition" | sed -e "s/[[:space swapon "$hdpartnr" done -# We use special non assigned partition type (id44) for harddisk scratch +# 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 $(sed -n -e "/ 44 /p" "/etc/disk.partition" | 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\tnoauto\t\tdefaults\t 0 0" >> "/etc/fstab" - mkdir -p /tmptmp - mv /tmp/* /tmp/.* /tmptmp/ - mount "$hdpartnr" /tmp - chmod a+rwxt /tmp - mv /tmptmp/* /tmptmp/.* /tmp/ - rmdir /tmptmp - break - else - echo "formatting failed for some reason" - fi # Made this non-forking, systemd should handle it - 2013-05-28 + # check for supported filesystem and formatter + if diskfm "$hdpartnr"; then + # echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready + mount_temp "$hdpartnr" || continue + echo -e "$hdpartnr\t/tmp\t\tnoauto\t\tdefaults\t 0 0" >> "/etc/fstab" + break + else + echo "formatting failed for some reason" + fi # Made this non-forking, systemd should handle it - 2013-05-28 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 $(sed -n -e "/ ${partid} /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do - mkdir -p "/media/${hdpartnr#/dev/*}" - if [ "${partid}" -eq 83 ]; then - echo -e "$hdpartnr\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/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" >> "/etc/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" >> "/etc/fstab" - fi - done + for hdpartnr in $(sed -n -e "/ ${partid} /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do + mkdir -p "/media/${hdpartnr#/dev/*}" + if [ "${partid}" -eq 83 ]; then + echo -e "$hdpartnr\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/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" >> "/etc/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" >> "/etc/fstab" + fi + done done mount -a +# Make huge tmpfs if nothing could be mounted for /tmp +if [ "$(mount | grep -c "on /tmp ")" = "0" ]; then + mount_temp -t tmpfs -o size=10G none +fi + -- cgit v1.2.3-55-g7522 From 26f2e448d55cba0b1823b4920cf311ed8892666f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 22 Aug 2013 10:47:54 +0200 Subject: [rootfs-stage31] Make MAC addresses lowercase, as udev fails to match a rule with uppercase letters in hex --- remote/rootfs/rootfs-stage31/data/bin/setup_network | 2 +- remote/rootfs/rootfs-stage31/data/init | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_network b/remote/rootfs/rootfs-stage31/data/bin/setup_network index 8e070bdf..b504a92b 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_network +++ b/remote/rootfs/rootfs-stage31/data/bin/setup_network @@ -26,7 +26,7 @@ IP_OUT=$(ip a | grep -B 1 "/ether" | sed -r '/^--$/d;$!N;s#^[0-9]+: ([a-z0-9\.:] for LINE in $IP_OUT; do IFACE=$(echo "$LINE" | awk -F '==' '{printf $1}') - IFMAC=$(echo "$LINE" | awk -F '==' '{printf $2}' | tr '[a-z]' '[A-Z]') + IFMAC=$(echo "$LINE" | awk -F '==' '{printf $2}' | tr '[A-Z]' '[a-z]') # udev requires mac addesses to be lowercase (a-f), see http://www.debianhelp.co.uk/udev.htm echo "${IFACE} = ${IFMAC}" if [ "x$IFMAC" == "x$MAC" ]; then diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index db4ef484..838892e5 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -64,7 +64,7 @@ for opts in ${KCL}; do export NFSSERVER=${nfs%:/*} ;; BOOTIF=*) - export MAC="$( echo "$opts" | cut -b 11- | tr '-' ':' | tr '[a-z]' '[A-Z]' )" ;; + export MAC="$( echo "$opts" | cut -b 11- | tr '-' ':' | tr '[A-Z]' '[a-z]' )" ;; # make mac lowercase for udev (see setup_network) esac done -- cgit v1.2.3-55-g7522 From 7199f8b6f00dbc904c92b6bfe1bad8d99c78c083 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 22 Aug 2013 12:11:21 +0200 Subject: [rootfs-stage31] Make download timeouts shorter, properly use drop_shell in the calling function/context, not in download() --- .../rootfs/rootfs-stage31/data/bin/setup_stage32 | 2 +- .../rootfs/rootfs-stage31/data/etc/functions.inc | 47 +++++++++++----------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 index bc00b830..cf20fbf5 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 +++ b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 @@ -34,7 +34,7 @@ STAGE32_TARGET_PATH="/stage32.sqfs" STAGE32_MOUNT_POINT="/rorootfs" # try to download it -download "${SLX_BASE_PATH}/stage32.sqfs" "$STAGE32_TARGET_PATH" || return 1 +download "${SLX_BASE_PATH}/stage32.sqfs" "$STAGE32_TARGET_PATH" || drop_shell "Could not download stage32!" # try to mount it at STAGE32_MOUNT_POINT echo "Mounting stage 3.2 as SquashFS..." diff --git a/remote/rootfs/rootfs-stage31/data/etc/functions.inc b/remote/rootfs/rootfs-stage31/data/etc/functions.inc index 362943ae..ce510aac 100644 --- a/remote/rootfs/rootfs-stage31/data/etc/functions.inc +++ b/remote/rootfs/rootfs-stage31/data/etc/functions.inc @@ -11,9 +11,9 @@ # drop_shell "This is your error message." # drop_shell() { - [ $# -gt 0 ] && echo $@ - echo "CTRL + D will continue booting." - setsid sh -c 'exec sh /dev/tty1 2>&1' + [ $# -gt 0 ] && echo $@ + echo "CTRL + D will continue booting." + setsid sh -c 'exec sh /dev/tty1 2>&1' } ######################################################################### @@ -28,7 +28,7 @@ read_from_cmdline(){ local OPTION="$1" local VALUE="" - + VALUE="$(grep -o -E "${OPTION}=\S+" /proc/cmdline | cut -c $((${#OPTION}+2))-)" if [ -z "$VALUE" ]; then echo "Error - '${OPTION}=' not found in command line, or empty" @@ -40,7 +40,7 @@ read_from_cmdline(){ ######################################################################### # -# Helper function to download given FILE_URL from servers in 'slxsrv' +# Helper function to download given FILE_URL from servers in 'slxsrv' # as given through the kernel command line. File will be saved under TARGET_PATH # # Usage: @@ -53,8 +53,8 @@ read_from_cmdline(){ # FILE_URL can have subpath, e.g. "ubuntu-13.04-x64/config" # download() { - [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguments, $# given." && return 1 - + [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguments, $# given." && return 1 + if [ -e "${FUTURE_ROOT}/opt/openslx/config" ]; then . "${FUTURE_ROOT}/opt/openslx/config" || echo "Error - could not source '${FUTURE_ROOT}/opt/openslx/config'" else @@ -62,31 +62,30 @@ download() { SLX_KCL_SERVERS="$(read_from_cmdline "slxsrv" | tr ',' ' ')" echo "SLX_KCL_SERVERS='$SLX_KCL_SERVERS'" >> "${FUTURE_ROOT}/opt/openslx/config" fi - - local FILE_URL="$1" - local TARGET_PATH="$2" - + + local FILE_URL="$1" + local TARGET_PATH="$2" + + # Shuffle server list local SERVERS=$(for SERVER in $SLX_CONFIG_SERVERS $SLX_KCL_SERVERS; do echo "$RANDOM $SERVER"; done | sort -u | sed -r 's/^[0-9]+ //') - - for TIMEOUT in 1 2 3 4 5; do + + for TIMEOUT in 1 1 4 4 10; do for SERVER in $SERVERS; do + rm -f "$TARGET_PATH" wget -T 5 -q -O "$TARGET_PATH" "http://${SERVER}/${FILE_URL}" RET=$? - if [ "x$RET" != "x0" ]; then + if [ "x$RET" != "x0" -o ! -e "$TARGET_PATH" ]; then echo "Error - downloading 'http://$SERVER/$FILE_URL' via wget failed. Exit Code: $RET" - echo "Trying again in $(($TIMEOUT * 500)) ms..." - [ $TIMEOUT -eq 5 ] && drop_shell "Max timeouts reached. Dropping shell..." - usleep $(($TIMEOUT * 500000)) + usleep 50000 # 50ms else - [ "x$DEBUG" != "x" ] && echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'." + echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'." return 0 fi done + echo "Trying again in $(($TIMEOUT * 250)) ms..." + usleep $(($TIMEOUT * 250000)) done - - # check if it actually worked - if [ ! -e $TARGET_PATH ]; then - echo "Error - $TARGET_PATH does not exists. Downloading '$FILE_URL' from '$SERVER_LIST' failed." - return 1 - fi + # Max retries reached, no success :-( + return 1 } + -- cgit v1.2.3-55-g7522