aboutsummaryrefslogtreecommitdiffstats
path: root/bin/switch_wfs_os
diff options
context:
space:
mode:
Diffstat (limited to 'bin/switch_wfs_os')
-rwxr-xr-xbin/switch_wfs_os91
1 files changed, 0 insertions, 91 deletions
diff --git a/bin/switch_wfs_os b/bin/switch_wfs_os
deleted file mode 100755
index c243826..0000000
--- a/bin/switch_wfs_os
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-IFS=$'\n\t'
-
-os_new="arch-rt"
-os_old="ubuntu-studio"
-os_current=""
-os_set=""
-
-syslinux_location_arch="/boot/syslinux/syslinux.cfg"
-syslinux_location_ubuntu="/mnt/boot/syslinux/syslinux.cfg"
-syslinux_location=""
-
-reboot_cmd_arch="sudo systemctl reboot"
-reboot_cmd_ubuntu="/usr/bin/sudo /sbin/reboot -q"
-reboot_cmd=""
-
-hostnames_arch=( "wfs-master" "wfs-node1" "wfs-node2" )
-hostnames_ubuntu=( "wfs" "n101" "n102" )
-host=$(hostname)
-
-if [ $UID -ne 0 ]; then
- echo "You need to be root or call this script with sudo to do this."
- exit 1
-fi
-
-echo "Host: $host."
-
-if [ -f /etc/arch-release ]; then
- os_current=$os_new
- syslinux_location=$syslinux_location_arch
- reboot_cmd=$reboot_cmd_arch
-else
- os_current=$os_old
- syslinux_location=$syslinux_location_ubuntu
- reboot_cmd=$reboot_cmd_ubuntu
-fi
-echo "Currently running: $os_current"
-
-if [ -f "${syslinux_location}" ]; then
- os_set=$(sed -ne '/^DEFAULT/p' $syslinux_location| cut -d' ' -f2)
- echo "Currently set up for next boot: $os_set"
-else
- echo "Error: Syslinux configuration does not exist ($syslinux_location)"
- exit 1
-fi
-
-if [ "$os_set" == "${os_new}" ] && [ "$os_current" == "${os_new}" ]; then
- if [[ " ${hostnames_arch[@]} " =~ " $host " ]]; then
- echo "Switching to: $os_old"
- sed -i 's/^DEFAULT .*/DEFAULT '${os_old}'/' $syslinux_location
- if [[ "${hostnames_arch[0]}" == "$host" ]]; then
- echo "Calling script on nodes:"
- set +e
- ssh wfs@${hostnames_arch[1]} "/usr/bin/sudo bin/$(basename $0)"
- ssh wfs@${hostnames_arch[2]} "/usr/bin/sudo bin/$(basename $0)"
- set -e
- fi
- else
- echo "Error: Script is not supposed to be running on this host!"
- echo "$(hostname) is not one of the following: ${hostnames_arch[@]}"
- echo "Exiting."
- exit 1
- fi
-elif [ "$os_set" == "${os_old}" ] && [ "$os_current" == "${os_old}" ]; then
- if [[ " ${hostnames_ubuntu[@]} " =~ " $host " ]]; then
- echo "Switching to: $os_new"
- sed -i 's/^DEFAULT .*/DEFAULT '${os_new}'/' $syslinux_location
- if [[ "${hostnames_ubuntu[0]}" == "$host" ]]; then
- echo "Calling script on nodes:"
- ssh wfs@${hostnames_ubuntu[1]} "/usr/bin/sudo bin/$(basename $0)"
- ssh wfs@${hostnames_ubuntu[2]} "/usr/bin/sudo bin/$(basename $0)"
- fi
- else
- echo "Error: Script is not supposed to be running on this host!"
- echo "$host is not one of the following: ${hostnames_ubuntu[@]}"
- echo "Exiting."
- exit 1
- fi
-else
- echo "Error: Current OS ($os_current) and OS to be booted ($os_set) are not the same."
- echo "Fix this manually in $syslinux_location or just reboot (into the other OS)."
- echo "Exiting."
- exit 1
-fi
-
-
-echo "Rebooting."
-eval $reboot_cmd
-exit 0