summaryrefslogtreecommitdiffstats
path: root/satellit_upgrader/updater.template.sh
diff options
context:
space:
mode:
authorSimon Rettberg2018-04-20 13:04:30 +0200
committerSimon Rettberg2018-04-20 13:04:30 +0200
commitaa4a86d7da14e6929f3dd0cccc7be5ba6b57b967 (patch)
treeb92641cb43d74256c674f2c24b4580a14bbff364 /satellit_upgrader/updater.template.sh
parent[SSPS] Don't start tftpd-hpa in verbose mode (diff)
downloadsetup-scripts-aa4a86d7da14e6929f3dd0cccc7be5ba6b57b967.tar.gz
setup-scripts-aa4a86d7da14e6929f3dd0cccc7be5ba6b57b967.tar.xz
setup-scripts-aa4a86d7da14e6929f3dd0cccc7be5ba6b57b967.zip
[SSUS] Replace atftpd by tftpd-hpa
Diffstat (limited to 'satellit_upgrader/updater.template.sh')
-rw-r--r--satellit_upgrader/updater.template.sh75
1 files changed, 45 insertions, 30 deletions
diff --git a/satellit_upgrader/updater.template.sh b/satellit_upgrader/updater.template.sh
index 2b9ca8f..221ab42 100644
--- a/satellit_upgrader/updater.template.sh
+++ b/satellit_upgrader/updater.template.sh
@@ -106,6 +106,18 @@ diffcp () {
return 0
}
+# failprint apt-get install foobar
+# Only prints command output to stdout if exit code is not 0
+failprint () {
+ local tf ret
+ tf=$(mktemp)
+ "$@" &> "$tf"
+ ret=$?
+ [ "$ret" != 0 ] && cat "$tf"
+ rm -f -- "$tf"
+ return "$ret"
+}
+
# ** Constants - to be patched by the packaging script
declare -rg TARGET_WEBIF_VERSION="%TARGET_WEBIF_VERSION%"
declare -rg TGZ_SLXADMIN="%TGZ_SLXADMIN%"
@@ -351,20 +363,6 @@ if [ -n "$TGZ_DOZMOD" ]; then
echo "dmsd upgrade complete"
fi
-# ************************** TFTP **************************
-if [ -n "$TGZ_TFTP" ]; then
- [ -e "$TMPDIR/$TGZ_TFTP" ] || perror "$TGZ_TFTP missing from payload"
- echo "* TFTP"
- echo "Extracting"
- rm -rf -- "$PATH_TFTP/v4" "$PATH_TFTP/v6" "$PATH_TFTP/ipxelinux.0" "$PATH_TFTP/pxelinux.0"
- mkdir -p "$PATH_TFTP"
- tar -x -C "$PATH_TFTP" -f "$TMPDIR/$TGZ_TFTP" || perror "Could not extract $TGZ_TFTP to $PATH_TFTP"
- fixperms "$PATH_TFTP" taskmanager:taskmanager
- echo "Resetting pxe menu"
- mysql -e 'UPDATE openslx.property SET value = "invalid" WHERE name = "server-ip"' || pwarning "Could not reset pxe menu status; manual regeneration of menu required"
- echo "TFTP upgrade complete"
-fi
-
echo "* Configuring lighttpd"
RESTART_LIGHTY=
@@ -423,21 +421,38 @@ if ! grep -q -E '^\s*post_max_size = 100M' "$PHPINIFILE"; then
RESTART_LIGHTY=ja
fi
-# ******************* atftpd update ************************
-echo "* Updating atftpd"
-if [ "$MAJOR" = 8 ] && [ -s "$FILEDIR/atftpd32.deb" ] && [ "$(uname -m)" == "i686" ]; then
- echo "Updating package"
- if ! dpkg -i "$FILEDIR/atftpd32.deb" > "$TMPDIR/apt.log" 2>&1; then
- cat "$TMPDIR/apt.log"
- pwarning "Could not update atftpd."
+echo "* TFTP"
+
+# ************************** TFTP **************************
+if [ -n "$TGZ_TFTP" ]; then
+ [ -e "$TMPDIR/$TGZ_TFTP" ] || perror "$TGZ_TFTP missing from payload"
+ echo "Extracting tftp server dir contents"
+ rm -rf -- "$PATH_TFTP/v4" "$PATH_TFTP/v6" "$PATH_TFTP/ipxelinux.0" "$PATH_TFTP/pxelinux.0"
+ mkdir -p "$PATH_TFTP"
+ tar -x -C "$PATH_TFTP" -f "$TMPDIR/$TGZ_TFTP" || perror "Could not extract $TGZ_TFTP to $PATH_TFTP"
+ fixperms "$PATH_TFTP" taskmanager:taskmanager
+ echo "Resetting pxe menu"
+ mysql -e 'UPDATE openslx.property SET value = "invalid" WHERE name = "server-ip"' || pwarning "Could not reset pxe menu status; manual regeneration of menu required"
+fi
+
+# ************* replace atftpd with tftpd-hpa **************
+chg=false
+if which "atftpd" &>/dev/null || dpkg-query -W -f='${db:Status-Abbrev}' "atftpd" | grep -q '^ii' \
+ || ! which "in.tftpd" &>/dev/null; then
+ if diffcp "tftpd/tftpd-hpa" "/etc/default/tftpd-hpa"; then
+ echo "Replacing atftpd with tftpd-hpa"
+ failprint apt-get remove -y atftpd || pwarning "Could not uninstall atftpd"
+ failprint apt-get install -y tftpd-hpa || perror "Could not install tftpd-hpa"
+ chg=true
fi
fi
-# ********************** atftpd.service ********************
-if diffcp "atftpd.service" "/etc/systemd/system/atftpd.service"; then
- ln -s -f "../atftpd.service" "/etc/systemd/system/multi-user.target.wants/"
+diffcp "tftpd/tftpd-hpa" "/etc/default/tftpd-hpa" && chg=true
+diffcp "tftpd/tftpd-hpa.service" "/etc/systemd/system/tftpd-hpa.service" && chg=true
+if "$chg"; then
+ ln -s -f "../tftpd-hpa.service" "/etc/systemd/system/multi-user.target.wants/"
systemctl daemon-reload
- restart_service atftpd
+ restart_service tftpd-hpa.service
fi
# ********************** dmsd.service **********************
@@ -471,7 +486,7 @@ if ! id -u dnbd3 &> /dev/null; then
echo "User added"
fi
-if ! dpkg -l | grep -q "^ii\\s.*$PACKAGE_LIBJANSSON"; then
+if ! dpkg -l "$PACKAGE_LIBJANSSON" | grep -q "^ii\\s.*$PACKAGE_LIBJANSSON"; then
echo "Installing $PACKAGE_LIBJANSSON"
if ! apt-get install -y "$PACKAGE_LIBJANSSON" &> "$TMPDIR/apt.log"; then
cat "$TMPDIR/apt.log"
@@ -488,9 +503,9 @@ if ! dpkg -l | grep -q "^ii\\s.*$PACKAGE_LIBJANSSON"; then
fi
# config
-diffcp "server.conf" "/etc/dnbd3-server/server.conf"
-diffcp "is-enabled" "$PATH_DNBD3/is-enabled"
-diffcp "$FILEDIR/rpc.acl" "/etc/dnbd3-server/rpc.acl"
+diffcp "dnbd3/server.conf" "/etc/dnbd3-server/server.conf"
+diffcp "dnbd3/rpc.acl" "/etc/dnbd3-server/rpc.acl"
+diffcp "dnbd3/is-enabled" "$PATH_DNBD3/is-enabled"
if [ -n "$TGZ_DNBD3" ]; then
echo "Extracting new dnbd3-server binary"
@@ -498,7 +513,7 @@ if [ -n "$TGZ_DNBD3" ]; then
fi
# ********************** dnbd3.service *******************
-if diffcp "dnbd3-server.service" "/etc/systemd/system/dnbd3-server.service"; then
+if diffcp "dnbd3/dnbd3-server.service" "/etc/systemd/system/dnbd3-server.service"; then
ln -s -f "../dnbd3-server.service" "/etc/systemd/system/multi-user.target.wants/"
systemctl daemon-reload
echo "Service file replaced"