summaryrefslogtreecommitdiffstats
path: root/satellit_upgrader
diff options
context:
space:
mode:
authorSimon Rettberg2019-02-13 13:19:00 +0100
committerSimon Rettberg2019-02-13 13:19:00 +0100
commit75edecee3c24a67918bdf8156402645f0be98ab2 (patch)
treece30c220247f483a09358981d3872a4d5fbc8082 /satellit_upgrader
parent[*] Preparations for new iPXE (mtools, mkdir) (diff)
downloadsetup-scripts-75edecee3c24a67918bdf8156402645f0be98ab2.tar.gz
setup-scripts-75edecee3c24a67918bdf8156402645f0be98ab2.tar.xz
setup-scripts-75edecee3c24a67918bdf8156402645f0be98ab2.zip
[SSUS] Update for new ipxe-aware slx-admin/taskmanager
Diffstat (limited to 'satellit_upgrader')
-rwxr-xr-xsatellit_upgrader/pack-update.sh75
-rw-r--r--satellit_upgrader/updater.template.sh24
2 files changed, 80 insertions, 19 deletions
diff --git a/satellit_upgrader/pack-update.sh b/satellit_upgrader/pack-update.sh
index 37b96c1..3997b98 100755
--- a/satellit_upgrader/pack-update.sh
+++ b/satellit_upgrader/pack-update.sh
@@ -3,10 +3,10 @@
declare -rg SELFPID=$$
perror () {
if [ -n "$IGNORE_ERRORS" ]; then
- echo "[ERROR] $@"
+ echo "${RED}[ERROR]${RESET} $@"
return 0
fi
- echo "[FATAL] $@"
+ echo "${RED}[FATAL]${RESET} $@"
[ "$$" != "$SELFPID" ] && kill "$SELFPID"
exit 1
}
@@ -24,9 +24,43 @@ declare -rg TGZ_DOZMOD="files/dozmod.tar.gz"
declare -rg TGZ_TASKMANAGER="files/taskmanager.tar.gz"
declare -rg TGZ_TFTP="files/tftpdir.tar.gz"
declare -rg TGZ_IPXE="files/ipxe.tar.gz"
+declare -rg FILES_IPXE="
+ pxelinux.0
+ src/
+ .git/
+"
declare -rg TGZ_LDADP="files/ldadp.tar.gz"
declare -rg TGZ_DNBD3="files/dnbd3-server.tar.gz"
+checkfiles () {
+tar tf "$1" | awk -v strings="$2" '
+BEGIN {
+ numStrings = split(strings,tmp)
+ for (i in tmp) strs[tmp[i]]
+}
+numStrings == 0 { exit 0 }
+{
+ for (str in strs) {
+ if ( $0 == str ) {
+ delete strs[str]
+ numStrings--
+ }
+ }
+}
+END { exit (numStrings ? 1 : 0) }
+'
+}
+
+RED=
+GREEN=
+RESET=
+if [ -t 1 ]; then
+ RED=$( echo -en '\033[1;31m' )
+ GREEN=$( echo -en '\033[1;32m' )
+ RESET=$( echo -en '\033[0m' )
+fi
+readonly RED GREEN RESET
+
# Prepare installer
cp "updater.template.sh" "$UPDATER" || perror "could not copy template"
chmod +x "$UPDATER"
@@ -67,13 +101,20 @@ fi
addpayload () {
echo -n "Includes $2: "
- local FILEVAR=$1
+ local FILEVAR="TGZ_$1"
+ local LISTVAR="FILES_$1"
local FILENAME=${!FILEVAR}
+ local LISTFILES=${!LISTVAR}
if [ -e "${FILENAME}" ]; then
- echo "yes"
+ if [ -n "$LISTFILES" ] && ! checkfiles "$FILENAME" "$LISTFILES"; then
+ echo "${RED}no !!! BAD FORMAT !!!${RESET}"
+ patchtgz "$FILEVAR"
+ return
+ fi
+ echo "${GREEN}yes${RESET}"
patchtgz "$FILEVAR" "$FILENAME"
else
- echo "no"
+ echo "${RED}no${RESET}"
patchtgz "$FILEVAR"
fi
}
@@ -83,15 +124,15 @@ addinstallfile () {
local file=$1
local path=$(dirname "$file")
if [ ! -d "../satellit_installer" ]; then
- echo "NO! (satellit_installer not found)"
+ echo "${RED}NO!${RESET} (satellit_installer not found)"
elif [ ! -e "../satellit_installer/static_files/$file" ]; then
- echo "NO! (file not found in satellit_installer/static_files)"
+ echo "${RED}NO!${RESET} (file not found in satellit_installer/static_files)"
else
mkdir -p "files/$path" || echo -n "(mkdir failed) "
if cp "../satellit_installer/static_files/$file" "files/$file"; then
- echo "yes"
+ echo "${GREEN}yes${RESET}"
else
- echo "...no! (copy failed)"
+ echo "...${RED}no!${RESET} (copy failed)"
fi
fi
}
@@ -100,7 +141,7 @@ addinstallfile () {
# slxadmin version
echo -n "Includes SLX-Admin: "
if [ -e "$TGZ_SLXADMIN" ]; then
- echo "yes"
+ echo "${GREEN}yes${RESET}"
VERS=$(date +%Y%j%H)
[ -n "$VERS" ] || perror "Could not extract slx-admin version!"
echo "Version: $VERS"
@@ -108,16 +149,16 @@ if [ -e "$TGZ_SLXADMIN" ]; then
sed -i "s/%SLXADMIN_FOOTER%/$(date '+%y-%m-%d %H:%M')/" "$UPDATER" || perror "could not patch slxadmin footer in updater"
patchtgz "TGZ_SLXADMIN" "$TGZ_SLXADMIN"
else
- echo "no"
+ echo "${RED}no${RESET}"
patchtgz "TGZ_SLXADMIN"
fi
-addpayload "TGZ_DOZMOD" "Dozmod server"
-addpayload "TGZ_TASKMANAGER" "Taskmanager"
-addpayload "TGZ_TFTP" "TFTP/PxeLinux data"
-addpayload "TGZ_IPXE" "iPXE source code"
-addpayload "TGZ_LDADP" "ldap/ad proxy"
-addpayload "TGZ_DNBD3" "dnbd3-server"
+addpayload "DOZMOD" "Dozmod server"
+addpayload "TASKMANAGER" "Taskmanager"
+addpayload "TFTP" "TFTP/PxeLinux data"
+addpayload "IPXE" "iPXE source code"
+addpayload "LDADP" "ldap/ad proxy"
+addpayload "DNBD3" "dnbd3-server"
if [ -z "$LEAN" ]; then
addinstallfile "lighttpd.conf"
diff --git a/satellit_upgrader/updater.template.sh b/satellit_upgrader/updater.template.sh
index b51a0f4..2f34c0c 100644
--- a/satellit_upgrader/updater.template.sh
+++ b/satellit_upgrader/updater.template.sh
@@ -209,6 +209,7 @@ if [ -n "$TGZ_TASKMANAGER" ]; then
tar -x -C "$PATH_TASKMANAGER" -f "$TMPDIR/$TGZ_TASKMANAGER"
fixperms "$PATH_TASKMANAGER" root:root
chmod -R a+x "$PATH_TASKMANAGER/scripts"
+ # Where we place the downloadable iPXE images
mkdir -p -m 0755 "/srv/openslx/www/boot/download"
fixperms "/srv/openslx/www/boot/download" taskmanager:www-data
echo "Restarting service"
@@ -240,7 +241,7 @@ if [ -n "$TGZ_IPXE" ]; then
} &
IPXE_PID=$!
fi
-# Need mtools
+# Need mtools for creating floppy images for iPXE
if ! which mformat &>/dev/null; then
failprint apt-get install -y mtools
fi
@@ -252,6 +253,8 @@ if [ -n "$TGZ_SLXADMIN" ]; then
# Test archive
INCMODS=$(mktemp)
tar tf "$TMPDIR/$TGZ_SLXADMIN" | grep -oP '^modules-available/[^/]+/$' > "$INCMODS" || perror "Could not read $TGZ_SLXADMIN"
+ # Remember boot module if already set
+ bootmodule=$( basename "$( readlink -f "$PATH_SLXADMIN/modules/serversetup" 2> /dev/null )" )
# Remove old files - wipe selectively, just in case someone added a new module by hand
rm -rf -- "$PATH_SLXADMIN/"{inc,apis,modules,templates,Mustache,script,style}
while read -r line || [[ -n "$line" ]]; do
@@ -291,12 +294,29 @@ if [ -n "$TGZ_SLXADMIN" ]; then
diffcp "slxadmin-cronscript" "/opt/openslx/slxadmin-cronscript"
# New crontab supplied
diffcp "slxadmin-crontab" "/etc/cron.d/slx-admin"
+ # Ask about ipxe / pxelinux
+ if [ -z "$bootmodule" ] || ! [ -d "$PATH_SLXADMIN/modules-available/$bootmodule" ]; then
+ bootmodule="serversetup-bwlp-pxelinux"
+ if [ -t 0 ] && [ -t 1 ]; then
+ echo "Congratulations! You have won a bwLehrpool-Server with iPXE support!"
+ echo "Do you want to enable iPXE boot support instead of the old ipxelinux4 approach?"
+ echo -n "If unsure, say NO here. [y/n]: "
+ read answer
+ while ! [[ "$answer" =~ ^[nNyY] ]]; do
+ echo -n "Please answer [Y]es or [N]o: "
+ read answer
+ done
+ [[ "$answer" =~ ^[yY] ]] && bootmodule="serversetup-bwlp-ipxe"
+ else
+ echo "(Not asking about iPXE vs. pxelinux 4 because we're not running from a terminal)"
+ fi
+ fi
# Enable modules
(
mkdir -p "$PATH_SLXADMIN/modules"
cd "$PATH_SLXADMIN/modules" || perror "Cannot cd to slxadmin"
echo "Enabling slx-admin modules"
- for mod in adduser backup baseconfig baseconfig_bwidm baseconfig_bwlp bootstrap_datepicker bootstrap_dialog bootstrap_multiselect bootstrap_switch bootstrap_timepicker dnbd3 dozmod eventlog exams js_chart js_circles js_jqueryui js_moment js_selectize js_stupidtable js_vis js_weekcalendar locationinfo locations main minilinux news permissionmanager rebootcontrol roomplanner runmode serversetup-bwlp session statistics statistics_reporting summernote sysconfig syslog systemstatus vmstore webinterface; do
+ for mod in adduser backup baseconfig baseconfig_bwidm baseconfig_bwlp bootstrap_datepicker bootstrap_dialog bootstrap_multiselect bootstrap_switch bootstrap_timepicker dnbd3 dozmod eventlog exams js_chart js_circles js_jqueryui js_moment js_selectize js_stupidtable js_vis js_weekcalendar locationinfo locations main minilinux news permissionmanager rebootcontrol roomplanner runmode "$bootmodule" session statistics statistics_reporting summernote sysconfig syslog systemstatus vmstore webinterface; do
name=${mod%%-*}
rm -f -- "$name"
ln -s "../modules-available/$mod" "$name" || pwarning "Could not activate module '$mod' (alias '$name')"