diff --git a/images/archlinux/build b/images/archlinux/build index 806e50d..a0c138b 100755 --- a/images/archlinux/build +++ b/images/archlinux/build @@ -33,7 +33,7 @@ patch_image() { sudo mkdir -p $TARGET/run/systemd/resolve sudo cp /etc/resolv.conf $TARGET/run/systemd/resolve/resolv.conf - patch_target common-patches + do_in_target 'curl https://raw.githubusercontent.com/online-labs/ocs-scripts/master/upgrade_root.bash | bash' patch_target archlinux-latest/patches # TODO Get ssh keys from config diff --git a/images/common-patches/usr/local/bin/oc-metadata b/images/common-patches/usr/local/bin/oc-metadata deleted file mode 100755 index 7dfc7e1..0000000 --- a/images/common-patches/usr/local/bin/oc-metadata +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -# description "executable which retrieves server metadata (TEXT)" -# author "Online Labs Cloud Team " - -CODE=0 -while [ $CODE -ne 200 ] -do - METADATA_URL=${METADATA_URL:-"http://169.254.42.42/conf"} - RESPONSE=$(curl --silent --write-out "\n%{http_CODE}\n" $METADATA_URL) - CODE=$(echo "$RESPONSE" | sed -n '$p') - BODY=$(echo "$RESPONSE" | sed '$d') - - test $CODE -eq 200 && break - sleep 5 -done - -if [ "$#" -ne 1 ]; then - echo "$BODY" -else - key="$1" - echo "$BODY" | grep "^$key=" | cut -d= -f2 | sed "s/^['\"]//;s/['\"]$//" -fi diff --git a/images/common-patches/usr/local/bin/oc-metadata-json b/images/common-patches/usr/local/bin/oc-metadata-json deleted file mode 100755 index a3bb610..0000000 --- a/images/common-patches/usr/local/bin/oc-metadata-json +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# description "executable which retrieves server metadata (JSON)" -# author "Online Labs Cloud Team " - -CODE=0 -while [ $CODE -ne 200 ] -do - RESPONSE=$(curl --silent --write-out "\n%{http_CODE}\n" http://169.254.42.42/conf?format=json) - CODE=$(echo "$RESPONSE" | sed -n '$p') - BODY=$(echo "$RESPONSE" | sed '$d') - test $CODE -eq 200 && break - sleep 5 -done - -echo "$BODY" diff --git a/images/common-patches/usr/sbin/nbd-disconnect-root b/images/common-patches/usr/sbin/nbd-disconnect-root deleted file mode 100755 index f152270..0000000 --- a/images/common-patches/usr/sbin/nbd-disconnect-root +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh -# Thanks to the LTSP project -# If the root /dev/nbd0 device is unmounted on shutdown then nbd read -# errors occur, and if it isn't, then # the nbd-server process on the server -# doesn't terminate. -# Called by init scripts on reboot or shutdown. - -case "$RUNLEVEL" in - 0) - key="o" - command="poweroff -f" - ;; - 6) - key="b" - command="reboot -d -f -i" - ;; - *) - echo "nbd-disconnect should only be called by initscripts on reboot/shutdown." >&2 - exit 1 - ;; -esac - -disconnect() { - # Stop trapping - trap - 0 HUP INT QUIT KILL SEGV PIPE TERM - - # ltsp-client-core.upstart needs "console output" to show stderr - echo "nbd-disconnect executing: " >&2 - # Cache the command in order to use it after nbd-client disconnects - $command --version >/dev/null 2>&1 - nbd-client -d "$root" - $command - - # Hopefully this should never be reached - echo "$key" > /proc/sysrq-trigger -} - -# Disconnect swap nbd devices first -while read device etc; do - case "$device" in - /dev/nbd[0-9]) - swapoff "$device" - nbd-client -d "$device" - ;; - /dev/mapper/swap[0-9]) - nbd_device=$(cryptsetup status "$device" | awk '/device:/{print $2}') - swapoff "$device" - cryptsetup remove "$device" - case "$nbd_device" in - /dev/nbd[1-9]) - nbd-client -d "$nbd_device" - ;; - esac - ;; - esac -done < /proc/swaps - -# If we're not using an nbd root, exit -unset root -for param in $(cat /proc/cmdline); do - case "$param" in - root=/dev/nbd[0-9]) - root="${param#root=}" - ;; - esac -done -test -n "$root" || exit 0 - -trap "disconnect" 0 HUP INT QUIT KILL SEGV PIPE TERM -sync -# Give up to 5 seconds for other services to be called. -# If they finish before that time, process termination will start, and the trap -# will be called. -sleep 5 diff --git a/images/common-patches/usr/sbin/oc-add-extra-volumes b/images/common-patches/usr/sbin/oc-add-extra-volumes deleted file mode 100755 index 72571fd..0000000 --- a/images/common-patches/usr/sbin/oc-add-extra-volumes +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -METADATA_CACHE=`mktemp -u` - -get_metadata() { - if [ ! -f $METADATA_CACHE ]; then - /usr/local/bin/oc-metadata > $METADATA_CACHE - fi -} - -get_value() { - # Get value from metadata - key="$1" - grep "^$key=" "$METADATA_CACHE" | cut -d= -f2 | sed "s/^['\"]//;s/['\"]$//" -} - -get_nbd_client_conf() { - keys=$(get_value VOLUMES) - -cat < raw (no other setup than to run the client) - cat < /etc/nbd-client -nbd_clients_connection -rm $METADATA_CACHE diff --git a/images/common-patches/usr/sbin/oc-sync-kernel-modules b/images/common-patches/usr/sbin/oc-sync-kernel-modules deleted file mode 100755 index ca39e91..0000000 --- a/images/common-patches/usr/sbin/oc-sync-kernel-modules +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# description "synchronizes kernel module" -# author "Online Labs Cloud Team " - -DIR=/lib/modules -mkdir -p $DIR -TMP_DIR=`mktemp -d -p $DIR` -KVERSION=`uname -r` -TIMEOUT=10 - -clean() { - rm -rf "$TMP_DIR" 2>/dev/null -} -trap 'clean' INT TERM EXIT - -if [ ! -d $DIR/${KVERSION} ] -then - wget --timeout=${TIMEOUT} --quiet --no-check-certificate -r --no-parent \ - --reject "index.html*" --reject "robots.txt" \ - --no-host-directories --cut-dirs 3 --directory-prefix \ - $TMP_DIR http://mirror.cloud.online.net/kernel/${KVERSION}/modules/${KVERSION}/ - - if [ $? -eq 0 ] - then - mkdir -p $DIR/${KVERSION} - mv $TMP_DIR/${KVERSION} $DIR - fi -fi -