From 3bcd6f69e7ad6740b18b1cb1ac25f3d6763cd784 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 1 Aug 2013 16:14:18 +0200 Subject: add new option '-k' to build config.tgz for given type. Example: ./mltk server -k freiburg --- mltk | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/mltk b/mltk index 28578381..ee965f49 100755 --- a/mltk +++ b/mltk @@ -162,7 +162,7 @@ read_params() { if [[ $1 != "-"* ]]; then TARGET=$1 shift - elif [[ $1 != "-s" ]] && [[ $1 != "-n" ]]; then + elif [[ $1 != "-s" && $1 != "-n" && $1 != "-k" ]]; then perror "A target is required. None given." fi @@ -174,9 +174,16 @@ read_params() { # options to current target if [[ "$PARAM" == "-"* ]]; then case "$PARAM" in + -k) + [ "$MODE" != "SERVER" ] && perror "-k can only be used in server mode" + # NOTE: check for validity of config is done in 'inital_checks' of server/export_target + SERVER_CONFIG_TYPE="$1" + SERVER_CONFIG="1" + shift + continue + ;; -s) SERVER_SYNC="1" - #TODO mit Remote IP continue ;; -c) @@ -206,8 +213,6 @@ read_params() { SERVER_EXPORT="1" SERVER_EXPORT_TYPE="$1" shift - SERVER_EXPORT_CONFIG="$1" - shift continue ;; -n) @@ -242,7 +247,7 @@ read_params() { # exit if no command - [[ $SERVER_CLEAN == 0 && $SERVER_EXPORT == 0 && $REMOTE_CLEAN == 0 && $REMOTE_BUILD == 0 && $SERVER_SYNC == 0 && $REMOTE_EXPORT == 0 ]] && print_usage && exit 1 + [[ $SERVER_CLEAN == 0 && $SERVER_EXPORT == 0 && $REMOTE_CLEAN == 0 && $REMOTE_BUILD == 0 && $SERVER_SYNC == 0 && $REMOTE_EXPORT == 0 && $SERVER_CONFIG == 0 ]] && print_usage && exit 1 } run() { @@ -253,12 +258,13 @@ run() { [[ $REMOTE_BUILD == 1 ]] && generate_target $TARGET $REMOTE_LIST_BUILD [[ $REMOTE_EXPORT == 1 ]] && export_builds fi - if [[ $SERVER_CLEAN == 1 || $SERVER_EXPORT == 1 || $SERVER_SYNC == 1 ]]; then + if [[ $SERVER_CLEAN == 1 || $SERVER_EXPORT == 1 || $SERVER_SYNC == 1 || $SERVER_CONFIG == 1 ]]; then [[ $SERVER_DEBUG == 1 ]] && unset_quiet || set_quiet . "${SERVER_EXPORT_TARGET}" || perror "Cannot source ${SERVER_EXPORT_TARGET}" [[ $SERVER_SYNC == 1 ]] && sync_remote [[ $SERVER_CLEAN == 1 ]] && clean_target $TARGET [[ $SERVER_EXPORT == 1 ]] && export_target $TARGET $SERVER_EXPORT_TYPE + [[ $SERVER_CONFIG == 1 ]] && echo "LASFKHSL" && generate_config $SERVER_CONFIG_TYPE fi } @@ -267,6 +273,7 @@ SERVER_EXPORT="0" SERVER_CLEAN="0" SERVER_EXPORT_TYPE="" SERVER_SYNC="0" +SERVER_CONFIG="0" REMOTE_DEBUG="0" REMOTE_CLEAN="0" REMOTE_BUILD="0" -- cgit v1.2.3-55-g7522 From d515b42421bd5781bcec98cea1e76b36cb3dbfa8 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 1 Aug 2013 16:18:33 +0200 Subject: [mltk-server] added check when merging different module config together to find possible conflicts. Also changed the way the config.tgz is built: now it generates under server/local_builds//configs// tarballs for all the modules, and merges them together at the end --- server/export_target | 117 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 75 insertions(+), 42 deletions(-) diff --git a/server/export_target b/server/export_target index fd4112b6..970ee0d9 100755 --- a/server/export_target +++ b/server/export_target @@ -33,12 +33,12 @@ initial_checks() { local TOOL_STR="$TOOL_STR initial_checks:" - [ ! -d "${SERVER_BOOT_DIR}" ] && mkdir -p "${SERVER_BOOT_DIR}" + [ -d "${SERVER_BOOT_DIR}" ] || mkdir -p "${SERVER_BOOT_DIR}" # check if SERVER_EXPORT_TARGET is valid - if [ ! -d "${SERVER_CONFIGS_DIR}/${SERVER_EXPORT_CONFIG}" ]; then + [ ! -z "${SERVER_EXPORT_CONFIG}" ] || perror "Server export config not given!" + [ -d "${SERVER_CONFIGS_DIR}/${SERVER_EXPORT_CONFIG}" ] || \ perror "Given export config not found: ${SERVER_CONFIGS_DIR}/${SERVER_EXPORT_CONFIG}" - fi } copy_kernel() { @@ -88,55 +88,89 @@ generate_addons() { generate_config() { # generate config from the target directory local TOOL_STR="${TOOL_STR} generate_config:" - pinfo "Generating config.tgz for '$SERVER_EXPORT_CONFIG'" - - local TARGET_CONFIG="${SERVER_CONFIGS_DIR}/${SERVER_EXPORT_CONFIG}" - - # its not possible to append files to a compressed tar archiv, so start with - # a simple tar which we will gzip at the end. + pinfo "Generating config.tgz for '${SERVER_CONFIG_TYPE}'" - local TARGET_CONFIG_PATH="${SERVER_CONFIGS_DIR}/config.tar" - local TARGET_COMPRESSED_CONFIG_PATH="${SERVER_CONFIGS_DIR}/config.tgz" + # directory where the activated modules are given + # ex: server/configs/freiburg/ + local TARGET_CONFIG_DIR="${SERVER_CONFIGS_DIR}/${SERVER_CONFIG_TYPE}" - [ -e "$TARGET_COMPRESSED_CONFIG_PATH" ] && rm -f "$TARGET_COMPRESSED_CONFIG_PATH" - - for MODULE_CONFIG in $(ls "$TARGET_CONFIG"); do + # directory where the generated config.tgz will land + local TARGET_CONFIG_FINAL_DIR="${SERVER_BOOT_DIR}/configs/${SERVER_CONFIG_TYPE}" + [ ! -d "$TARGET_CONFIG_FINAL_DIR" ] && mkdir -p "$TARGET_CONFIG_FINAL_DIR" + + # directory where the sub-archives of modules will be built + local TARGET_CONFIG_BUILD_DIR="${SERVER_BUILD_DIR}/configs/${SERVER_CONFIG_TYPE}" + # always clean the build dir + rm -rf "$TARGET_CONFIG_BUILD_DIR" && mkdir -p "$TARGET_CONFIG_BUILD_DIR" + + local TARGET_CONFIG_PATH="${TARGET_CONFIG_FINAL_DIR}/config.tar" + local TARGET_CONFIG_FINAL_PATH="${TARGET_CONFIG_FINAL_DIR}/config.tgz" + [ -e "$TARGET_CONFIG_PATH" ] && rm -f "$TARGET_CONFIG_PATH" + [ -e "$TARGET_CONFIG_FINAL_PATH" ] && rm -f "$TARGET_CONFIG_FINAL_PATH" + + # now go over the activated modules and pack the contents into the tar archive + for MODULE_CONFIG in $(ls "$TARGET_CONFIG_DIR"); do + pinfo "\tGenerating sub-archive for '${MODULE_CONFIG}'" # add files in that directory to config.tgz - cd "$TARGET_CONFIG/$MODULE_CONFIG" || perror "Could not cd to $TARGET_CONFIG/$MODULE_CONFIG" - tar rf "${TARGET_CONFIG_PATH}" $(ls) + cd "${TARGET_CONFIG_DIR}/${MODULE_CONFIG}" || perror "\tCould not cd to '${TARGET_CONFIG_DIR}/${MODULE_CONFIG}'" + + # check if files are already in another module config + for FILE in $(find . -type f); do + # check for all the archives we find in TARGET_CONFIG_BUILD_DIR + for ARCHIV in $(ls "${TARGET_CONFIG_BUILD_DIR}/"*.tar 2>/dev/null); do + if [ "x$(tar tvf "${ARCHIV}" | grep "$FILE")" != "x" ]; then + # name of the module in conflict + local CONFLICTING_MODULE="$(basename ${ARCHIV%.tar})" + # file is present in archiv + pwarning "\tFile '${FILE#.}' is already present in module config of '${CONFLICTING_MODULE}'." + perror "\tResolve conflicts between '${CONFLICTING_MODULE}' and '${MODULE_CONFIG}', then try again." + fi + done + + done + + # no conflict, add file to archive + tar cf "${TARGET_CONFIG_BUILD_DIR}/${MODULE_CONFIG}.tar" $(ls) RET=$? - if [ "x$RET" != "x0" ]; then - # something went wrong - perror "Could not add files from $MODULE_CONFIG to $TARGET_CONFIG_PATH" - fi + [ "x$RET" != "x0" ] && perror "\tCould not create '${TARGET_CONFIG_BUILD_DIR}/${MODULE_CONFIG}.tgz'" done - # now gzip the tarball - gzip "${TARGET_CONFIG_PATH}" || perror "Could not gzip ${TARGET_CONFIG_PATH}" - mv "${TARGET_CONFIG_PATH}.gz" "${TARGET_COMPRESSED_CONFIG_PATH}" + # now we have packed all configs separately and can concatenate them all together. + pinfo "Merging all sub-archive into one" + for MODULE_CONFIG_ARCHIV in $(ls "${TARGET_CONFIG_BUILD_DIR}/"*.tar 2>/dev/null); do + tar Af "${TARGET_CONFIG_PATH}" "${MODULE_CONFIG_ARCHIV}" + RET=$? + [ "x$RET" != "x0" ] && perror "Could not merge '${MODULE_CONFIG_ARCHIV}' into '${TARGET_CONFIG_PATH}.tar'" + done + # now gzip everything + gzip "${TARGET_CONFIG_PATH}" || perror "Could not gzip '${TARGET_CONFIG_FINAL_PATH}'" + mv "${TARGET_CONFIG_PATH}.gz" "${TARGET_CONFIG_FINAL_PATH}" \ + || perror "Could not mv '${TARGET_CONFIG_PATH}.gz' to '${TARGET_CONFIG_FINAL_PATH}'" + + pinfo "Created config.tgz for '${SERVER_CONFIG_TYPE}' at '${TARGET_CONFIG_FINAL_PATH}'" } export_target() { -initial_checks -copy_kernel - -TARGET=$1 -[ -d ${SERVER_BUILD_DIR}/${TARGET} ] || perror "Given target directory does not exist: ${SERVER_BUILD_DIR}/${TARGET}" - -case "$2" in - stage31) - generate_stage31 - ;; - stage32) - generate_stage32 - generate_config - ;; - addons) - generate_addons - ;; -esac + initial_checks + copy_kernel + + TARGET=$1 + [ -d ${SERVER_BUILD_DIR}/${TARGET} ] || perror "Given target directory does not exist: ${SERVER_BUILD_DIR}/${TARGET}" + + case "$2" in + stage31) + generate_stage31 + ;; + stage32) + generate_stage32 + #generate_config + ;; + addons) + generate_addons + ;; + esac } @@ -155,4 +189,3 @@ clean_target() { pinfo "Cleaning '${SERVER_BOOT_DIR}/stage32_dqfs/mnt/${TARGET}.sqfs'..." [ -e "${SERVER_BOOT_DIR}/stage32_sqfs/mnt/${TARGET}.sqfs" ] && { rm "${SERVER_BOOT_DIR}/stage32_sqfs/mnt/${TARGET}.sqfs" || perror "rm failed."; } } - -- cgit v1.2.3-55-g7522 From 219db4c8d3798325c7a0ea9403b4e272019c6fba Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 1 Aug 2013 16:20:01 +0200 Subject: Renamed configs/freiburg/pam to configs/freiburg/pam-freiburg for cleaner structure. Added 'config.tgz' to .gitignore. Removed file added by accident --- server/.gitignore | 2 ++ server/configs/config.tgz | Bin 6661 -> 0 bytes server/configs/freiburg/pam | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 server/.gitignore delete mode 100644 server/configs/config.tgz delete mode 120000 server/configs/freiburg/pam diff --git a/server/.gitignore b/server/.gitignore new file mode 100644 index 00000000..3422c782 --- /dev/null +++ b/server/.gitignore @@ -0,0 +1,2 @@ +config.tgz + diff --git a/server/configs/config.tgz b/server/configs/config.tgz deleted file mode 100644 index 01ad15a6..00000000 Binary files a/server/configs/config.tgz and /dev/null differ diff --git a/server/configs/freiburg/pam b/server/configs/freiburg/pam deleted file mode 120000 index 4e851a8d..00000000 --- a/server/configs/freiburg/pam +++ /dev/null @@ -1 +0,0 @@ -../../modules/pam-freiburg \ No newline at end of file -- cgit v1.2.3-55-g7522 From 08f1167d099837e88c8b38809d07fe75c2a83580 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 1 Aug 2013 16:20:23 +0200 Subject: [mltk-server] freiburg pam config --- server/configs/freiburg/pam-freiburg | 1 + 1 file changed, 1 insertion(+) create mode 120000 server/configs/freiburg/pam-freiburg diff --git a/server/configs/freiburg/pam-freiburg b/server/configs/freiburg/pam-freiburg new file mode 120000 index 00000000..4e851a8d --- /dev/null +++ b/server/configs/freiburg/pam-freiburg @@ -0,0 +1 @@ +../../modules/pam-freiburg \ No newline at end of file -- cgit v1.2.3-55-g7522 From 3305ec59a2a15a94cf0d04fe06b2c6d9df480550 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 1 Aug 2013 16:23:23 +0200 Subject: [server] removed creation of config.tgz from generate_stage32 --- server/export_target | 1 - 1 file changed, 1 deletion(-) diff --git a/server/export_target b/server/export_target index 970ee0d9..3bda2ce6 100755 --- a/server/export_target +++ b/server/export_target @@ -165,7 +165,6 @@ export_target() { ;; stage32) generate_stage32 - #generate_config ;; addons) generate_addons -- cgit v1.2.3-55-g7522 From d480a569dc7a2106f702404b4a943f70c504e82a Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 1 Aug 2013 16:58:44 +0200 Subject: adapted new naming conventions for all the scripts. for our own systemd service files: use: service-file-name.service ex: /etc/systemd/system/setup-proxy.service ALL systemd services files need to be under /etc/systemd/system for our own scripts: use: tool-what_it_does ex: /opt/openslx/scripts/systemd-setup_proxy ALL our scripts under /opt/openslx/scripts --- .../data/etc/systemd/system/debug-shell.service | 1 - .../etc/systemd/system/load-german-keymap.service | 2 +- .../data/opt/openslx/scripts/load_german_keymaps | 22 --- .../openslx/scripts/systemd-load_german_keymaps | 22 +++ .../system/basic.target.wants/setup-proxy.service | 1 + .../system/basic.target.wants/setup_proxy.service | 1 - .../data/etc/systemd/system/setup-proxy.service | 9 ++ .../data/etc/systemd/system/setup_proxy.service | 9 -- .../redsocks/data/opt/openslx/scripts/setup_proxy | 51 ------ .../data/opt/openslx/scripts/systemd-setup_proxy | 51 ++++++ .../data/etc/systemd/system/nfs-mount.service | 2 +- .../data/etc/systemd/system/udhcpc@.service | 2 +- .../data/etc/systemd/system/var-lib-virt.service | 4 +- .../vmchooser/data/opt/openslx/bin/mount-lib-virt | 8 - .../opt/openslx/scripts/systemd-mount_vm_store | 8 + .../etc/systemd/system/download-config.service | 8 - .../etc/systemd/system/load-gfx-driver.service | 2 +- .../data/etc/systemd/system/mount-tmp.service | 10 -- .../data/etc/systemd/system/ntpdate.service | 2 +- .../etc/systemd/system/setup-partitions.service | 10 ++ .../system/sysinit.target.wants/mount-tmp.service | 1 - .../sysinit.target.wants/setup-partitions.service | 1 + .../data/opt/openslx/bin/mountexport | 17 -- .../rootfs-stage32/data/opt/openslx/bin/nettime | 22 --- .../data/opt/openslx/bin/udhcpc.openslx.script | 174 --------------------- .../data/opt/openslx/scripts/analyse-disk | 111 ------------- .../rootfs-stage32/data/opt/openslx/scripts/dhcp++ | 10 -- .../data/opt/openslx/scripts/load-gfx-driver | 16 -- .../data/opt/openslx/scripts/mountexport | 17 -- .../data/opt/openslx/scripts/nettime | 22 --- .../opt/openslx/scripts/systemd-load_gfx_driver | 16 ++ .../data/opt/openslx/scripts/systemd-mount_export | 17 ++ .../opt/openslx/scripts/systemd-setup_network_time | 22 +++ .../opt/openslx/scripts/systemd-setup_partitions | 111 +++++++++++++ .../data/opt/openslx/scripts/systemd-udhcpc++ | 10 ++ .../data/opt/openslx/scripts/udhcpc-openslx | 174 +++++++++++++++++++++ .../data/opt/openslx/scripts/udhcpc-openslx-script | 174 --------------------- 37 files changed, 459 insertions(+), 681 deletions(-) delete mode 100755 remote/modules/german/data/opt/openslx/scripts/load_german_keymaps create mode 100755 remote/modules/german/data/opt/openslx/scripts/systemd-load_german_keymaps create mode 120000 remote/modules/redsocks/data/etc/systemd/system/basic.target.wants/setup-proxy.service delete mode 120000 remote/modules/redsocks/data/etc/systemd/system/basic.target.wants/setup_proxy.service create mode 100644 remote/modules/redsocks/data/etc/systemd/system/setup-proxy.service delete mode 100644 remote/modules/redsocks/data/etc/systemd/system/setup_proxy.service delete mode 100755 remote/modules/redsocks/data/opt/openslx/scripts/setup_proxy create mode 100755 remote/modules/redsocks/data/opt/openslx/scripts/systemd-setup_proxy delete mode 100755 remote/modules/vmchooser/data/opt/openslx/bin/mount-lib-virt create mode 100755 remote/modules/vmchooser/data/opt/openslx/scripts/systemd-mount_vm_store delete mode 100644 remote/rootfs/rootfs-stage32/data/etc/systemd/system/download-config.service delete mode 100644 remote/rootfs/rootfs-stage32/data/etc/systemd/system/mount-tmp.service create mode 100644 remote/rootfs/rootfs-stage32/data/etc/systemd/system/setup-partitions.service delete mode 120000 remote/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/mount-tmp.service create mode 120000 remote/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-partitions.service delete mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/bin/mountexport delete mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/bin/nettime delete mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script delete mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/analyse-disk delete mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/dhcp++ delete mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/load-gfx-driver delete mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/mountexport delete mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/nettime create mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-load_gfx_driver create mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export create mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_network_time create mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions create mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-udhcpc++ create mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/udhcpc-openslx delete mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/udhcpc-openslx-script diff --git a/remote/modules/debug/data/etc/systemd/system/debug-shell.service b/remote/modules/debug/data/etc/systemd/system/debug-shell.service index fedd138d..6d50b3bd 100644 --- a/remote/modules/debug/data/etc/systemd/system/debug-shell.service +++ b/remote/modules/debug/data/etc/systemd/system/debug-shell.service @@ -12,7 +12,6 @@ DefaultDependencies=no IgnoreOnIsolate=yes [Service] -Environment=TERM=linux PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin:/opt/openslx/usr/sbin:/opt/openslx/usr/bin ExecStart=/bin/sh Restart=always RestartSec=0 diff --git a/remote/modules/german/data/etc/systemd/system/load-german-keymap.service b/remote/modules/german/data/etc/systemd/system/load-german-keymap.service index e31406fb..c26346fe 100644 --- a/remote/modules/german/data/etc/systemd/system/load-german-keymap.service +++ b/remote/modules/german/data/etc/systemd/system/load-german-keymap.service @@ -7,4 +7,4 @@ Before=shutdown.target [Service] Type=oneshot RemainAfterExit=yes -ExecStart=/opt/openslx/scripts/load_german_keymaps +ExecStart=/opt/openslx/scripts/systemd-load_german_keymaps diff --git a/remote/modules/german/data/opt/openslx/scripts/load_german_keymaps b/remote/modules/german/data/opt/openslx/scripts/load_german_keymaps deleted file mode 100755 index c7dbbb33..00000000 --- a/remote/modules/german/data/opt/openslx/scripts/load_german_keymaps +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Script serves as container script for a systemd-call due to the buggyness of several -# loadkeys-implementations <= kbd (Linux keyboard tools) 1.15.3. -# This bug can be detected through failure of the command pipe 'dumpkeys|loadkeys' yielding -# the message "unknown keysym 'compose'. - -# So we first try to insert a keymap including compose-lines: -loadkeys /opt/openslx/keymaps/german_qwertz_compose_keyboard_translation.map -ERR=$? - -# ... if this fails we enter a keymap without compose-lines: -if [[ "$ERR" -eq 0 ]]; then - exit 0 # in that case everything went smooth - exit. -else - loadkeys /opt/openslx/keymaps/german_qwertz_keyboard_translation.map # insert a keymap without compose lines - ERR=$? -fi - -# if at this point the second keymap insertion failed we pass the errorlevel to -# systemd - we cannot do more at this point. - -exit $ERR diff --git a/remote/modules/german/data/opt/openslx/scripts/systemd-load_german_keymaps b/remote/modules/german/data/opt/openslx/scripts/systemd-load_german_keymaps new file mode 100755 index 00000000..c7dbbb33 --- /dev/null +++ b/remote/modules/german/data/opt/openslx/scripts/systemd-load_german_keymaps @@ -0,0 +1,22 @@ +#!/bin/bash +# Script serves as container script for a systemd-call due to the buggyness of several +# loadkeys-implementations <= kbd (Linux keyboard tools) 1.15.3. +# This bug can be detected through failure of the command pipe 'dumpkeys|loadkeys' yielding +# the message "unknown keysym 'compose'. + +# So we first try to insert a keymap including compose-lines: +loadkeys /opt/openslx/keymaps/german_qwertz_compose_keyboard_translation.map +ERR=$? + +# ... if this fails we enter a keymap without compose-lines: +if [[ "$ERR" -eq 0 ]]; then + exit 0 # in that case everything went smooth - exit. +else + loadkeys /opt/openslx/keymaps/german_qwertz_keyboard_translation.map # insert a keymap without compose lines + ERR=$? +fi + +# if at this point the second keymap insertion failed we pass the errorlevel to +# systemd - we cannot do more at this point. + +exit $ERR diff --git a/remote/modules/redsocks/data/etc/systemd/system/basic.target.wants/setup-proxy.service b/remote/modules/redsocks/data/etc/systemd/system/basic.target.wants/setup-proxy.service new file mode 120000 index 00000000..0da8d078 --- /dev/null +++ b/remote/modules/redsocks/data/etc/systemd/system/basic.target.wants/setup-proxy.service @@ -0,0 +1 @@ +../setup-proxy.service \ No newline at end of file diff --git a/remote/modules/redsocks/data/etc/systemd/system/basic.target.wants/setup_proxy.service b/remote/modules/redsocks/data/etc/systemd/system/basic.target.wants/setup_proxy.service deleted file mode 120000 index 0c7dc84b..00000000 --- a/remote/modules/redsocks/data/etc/systemd/system/basic.target.wants/setup_proxy.service +++ /dev/null @@ -1 +0,0 @@ -../setup_proxy.service \ No newline at end of file diff --git a/remote/modules/redsocks/data/etc/systemd/system/setup-proxy.service b/remote/modules/redsocks/data/etc/systemd/system/setup-proxy.service new file mode 100644 index 00000000..54052425 --- /dev/null +++ b/remote/modules/redsocks/data/etc/systemd/system/setup-proxy.service @@ -0,0 +1,9 @@ +[Unit] +Description=Proxy setup detection +Before=shutdown.target +DefaultDependencies=no + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/systemd-setup_proxy +RemainAfterExit=yes diff --git a/remote/modules/redsocks/data/etc/systemd/system/setup_proxy.service b/remote/modules/redsocks/data/etc/systemd/system/setup_proxy.service deleted file mode 100644 index 2a06058b..00000000 --- a/remote/modules/redsocks/data/etc/systemd/system/setup_proxy.service +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=Proxy setup detection -Before=shutdown.target -DefaultDependencies=no - -[Service] -Type=oneshot -ExecStart=/opt/openslx/scripts/setup_proxy -RemainAfterExit=yes diff --git a/remote/modules/redsocks/data/opt/openslx/scripts/setup_proxy b/remote/modules/redsocks/data/opt/openslx/scripts/setup_proxy deleted file mode 100755 index 6c39c077..00000000 --- a/remote/modules/redsocks/data/opt/openslx/scripts/setup_proxy +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -for wait in 1 1 2 3 4 6 8 10 end; do - grep '^#_RCONFIG_TAG$' /opt/openslx/config > /dev/null && echo "Config found!" && break - [ "$wait" == "end" ] && echo "Giving up!" && exit 1 - echo "No config yet..." - sleep $wait -done - -. /opt/openslx/config || echo "Error sourcing config for setup_proxy" - -[ -z "$SLX_PROXY_MODE" -o "x$SLX_PROXY_MODE" == "xoff" ] && echo "proxy mode disabled." && exit 0 - -PROXY=off -if [ "$SLX_PROXY_MODE" == "on" ]; then - PROXY=on -elif [ "$SLX_PROXY_MODE" == "auto" -a -n "$SLX_PXE_CLIENT_IP" ]; then - [[ "$SLX_PXE_CLIENT_IP" =~ ^10\. ]] && PROXY=on - [[ "$SLX_PXE_CLIENT_IP" =~ ^192\.168\. ]] && PROXY=on - [[ "$SLX_PXE_CLIENT_IP" =~ ^172\.[123] ]] && PROXY=on -fi - -[ "$PROXY" == "off" ] && echo "Proxy mode not required." && exit 0 - -sed -i "s/%%PROXY_IP%%/$SLX_PROXY_IP/g;s/%%PROXY_PORT%%/$SLX_PROXY_PORT/g;s/%%PROXY_TYPE%%/$SLX_PROXY_TYPE/g" /etc/redsocks.conf - -mkdir -p /run/redsocks -chown redsocks:redsocks /run/redsocks -systemctl start redsocks - -iptables -t nat -N REDSOCKS -iptables -t nat -A REDSOCKS -d "$SLX_PROXY_IP" -j RETURN -iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN -iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN -iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN -iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN -iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN -iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN -iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN -iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN -if [ -n "$SLX_PROXY_BLACKLIST" ]; then - for ADDR in $SLX_PROXY_BLACKLIST; do - iptables -t nat -A REDSOCKS -d "$ADDR" -j RETURN - done -fi -iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-port 12345 -iptables -t nat -A PREROUTING -p tcp -j REDSOCKS -iptables -t nat -A OUTPUT -p tcp -j REDSOCKS -iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE -iptables -A INPUT -i br0 -p tcp --dport 12345 -j DROP - diff --git a/remote/modules/redsocks/data/opt/openslx/scripts/systemd-setup_proxy b/remote/modules/redsocks/data/opt/openslx/scripts/systemd-setup_proxy new file mode 100755 index 00000000..6c39c077 --- /dev/null +++ b/remote/modules/redsocks/data/opt/openslx/scripts/systemd-setup_proxy @@ -0,0 +1,51 @@ +#!/bin/bash + +for wait in 1 1 2 3 4 6 8 10 end; do + grep '^#_RCONFIG_TAG$' /opt/openslx/config > /dev/null && echo "Config found!" && break + [ "$wait" == "end" ] && echo "Giving up!" && exit 1 + echo "No config yet..." + sleep $wait +done + +. /opt/openslx/config || echo "Error sourcing config for setup_proxy" + +[ -z "$SLX_PROXY_MODE" -o "x$SLX_PROXY_MODE" == "xoff" ] && echo "proxy mode disabled." && exit 0 + +PROXY=off +if [ "$SLX_PROXY_MODE" == "on" ]; then + PROXY=on +elif [ "$SLX_PROXY_MODE" == "auto" -a -n "$SLX_PXE_CLIENT_IP" ]; then + [[ "$SLX_PXE_CLIENT_IP" =~ ^10\. ]] && PROXY=on + [[ "$SLX_PXE_CLIENT_IP" =~ ^192\.168\. ]] && PROXY=on + [[ "$SLX_PXE_CLIENT_IP" =~ ^172\.[123] ]] && PROXY=on +fi + +[ "$PROXY" == "off" ] && echo "Proxy mode not required." && exit 0 + +sed -i "s/%%PROXY_IP%%/$SLX_PROXY_IP/g;s/%%PROXY_PORT%%/$SLX_PROXY_PORT/g;s/%%PROXY_TYPE%%/$SLX_PROXY_TYPE/g" /etc/redsocks.conf + +mkdir -p /run/redsocks +chown redsocks:redsocks /run/redsocks +systemctl start redsocks + +iptables -t nat -N REDSOCKS +iptables -t nat -A REDSOCKS -d "$SLX_PROXY_IP" -j RETURN +iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN +iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN +iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN +iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN +iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN +iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN +iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN +iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN +if [ -n "$SLX_PROXY_BLACKLIST" ]; then + for ADDR in $SLX_PROXY_BLACKLIST; do + iptables -t nat -A REDSOCKS -d "$ADDR" -j RETURN + done +fi +iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-port 12345 +iptables -t nat -A PREROUTING -p tcp -j REDSOCKS +iptables -t nat -A OUTPUT -p tcp -j REDSOCKS +iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE +iptables -A INPUT -i br0 -p tcp --dport 12345 -j DROP + diff --git a/remote/modules/systemd/data/etc/systemd/system/nfs-mount.service b/remote/modules/systemd/data/etc/systemd/system/nfs-mount.service index 0d537e2a..d597fa4b 100644 --- a/remote/modules/systemd/data/etc/systemd/system/nfs-mount.service +++ b/remote/modules/systemd/data/etc/systemd/system/nfs-mount.service @@ -4,4 +4,4 @@ Description=Mount NFS Share [TEST] [Service] Type=oneshot RemainAfterExit=yes -ExecStart=/opt/openslx/scripts/mountexport +ExecStart=/opt/openslx/scripts/systemd-mount_export diff --git a/remote/modules/systemd/data/etc/systemd/system/udhcpc@.service b/remote/modules/systemd/data/etc/systemd/system/udhcpc@.service index a7d6c324..0b198476 100644 --- a/remote/modules/systemd/data/etc/systemd/system/udhcpc@.service +++ b/remote/modules/systemd/data/etc/systemd/system/udhcpc@.service @@ -4,7 +4,7 @@ Description=DHCP Client [Service] Type=forking PIDFile=/run/udhcpc/udhcpc.%I.pid -ExecStart=/opt/openslx/scripts/dhcp++ %I +ExecStart=/opt/openslx/scripts/systemd-udhcpc++ %I ExecStopPost=/bin/rm /run/udhcpc/udhcpc.%I.pid [Install] diff --git a/remote/modules/vmchooser/data/etc/systemd/system/var-lib-virt.service b/remote/modules/vmchooser/data/etc/systemd/system/var-lib-virt.service index 8746629c..cfaa7af8 100644 --- a/remote/modules/vmchooser/data/etc/systemd/system/var-lib-virt.service +++ b/remote/modules/vmchooser/data/etc/systemd/system/var-lib-virt.service @@ -1,5 +1,5 @@ [Unit] -Description=Mount vm-store NFS +Description=Mount VM store per NFS After=download-config.service network.target Requires=network.target DefaultDependencies=no @@ -7,4 +7,4 @@ ConditionPathExists=/run/udhcpc/network-ready [Service] Type=oneshot -ExecStart=/opt/openslx/bin/mount-lib-virt +ExecStart=/opt/openslx/scripts/systemd-mount_vm_store diff --git a/remote/modules/vmchooser/data/opt/openslx/bin/mount-lib-virt b/remote/modules/vmchooser/data/opt/openslx/bin/mount-lib-virt deleted file mode 100755 index 27a8f55c..00000000 --- a/remote/modules/vmchooser/data/opt/openslx/bin/mount-lib-virt +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -. /opt/openslx/config || exit 1 - -export PATH="$PATH:/opt/openslx/bin:/opt/openslx/usr/bin:/opt/openslx/sbin:/opt/openslx/usr/sbin" - -mkdir -p /var/lib/virt -mount -t nfs -o ro,async,nolock,vers=3 "$SLX_VM_NFS" /var/lib/virt diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-mount_vm_store b/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-mount_vm_store new file mode 100755 index 00000000..27a8f55c --- /dev/null +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-mount_vm_store @@ -0,0 +1,8 @@ +#!/bin/bash + +. /opt/openslx/config || exit 1 + +export PATH="$PATH:/opt/openslx/bin:/opt/openslx/usr/bin:/opt/openslx/sbin:/opt/openslx/usr/sbin" + +mkdir -p /var/lib/virt +mount -t nfs -o ro,async,nolock,vers=3 "$SLX_VM_NFS" /var/lib/virt diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/download-config.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/download-config.service deleted file mode 100644 index ef8fb438..00000000 --- a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/download-config.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=Parse kernel command line for config URL and download -DefaultDependencies=no - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/opt/openslx/scripts/activate-sysconfig diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/load-gfx-driver.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/load-gfx-driver.service index 93641cee..0534f45c 100644 --- a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/load-gfx-driver.service +++ b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/load-gfx-driver.service @@ -5,5 +5,5 @@ DefaultDependencies=no [Service] Type=oneshot -ExecStart=/opt/openslx/scripts/load-gfx-driver +ExecStart=/opt/openslx/scripts/systemd-load_gfx_driver RemainAfterExit=yes diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/mount-tmp.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/mount-tmp.service deleted file mode 100644 index 070e3e1f..00000000 --- a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/mount-tmp.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Mount hard drive as tmp -After=sysinit.target -Before=shutdown.target -DefaultDependencies=no - -[Service] -Type=oneshot -ExecStart=/opt/openslx/scripts/analyse-disk -RemainAfterExit=yes diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/ntpdate.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/ntpdate.service index 69b1ba33..a48375d0 100644 --- a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/ntpdate.service +++ b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/ntpdate.service @@ -7,4 +7,4 @@ ConditionPathExists=/run/udhcpc/network-ready [Service] Type=oneshot RemainAfterExit=yes -ExecStart=/opt/openslx/scripts/nettime +ExecStart=/opt/openslx/scripts/systemd-setup_network_time diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/setup-partitions.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/setup-partitions.service new file mode 100644 index 00000000..20e789a4 --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/setup-partitions.service @@ -0,0 +1,10 @@ +[Unit] +Description=Setup local disk partitions (tmp, swap) +After=sysinit.target +Before=shutdown.target +DefaultDependencies=no + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/systemd-setup_partitions +RemainAfterExit=yes diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/mount-tmp.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/mount-tmp.service deleted file mode 120000 index 8ebb27be..00000000 --- a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/mount-tmp.service +++ /dev/null @@ -1 +0,0 @@ -../mount-tmp.service \ No newline at end of file diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-partitions.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-partitions.service new file mode 120000 index 00000000..af2957f8 --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-partitions.service @@ -0,0 +1 @@ +../setup-partitions.service \ No newline at end of file diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/mountexport b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/mountexport deleted file mode 100755 index 64d5f485..00000000 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/mountexport +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -export PATH=$PATH:/opt/openslx/usr/sbin:/opt/openslx/usr/bin:/opt/openslx/sbin:/opt/openslx/bin - -if grep "Ubuntu 13.04" "/etc/issue" >/dev/null; then - EXPORT="132.230.8.113:/srv/ubuntu1304" -elif grep "SUSE" "/etc/issue" >/dev/null; then - EXPORT="132.230.8.113:/srv/suse" -else - echo "Could not determine System" - exit 1 -fi - -echo "Mounting ${EXPORT} to /opt/openslx/mnt" -mount -t nfs -o ro,async,nolock,vers=3 "$EXPORT" /opt/openslx/mnt || { echo "Fail." && exit 1; } -echo "Appending /opt/openslx/mnt to /" -mount -o remount,append:/opt/openslx/mnt=ro / || { echo "Fail." && exit 1; } diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/nettime b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/nettime deleted file mode 100755 index 3ca13931..00000000 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/nettime +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -. /opt/openslx/config || { echo "Could not source config!"; exit 1; } -SLX_NTP_SERVER="$SLX_NTP_SERVER time.uni-freiburg.de 0.de.pool.ntp.org" -for SERVER in $SLX_NTP_SERVER; do - if ntpdate -u -b "$SERVER"; then - echo "Successfully queried $SERVER for time." - if [ "x$SLX_BIOS_CLOCK" = "xlocal" ]; then - sleep 1 - hwclock -l -w || echo "... but could not set BIOS clock to localtime" - elif [ "x$SLX_BIOS_CLOCK" = "xutc" ]; then - sleep 1 - hwclock -u -w || echo "... but could not set BIOS clock to UTC" - fi - exit 0 - fi - echo "Error querying $SERVER for current time" -done - -echo "No more servers to try. No NTP server was reachable." >&2 -exit 1 - diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script deleted file mode 100755 index 1bbf6e80..00000000 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script +++ /dev/null @@ -1,174 +0,0 @@ -#!/bin/bash -# ----------------------------------------------------------------------------- -# -# Copyright (c) 2011 - 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 suggestions, praise, or complaints to feedback@openslx.org -# -# General information about OpenSLX can be found at http://openslx.org/ -# ----------------------------------------------------------------------------- -# -# Mini-Linux Toolkit -# -# ----------------------------------------------------------------------------- - -. /opt/openslx/config - -RESOLV_CONF="/etc/resolv.conf" -THISFILE="/run/udhcpc/${interface}.resolv" - -echo "$interface [$1] $ip" >> "/tmp/udhcpclog" - -rebuild_resolv_conf () { - # Maybe make this smarter some time, if anyone is using client's that are on multiple networks at once etc... - # This is a little braindead but should work most of the time - sort -u /run/udhcpc/*.resolv > "$RESOLV_CONF" -} - -escape_search() { - echo "$@" | sed -e 's/[]\/()$*.^|[]/\\&/g' -} - -escape_replace() { - echo "$@" | sed -e 's/[\/&]/\\&/g' -} - -case "$1" in - bound|renew) - ip addr add "$ip/$(ipcalc -s -p $ip $subnet|sed s/.*=//)" dev "$interface" - if [ -n "$router" ]; then - ip route add default via "$router" - fi - - # Update resolver configuration file - CONF="" - if [ -n "$domain" ]; then - printf -v CONF "domain $domain\nsearch $domain\n" - elif [ -n "$SLX_NET_DOMAIN" ]; then - printf -v CONF "domain $SLX_NET_DOMAIN\nsearch $SLX_NET_DOMAIN\n" - fi - for i in $dns; do - echo "$0: Adding DNS $i" - printf -v CONF "${CONF}nameserver $i\n" - done - - if [ -x /sbin/resolvconf ]; then - # Automatic handling :-) - echo -n "$CONF" | resolvconf -a "${interface}.udhcpc" - else - # Manual handling required :-( - mkdir -p "/run/udhcpc" - echo -n "$CONF" > "$THISFILE" - rebuild_resolv_conf - fi - - # Things that should only happen for the main interface that was used for booting - if [ "$interface" == "br0" ]; then - #update ip - sed -i "s/^\(SLX_PXE_CLIENT_IP=\).*$/\1'$ip'/" /opt/openslx/config - - #update hostname - dns_host=$(rdns "$ip") - if [ -z "$dns_host" ]; then - # fallback to what the dhcp told us - dns_host="$hostname" - fi - if [ -n "$dns_host" ]; then - echo "$dns_host" > "/proc/sys/kernel/hostname" - echo "$dns_host" > "/etc/hostname" - if grep '^SLX_HOSTNAME=' /opt/openslx/config 2>/dev/null; then - sed -i "s/^\(SLX_HOSTNAME=\).*$/\1'$dns_host'/" /opt/openslx/config - else - echo "# Config written by openslx-dhcp-script (1)" >> /opt/openslx/config - echo "SLX_HOSTNAME='$dns_host'" >> /opt/openslx/config - fi - fi - fi - - # Hostname in /etc/hosts - touch /etc/hosts - if [ -n "$dns_host" ]; then - short="${dns_host%%.*}" - [ "x$short" = "x$dns_host" ] && short="" - sed -i -r "s/\s$(escape_search "$dns_host")(\s|$)/ /g" /etc/hosts - [ -n "$short" ] && sed -i -r "s/\s$(escape_search "$short")(\s|$)/ /g" /etc/hosts - if grep -q -E "^$ip\s" /etc/hosts; then - sed -i "s/^$(escape_search "$ip")\s/$(escape_replace "$ip $dns_host $short ")/g" /etc/hosts - else - echo "$ip $dns_host $short" >> /etc/hosts - fi - fi - if [ -n "$hostname" -a "x$hostname" != "x$dns_host" ]; then - short="${hostname%%.*}" - [ "x$short" = "x$hostname" ] && short="" - sed -i -r "s/\s$(escape_search "$hostname")(\s|$)/ /g" /etc/hosts - [ -n "$short" ] && sed -i -r "s/\s$(escape_search "$short")(\s|$)/ /g" /etc/hosts - if grep -q -E "^$ip\s" /etc/hosts; then - sed -i "s/^$(escape_search "$ip")\s/$(escape_replace "$ip $hostname $short ")/g" /etc/hosts - else - echo "$ip $hostname $short" >> /etc/hosts - fi - fi - sed -i -r '/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s*$/d' /etc/hosts - - # We consider the network setup to be complete if an interface is being configured that - # has a default route and some dns servers set. - if [ -n "$router" ] && [ -n "$dns" ] && [ ! -e "/run/udhcpc/network-ready" ]; then - touch "/run/udhcpc/network-ready" - # Write to openslx-config - echo "# Config written by openslx-dhcp-script (2)" >> /opt/openslx/config - echo "SLX_DNS='$dns'" >> /opt/openslx/config - - # TODO: This mounts stage4. Current method is for testing purposes only. - # when going productive, this has to happen after user login, if the - # user selects a native linux session. - if [ "x$(grep -ci mount /proc/cmdline)" != "x0" ]; then - systemctl start nfs-mount.service & - fi - # Mark network target as reached - systemctl start network.target - fi - - ;; - - deconfig) - if [ $(grep -c "nfs=" /proc/cmdline) == 0 ]; then - echo 1 > "/proc/sys/net/ipv4/conf/$interface/promote_secondaries" - clientip=${ip%%:*} - ip addr del "$clientip/$(ipcalc -s -p $clientip $subnet|sed s/.*=//)" dev "$interface" - else - echo "NFS is active, not removing old ip adress. warning: lease may expire after a while." - fi - - if [ -x /sbin/resolvconf ]; then - # Automatic handling :-) - resolvconf -d "${interface}.udhcpc" - else - # Manual handling required :-( - rm -f "$THISFILE" - rebuild_resolv_conf - fi - - ;; - - leasefail) - echo "$0: Lease failed: $message" - - ;; - - nak) - echo "$0: Received a NAK: $message" - - ;; - - *) - echo "$0: Unknown udhcpc command: $1"; - exit 1; - - ;; -esac - diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/analyse-disk b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/analyse-disk deleted file mode 100755 index f162ec3a..00000000 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/analyse-disk +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash -# 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 autodetection script for OpenSLX linux stateless clients, -# detecting swap and special partitions - -############################################################################# - - -# 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 -} - -# Check for local harddisks and appropriate partitions -for waiting in 1 1 2 3 4; do - fdisk -l | sed -n "/^\/dev\//p" > "/etc/disk.partition" - [ -s "/etc/disk.partition" ] && break - sleep "$waiting" -done -echo "Partitions:" -cat "/etc/disk.partition" - -# Check for standard swap partitions and make them available to the system -for hdpartnr in $(sed -n -e "/ 82 /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do - echo -e "$hdpartnr\tswap\t\tswap\t\tdefaults\t 0 0" >> "/etc/fstab" - swapon "$hdpartnr" -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 $(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 -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 -done - -mount -a - diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/dhcp++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/dhcp++ deleted file mode 100755 index 8a03ce98..00000000 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/dhcp++ +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -NET_IF="$1" -NET_IP="$(ip addr show dev "${NET_IF}" | grep "inet " | awk -F " " '{print $2}' | awk -F "/" '{print $1}')" - -UDHCPC_OPTS="" -[ ! -z "$NET_IP" ] && UDHCPC_OPTS=" -r $NET_IP " -echo "udhcp++: running on $NET_IF with additional params $UDHCPC_OPTS" >> "/tmp/udhcpclog" -mkdir -p /run/udhcpc -/opt/openslx/sbin/udhcpc $UDHCPC_OPTS -O domain -O nissrv -O nisdomain -O wpad -t 8 -s /opt/openslx/scripts/udhcpc-openslx-script -i "$NET_IF" -p "/run/udhcpc/udhcpc.$NET_IF.pid" diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/load-gfx-driver b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/load-gfx-driver deleted file mode 100755 index 04fbea6e..00000000 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/load-gfx-driver +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -PCIFILE=/tmp/lspci-output - -if ! lspci -n > "$PCIFILE"; then - echo "lspci -n failed..." - exit 1 -fi - -if grep -E ' 8086:0152( |$)' "$PCIFILE" > /dev/null; then - echo "i915 - enable 3D" - echo -e "# Written by load-gfx-driver\nSLX_VMWARE_3D=yes" >> "/opt/openslx/config" -fi - -exit 0 - diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/mountexport b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/mountexport deleted file mode 100755 index 64d5f485..00000000 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/mountexport +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -export PATH=$PATH:/opt/openslx/usr/sbin:/opt/openslx/usr/bin:/opt/openslx/sbin:/opt/openslx/bin - -if grep "Ubuntu 13.04" "/etc/issue" >/dev/null; then - EXPORT="132.230.8.113:/srv/ubuntu1304" -elif grep "SUSE" "/etc/issue" >/dev/null; then - EXPORT="132.230.8.113:/srv/suse" -else - echo "Could not determine System" - exit 1 -fi - -echo "Mounting ${EXPORT} to /opt/openslx/mnt" -mount -t nfs -o ro,async,nolock,vers=3 "$EXPORT" /opt/openslx/mnt || { echo "Fail." && exit 1; } -echo "Appending /opt/openslx/mnt to /" -mount -o remount,append:/opt/openslx/mnt=ro / || { echo "Fail." && exit 1; } diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/nettime b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/nettime deleted file mode 100755 index 3ca13931..00000000 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/nettime +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -. /opt/openslx/config || { echo "Could not source config!"; exit 1; } -SLX_NTP_SERVER="$SLX_NTP_SERVER time.uni-freiburg.de 0.de.pool.ntp.org" -for SERVER in $SLX_NTP_SERVER; do - if ntpdate -u -b "$SERVER"; then - echo "Successfully queried $SERVER for time." - if [ "x$SLX_BIOS_CLOCK" = "xlocal" ]; then - sleep 1 - hwclock -l -w || echo "... but could not set BIOS clock to localtime" - elif [ "x$SLX_BIOS_CLOCK" = "xutc" ]; then - sleep 1 - hwclock -u -w || echo "... but could not set BIOS clock to UTC" - fi - exit 0 - fi - echo "Error querying $SERVER for current time" -done - -echo "No more servers to try. No NTP server was reachable." >&2 -exit 1 - diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-load_gfx_driver b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-load_gfx_driver new file mode 100755 index 00000000..04fbea6e --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-load_gfx_driver @@ -0,0 +1,16 @@ +#!/bin/bash + +PCIFILE=/tmp/lspci-output + +if ! lspci -n > "$PCIFILE"; then + echo "lspci -n failed..." + exit 1 +fi + +if grep -E ' 8086:0152( |$)' "$PCIFILE" > /dev/null; then + echo "i915 - enable 3D" + echo -e "# Written by load-gfx-driver\nSLX_VMWARE_3D=yes" >> "/opt/openslx/config" +fi + +exit 0 + diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export new file mode 100755 index 00000000..64d5f485 --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export @@ -0,0 +1,17 @@ +#!/bin/bash + +export PATH=$PATH:/opt/openslx/usr/sbin:/opt/openslx/usr/bin:/opt/openslx/sbin:/opt/openslx/bin + +if grep "Ubuntu 13.04" "/etc/issue" >/dev/null; then + EXPORT="132.230.8.113:/srv/ubuntu1304" +elif grep "SUSE" "/etc/issue" >/dev/null; then + EXPORT="132.230.8.113:/srv/suse" +else + echo "Could not determine System" + exit 1 +fi + +echo "Mounting ${EXPORT} to /opt/openslx/mnt" +mount -t nfs -o ro,async,nolock,vers=3 "$EXPORT" /opt/openslx/mnt || { echo "Fail." && exit 1; } +echo "Appending /opt/openslx/mnt to /" +mount -o remount,append:/opt/openslx/mnt=ro / || { echo "Fail." && exit 1; } diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_network_time b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_network_time new file mode 100755 index 00000000..3e644abd --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_network_time @@ -0,0 +1,22 @@ +#!/bin/sh + +. /opt/openslx/config || { echo "Could not source config!"; exit 1; } +SLX_NTP_SERVER="$SLX_NTP_SERVER 0.de.pool.ntp.org" +for SERVER in $SLX_NTP_SERVER; do + if ntpdate -u -b "$SERVER"; then + echo "Successfully queried $SERVER for time." + if [ "x$SLX_BIOS_CLOCK" = "xlocal" ]; then + sleep 1 + hwclock -l -w || echo "... but could not set BIOS clock to localtime" + elif [ "x$SLX_BIOS_CLOCK" = "xutc" ]; then + sleep 1 + hwclock -u -w || echo "... but could not set BIOS clock to UTC" + fi + exit 0 + fi + echo "Error querying $SERVER for current time" +done + +echo "No more servers to try. No NTP server was reachable." >&2 +exit 1 + 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 new file mode 100755 index 00000000..f162ec3a --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions @@ -0,0 +1,111 @@ +#!/bin/bash +# 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 autodetection script for OpenSLX linux stateless clients, +# detecting swap and special partitions + +############################################################################# + + +# 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 +} + +# Check for local harddisks and appropriate partitions +for waiting in 1 1 2 3 4; do + fdisk -l | sed -n "/^\/dev\//p" > "/etc/disk.partition" + [ -s "/etc/disk.partition" ] && break + sleep "$waiting" +done +echo "Partitions:" +cat "/etc/disk.partition" + +# Check for standard swap partitions and make them available to the system +for hdpartnr in $(sed -n -e "/ 82 /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do + echo -e "$hdpartnr\tswap\t\tswap\t\tdefaults\t 0 0" >> "/etc/fstab" + swapon "$hdpartnr" +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 $(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 +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 +done + +mount -a + diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-udhcpc++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-udhcpc++ new file mode 100755 index 00000000..ddb6759f --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-udhcpc++ @@ -0,0 +1,10 @@ +#!/bin/bash + +NET_IF="$1" +NET_IP="$(ip addr show dev "${NET_IF}" | grep "inet " | awk -F " " '{print $2}' | awk -F "/" '{print $1}')" + +UDHCPC_OPTS="" +[ ! -z "$NET_IP" ] && UDHCPC_OPTS=" -r $NET_IP " +echo "udhcp++: running on $NET_IF with additional params $UDHCPC_OPTS" >> "/tmp/udhcpclog" +mkdir -p /run/udhcpc +/opt/openslx/sbin/udhcpc $UDHCPC_OPTS -O domain -O nissrv -O nisdomain -O wpad -t 8 -s /opt/openslx/scripts/udhcpc-openslx -i "$NET_IF" -p "/run/udhcpc/udhcpc.$NET_IF.pid" diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/udhcpc-openslx b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/udhcpc-openslx new file mode 100755 index 00000000..1bbf6e80 --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/udhcpc-openslx @@ -0,0 +1,174 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# +# Copyright (c) 2011 - 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 suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# +# Mini-Linux Toolkit +# +# ----------------------------------------------------------------------------- + +. /opt/openslx/config + +RESOLV_CONF="/etc/resolv.conf" +THISFILE="/run/udhcpc/${interface}.resolv" + +echo "$interface [$1] $ip" >> "/tmp/udhcpclog" + +rebuild_resolv_conf () { + # Maybe make this smarter some time, if anyone is using client's that are on multiple networks at once etc... + # This is a little braindead but should work most of the time + sort -u /run/udhcpc/*.resolv > "$RESOLV_CONF" +} + +escape_search() { + echo "$@" | sed -e 's/[]\/()$*.^|[]/\\&/g' +} + +escape_replace() { + echo "$@" | sed -e 's/[\/&]/\\&/g' +} + +case "$1" in + bound|renew) + ip addr add "$ip/$(ipcalc -s -p $ip $subnet|sed s/.*=//)" dev "$interface" + if [ -n "$router" ]; then + ip route add default via "$router" + fi + + # Update resolver configuration file + CONF="" + if [ -n "$domain" ]; then + printf -v CONF "domain $domain\nsearch $domain\n" + elif [ -n "$SLX_NET_DOMAIN" ]; then + printf -v CONF "domain $SLX_NET_DOMAIN\nsearch $SLX_NET_DOMAIN\n" + fi + for i in $dns; do + echo "$0: Adding DNS $i" + printf -v CONF "${CONF}nameserver $i\n" + done + + if [ -x /sbin/resolvconf ]; then + # Automatic handling :-) + echo -n "$CONF" | resolvconf -a "${interface}.udhcpc" + else + # Manual handling required :-( + mkdir -p "/run/udhcpc" + echo -n "$CONF" > "$THISFILE" + rebuild_resolv_conf + fi + + # Things that should only happen for the main interface that was used for booting + if [ "$interface" == "br0" ]; then + #update ip + sed -i "s/^\(SLX_PXE_CLIENT_IP=\).*$/\1'$ip'/" /opt/openslx/config + + #update hostname + dns_host=$(rdns "$ip") + if [ -z "$dns_host" ]; then + # fallback to what the dhcp told us + dns_host="$hostname" + fi + if [ -n "$dns_host" ]; then + echo "$dns_host" > "/proc/sys/kernel/hostname" + echo "$dns_host" > "/etc/hostname" + if grep '^SLX_HOSTNAME=' /opt/openslx/config 2>/dev/null; then + sed -i "s/^\(SLX_HOSTNAME=\).*$/\1'$dns_host'/" /opt/openslx/config + else + echo "# Config written by openslx-dhcp-script (1)" >> /opt/openslx/config + echo "SLX_HOSTNAME='$dns_host'" >> /opt/openslx/config + fi + fi + fi + + # Hostname in /etc/hosts + touch /etc/hosts + if [ -n "$dns_host" ]; then + short="${dns_host%%.*}" + [ "x$short" = "x$dns_host" ] && short="" + sed -i -r "s/\s$(escape_search "$dns_host")(\s|$)/ /g" /etc/hosts + [ -n "$short" ] && sed -i -r "s/\s$(escape_search "$short")(\s|$)/ /g" /etc/hosts + if grep -q -E "^$ip\s" /etc/hosts; then + sed -i "s/^$(escape_search "$ip")\s/$(escape_replace "$ip $dns_host $short ")/g" /etc/hosts + else + echo "$ip $dns_host $short" >> /etc/hosts + fi + fi + if [ -n "$hostname" -a "x$hostname" != "x$dns_host" ]; then + short="${hostname%%.*}" + [ "x$short" = "x$hostname" ] && short="" + sed -i -r "s/\s$(escape_search "$hostname")(\s|$)/ /g" /etc/hosts + [ -n "$short" ] && sed -i -r "s/\s$(escape_search "$short")(\s|$)/ /g" /etc/hosts + if grep -q -E "^$ip\s" /etc/hosts; then + sed -i "s/^$(escape_search "$ip")\s/$(escape_replace "$ip $hostname $short ")/g" /etc/hosts + else + echo "$ip $hostname $short" >> /etc/hosts + fi + fi + sed -i -r '/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s*$/d' /etc/hosts + + # We consider the network setup to be complete if an interface is being configured that + # has a default route and some dns servers set. + if [ -n "$router" ] && [ -n "$dns" ] && [ ! -e "/run/udhcpc/network-ready" ]; then + touch "/run/udhcpc/network-ready" + # Write to openslx-config + echo "# Config written by openslx-dhcp-script (2)" >> /opt/openslx/config + echo "SLX_DNS='$dns'" >> /opt/openslx/config + + # TODO: This mounts stage4. Current method is for testing purposes only. + # when going productive, this has to happen after user login, if the + # user selects a native linux session. + if [ "x$(grep -ci mount /proc/cmdline)" != "x0" ]; then + systemctl start nfs-mount.service & + fi + # Mark network target as reached + systemctl start network.target + fi + + ;; + + deconfig) + if [ $(grep -c "nfs=" /proc/cmdline) == 0 ]; then + echo 1 > "/proc/sys/net/ipv4/conf/$interface/promote_secondaries" + clientip=${ip%%:*} + ip addr del "$clientip/$(ipcalc -s -p $clientip $subnet|sed s/.*=//)" dev "$interface" + else + echo "NFS is active, not removing old ip adress. warning: lease may expire after a while." + fi + + if [ -x /sbin/resolvconf ]; then + # Automatic handling :-) + resolvconf -d "${interface}.udhcpc" + else + # Manual handling required :-( + rm -f "$THISFILE" + rebuild_resolv_conf + fi + + ;; + + leasefail) + echo "$0: Lease failed: $message" + + ;; + + nak) + echo "$0: Received a NAK: $message" + + ;; + + *) + echo "$0: Unknown udhcpc command: $1"; + exit 1; + + ;; +esac + diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/udhcpc-openslx-script b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/udhcpc-openslx-script deleted file mode 100755 index 1bbf6e80..00000000 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/udhcpc-openslx-script +++ /dev/null @@ -1,174 +0,0 @@ -#!/bin/bash -# ----------------------------------------------------------------------------- -# -# Copyright (c) 2011 - 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 suggestions, praise, or complaints to feedback@openslx.org -# -# General information about OpenSLX can be found at http://openslx.org/ -# ----------------------------------------------------------------------------- -# -# Mini-Linux Toolkit -# -# ----------------------------------------------------------------------------- - -. /opt/openslx/config - -RESOLV_CONF="/etc/resolv.conf" -THISFILE="/run/udhcpc/${interface}.resolv" - -echo "$interface [$1] $ip" >> "/tmp/udhcpclog" - -rebuild_resolv_conf () { - # Maybe make this smarter some time, if anyone is using client's that are on multiple networks at once etc... - # This is a little braindead but should work most of the time - sort -u /run/udhcpc/*.resolv > "$RESOLV_CONF" -} - -escape_search() { - echo "$@" | sed -e 's/[]\/()$*.^|[]/\\&/g' -} - -escape_replace() { - echo "$@" | sed -e 's/[\/&]/\\&/g' -} - -case "$1" in - bound|renew) - ip addr add "$ip/$(ipcalc -s -p $ip $subnet|sed s/.*=//)" dev "$interface" - if [ -n "$router" ]; then - ip route add default via "$router" - fi - - # Update resolver configuration file - CONF="" - if [ -n "$domain" ]; then - printf -v CONF "domain $domain\nsearch $domain\n" - elif [ -n "$SLX_NET_DOMAIN" ]; then - printf -v CONF "domain $SLX_NET_DOMAIN\nsearch $SLX_NET_DOMAIN\n" - fi - for i in $dns; do - echo "$0: Adding DNS $i" - printf -v CONF "${CONF}nameserver $i\n" - done - - if [ -x /sbin/resolvconf ]; then - # Automatic handling :-) - echo -n "$CONF" | resolvconf -a "${interface}.udhcpc" - else - # Manual handling required :-( - mkdir -p "/run/udhcpc" - echo -n "$CONF" > "$THISFILE" - rebuild_resolv_conf - fi - - # Things that should only happen for the main interface that was used for booting - if [ "$interface" == "br0" ]; then - #update ip - sed -i "s/^\(SLX_PXE_CLIENT_IP=\).*$/\1'$ip'/" /opt/openslx/config - - #update hostname - dns_host=$(rdns "$ip") - if [ -z "$dns_host" ]; then - # fallback to what the dhcp told us - dns_host="$hostname" - fi - if [ -n "$dns_host" ]; then - echo "$dns_host" > "/proc/sys/kernel/hostname" - echo "$dns_host" > "/etc/hostname" - if grep '^SLX_HOSTNAME=' /opt/openslx/config 2>/dev/null; then - sed -i "s/^\(SLX_HOSTNAME=\).*$/\1'$dns_host'/" /opt/openslx/config - else - echo "# Config written by openslx-dhcp-script (1)" >> /opt/openslx/config - echo "SLX_HOSTNAME='$dns_host'" >> /opt/openslx/config - fi - fi - fi - - # Hostname in /etc/hosts - touch /etc/hosts - if [ -n "$dns_host" ]; then - short="${dns_host%%.*}" - [ "x$short" = "x$dns_host" ] && short="" - sed -i -r "s/\s$(escape_search "$dns_host")(\s|$)/ /g" /etc/hosts - [ -n "$short" ] && sed -i -r "s/\s$(escape_search "$short")(\s|$)/ /g" /etc/hosts - if grep -q -E "^$ip\s" /etc/hosts; then - sed -i "s/^$(escape_search "$ip")\s/$(escape_replace "$ip $dns_host $short ")/g" /etc/hosts - else - echo "$ip $dns_host $short" >> /etc/hosts - fi - fi - if [ -n "$hostname" -a "x$hostname" != "x$dns_host" ]; then - short="${hostname%%.*}" - [ "x$short" = "x$hostname" ] && short="" - sed -i -r "s/\s$(escape_search "$hostname")(\s|$)/ /g" /etc/hosts - [ -n "$short" ] && sed -i -r "s/\s$(escape_search "$short")(\s|$)/ /g" /etc/hosts - if grep -q -E "^$ip\s" /etc/hosts; then - sed -i "s/^$(escape_search "$ip")\s/$(escape_replace "$ip $hostname $short ")/g" /etc/hosts - else - echo "$ip $hostname $short" >> /etc/hosts - fi - fi - sed -i -r '/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s*$/d' /etc/hosts - - # We consider the network setup to be complete if an interface is being configured that - # has a default route and some dns servers set. - if [ -n "$router" ] && [ -n "$dns" ] && [ ! -e "/run/udhcpc/network-ready" ]; then - touch "/run/udhcpc/network-ready" - # Write to openslx-config - echo "# Config written by openslx-dhcp-script (2)" >> /opt/openslx/config - echo "SLX_DNS='$dns'" >> /opt/openslx/config - - # TODO: This mounts stage4. Current method is for testing purposes only. - # when going productive, this has to happen after user login, if the - # user selects a native linux session. - if [ "x$(grep -ci mount /proc/cmdline)" != "x0" ]; then - systemctl start nfs-mount.service & - fi - # Mark network target as reached - systemctl start network.target - fi - - ;; - - deconfig) - if [ $(grep -c "nfs=" /proc/cmdline) == 0 ]; then - echo 1 > "/proc/sys/net/ipv4/conf/$interface/promote_secondaries" - clientip=${ip%%:*} - ip addr del "$clientip/$(ipcalc -s -p $clientip $subnet|sed s/.*=//)" dev "$interface" - else - echo "NFS is active, not removing old ip adress. warning: lease may expire after a while." - fi - - if [ -x /sbin/resolvconf ]; then - # Automatic handling :-) - resolvconf -d "${interface}.udhcpc" - else - # Manual handling required :-( - rm -f "$THISFILE" - rebuild_resolv_conf - fi - - ;; - - leasefail) - echo "$0: Lease failed: $message" - - ;; - - nak) - echo "$0: Received a NAK: $message" - - ;; - - *) - echo "$0: Unknown udhcpc command: $1"; - exit 1; - - ;; -esac - -- cgit v1.2.3-55-g7522 From 332a36cab877d3a3b96bae683fa7a2b7dcf4c402 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 1 Aug 2013 17:07:31 +0200 Subject: [rootfs-stage32] added /etc/nsswitch.conf with standard config --- remote/rootfs/rootfs-stage32/data/etc/nsswitch.conf | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 remote/rootfs/rootfs-stage32/data/etc/nsswitch.conf diff --git a/remote/rootfs/rootfs-stage32/data/etc/nsswitch.conf b/remote/rootfs/rootfs-stage32/data/etc/nsswitch.conf new file mode 100644 index 00000000..6886def9 --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/etc/nsswitch.conf @@ -0,0 +1,19 @@ +# /etc/nsswitch.conf +# +# Example configuration of GNU Name Service Switch functionality. +# If you have the `glibc-doc-reference' and `info' packages installed, try: +# `info libc "Name Service Switch"' for information about this file. + +passwd: compat +group: compat +shadow: compat + +hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 +networks: files + +protocols: db files +services: db files +ethers: db files +rpc: db files + +netgroup: nis -- cgit v1.2.3-55-g7522