summaryrefslogtreecommitdiffstats
path: root/satellit_upgrader/updater.template.sh
diff options
context:
space:
mode:
authorChristian Rößler2017-12-06 15:36:18 +0100
committerChristian Rößler2017-12-06 15:36:18 +0100
commit8f57189fabb4657dbdd0ace6e1c5cdc83621d8ad (patch)
tree4e8073aeb58866bb927422f513e54b07989af503 /satellit_upgrader/updater.template.sh
parent[SSPS] slxadmin: Update config.php (diff)
downloadsetup-scripts-8f57189fabb4657dbdd0ace6e1c5cdc83621d8ad.tar.gz
setup-scripts-8f57189fabb4657dbdd0ace6e1c5cdc83621d8ad.tar.xz
setup-scripts-8f57189fabb4657dbdd0ace6e1c5cdc83621d8ad.zip
[SSPS] some more stuff, mostly dnbd3
Diffstat (limited to 'satellit_upgrader/updater.template.sh')
-rw-r--r--satellit_upgrader/updater.template.sh93
1 files changed, 92 insertions, 1 deletions
diff --git a/satellit_upgrader/updater.template.sh b/satellit_upgrader/updater.template.sh
index d534209..eb56e41 100644
--- a/satellit_upgrader/updater.template.sh
+++ b/satellit_upgrader/updater.template.sh
@@ -86,6 +86,7 @@ declare -rg TGZ_TASKMANAGER="%TGZ_TASKMANAGER%"
declare -rg TGZ_TFTP="%TGZ_TFTP%"
declare -rg TGZ_IPXE="%TGZ_IPXE%"
declare -rg TGZ_LDADP="%TGZ_LDADP%"
+declare -rg TGZ_DNBD3="%TGZ_DNBD3%"
declare -rg PAYLOAD_OFFSET="%PAYLOAD_OFFSET%"
declare -rg SLXADMIN_FOOTER="%SLXADMIN_FOOTER%"
@@ -97,6 +98,8 @@ declare -rg PATH_TASKMANAGER="/opt/taskmanager"
declare -rg PATH_TFTP="/srv/openslx/tftp"
declare -rg PATH_IPXE="/opt/openslx/ipxe"
declare -rg PATH_LDADP="/opt/ldadp"
+declare -rg PATH_DNBD3="/opt/openslx/dnbd3"
+declare -rg PACKAGE_LIBJANSSON="libjansson4" # needed by dnbd3
# ** Check if constants have been filled, bail out otherwise
if [ -z "$TARGET_WEBIF_VERSION" ] || [[ "$TARGET_WEBIF_VERSION" == %*% ]]; then
@@ -237,7 +240,7 @@ if [ -n "$TGZ_SLXADMIN" ]; then
(
mkdir -p "$PATH_SLXADMIN/modules"
cd "$PATH_SLXADMIN/modules" || perror "Cannot cd to slxadmin"
- for mod in adduser backup baseconfig baseconfig_bwidm baseconfig_bwlp bootstrap_datepicker bootstrap_dialog bootstrap_timepicker bootstrap_multiselect bootstrap_switch dozmod eventlog exams js_chart js_circles js_jqueryui js_moment js_selectize js_stupidtable js_vis locationinfo locations main minilinux news serversetup-bwlp rebootcontrol roomplanner 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 rebootcontrol roomplanner runmode serversetup-bwlp 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')"
@@ -400,6 +403,94 @@ if [ -e "$FILEDIR/dmsd.service" ]; then
echo "Service file replaced"
fi
+# ********************** dnbd3 config *******************
+
+echo "* Checking dnbd3 stuff ... "
+# check for dnbd3 user: dnbd3, 10002, group dnbd3, 10002
+dnbd3group=10002
+
+echo -n "* Checking for dnbd3 user ... "
+if [[ ! "$(id -u dnbd3 > /dev/null 2>&1; echo $?)" == "0" ]]; then
+ echo "not found."
+ echo -n "* Checking for dnbd3 group ... "
+ if [[ "$(getent group dnbd3; echo $? > /dev/null 2>&1; echo $?)" == "0" ]]; then
+ groupadd -g "$dnbd3group" dnbd3 || perror "Could not add dnbd3 group!"
+ echo "group added."
+ else
+ echo "group already there: adding user to group."
+ dnbd3group=$(getent group dnbd3 | cut -d ":" -f 3)
+ fi
+
+ echo -n "* Adding user dnbd3 ... "
+ useradd --no-create-home -d /nonexistent -s /bin/false --gid "$dnbd3group" --uid 10002 dnbd3 || perror "Could not add user dnbd3!"
+ echo "added."
+else
+ # if there's an user we don't care about any groups
+ echo "found. Doing nothing."
+fi
+
+echo -n "* Checking for $PACKAGE_LIBJANSSON ... "
+if [[ $(dpkg -l|grep "$PACKAGE_LIBJANSSON"|cut -f 1 -d " ") != "ii" ]]; then
+ echo -n "not found. Trying to install ... "
+ if ! apt-get install "$PACKAGE_LIBJANSSON" 2>/dev/null 1>&2; then
+ pwarning "*"
+ pwarning "* Warning: Could not install $PACKAGE_LIBJANSSON!"
+ pwarning "*"
+ pwarning "* This means the dnbd3 server will not work."
+ pwarning "* Please do either \"apt-get install $PACKAGE_LIBJANSSON\" by hand or"
+ pwarning "* install $PACKAGE_LIBJANSSON otherwise."
+ pwarning "*"
+ else
+ echo "installed."
+ fi
+else
+ echo "found."
+fi
+
+# config
+if [ -e "$FILEDIR/server.conf" ]; then
+ echo "* dnbd3 triggered via $FILEDIR/server.conf"
+ if [ -e "/etc/dnbd3-server/server.conf" ]; then
+ echo "* Replacing server.conf (dnbd3)"
+ cp "$FILEDIR/server.conf" "/etc/dnbd3-server/server.conf" || perror "Could not replace /etc/dnbd3-server/server.conf"
+ echo "dnbd3 config upgrade complete"
+ else
+ echo "* Inserting server.conf (dnbd3)"
+ mkdir -p /etc/dnbd3-server || perror "Could not mkdir /etc/dnbd3-server"
+ cp "$FILEDIR/server.conf" "/etc/dnbd3-server/server.conf" || perror "Could not write /etc/dnbd3-server/server.conf"
+ echo "dnbd3 config inserted"
+ fi
+
+ [ -e "$PATH_DNBD3" ] || mkdir -p "$PATH_DNBD3"
+ if [ -e "$FILEDIR/is-enabled" ]; then
+ echo "* Inserting is-enabled to $PATH_DNBD3 (dnbd3)"
+ cp "$FILEDIR/is-enabled" "$PATH_DNBD3/is-enabled" || perror "Could not write /opt/openslx/dnbd3/is-enabled"
+ echo "is-enabled inserted (dnbd3)"
+ else
+ echo "* NOT Inserting is-enabled to $PATH_DNBD3 (dnbd3)"
+ fi
+ if [ -e "$FILEDIR/rpc.acl" ]; then
+ echo "* Inserting rpc.acl to $PATH_DNBD3 (dnbd3)"
+ cp "$FILEDIR/rpc.acl" "/etc/dnbd3-server/rpc.acl" || perror "Could not write /etc/dnbd3-server/rpc.acl"
+ echo "rpc.acl inserted (dnbd3)"
+ else
+ echo "* NOT inserting rpc.acl to $PATH_DNBD3 (dnbd3)"
+ fi
+else
+ echo "* dnbd3 NOT triggered (no $FILEDIR/server.conf)"
+fi
+
+# ********************** dnbd3.service *******************
+tar -x -C "$PATH_DNBD3" -f "$TMPDIR/$TGZ_DNBD3" || perror "Could not extract $TGZ_DNBD3 to $PATH_DNBD3"
+if [ -e "$FILEDIR/dnbd3-server.service" ]; then
+ echo "* Replacing/writing dnbd3-server.service"
+ cp "$FILEDIR/dnbd3-server.service" "/etc/systemd/system/dnbd3-server.service" || \
+ perror "Could not replace/write /etc/systemd/system/dnbd3-server.service"
+ ln -s -f "../dnbd3-server.service" "/etc/systemd/system/multi-user.target.wants/"
+ systemctl daemon-reload
+ echo "Service file replaced"
+fi
+
# ************************** ldadp *************************
if [ -n "$TGZ_LDADP" ]; then
[ -e "$TMPDIR/$TGZ_LDADP" ] || perror "$TGZ_LDADP missing from payload"