diff options
-rw-r--r-- | satellit_installer/includes/00-variables.inc | 2 | ||||
-rw-r--r-- | satellit_installer/static_files/dnbd3-server.service | 13 | ||||
-rw-r--r-- | satellit_installer/static_files/dnbd3/rpc.acl | 2 | ||||
-rwxr-xr-x | satellit_installer/static_files/is-enabled | 22 | ||||
-rw-r--r-- | satellit_installer/static_files/rpc.acl | 2 | ||||
-rw-r--r-- | satellit_installer/static_files/server.conf | 26 | ||||
-rwxr-xr-x | satellit_upgrader/pack-update.sh | 8 | ||||
-rw-r--r-- | satellit_upgrader/updater.template.sh | 93 |
8 files changed, 166 insertions, 2 deletions
diff --git a/satellit_installer/includes/00-variables.inc b/satellit_installer/includes/00-variables.inc index f71e370..ce10962 100644 --- a/satellit_installer/includes/00-variables.inc +++ b/satellit_installer/includes/00-variables.inc @@ -25,7 +25,7 @@ PACKAGELIST_SERVER=" mysql-server lighttpd atftpd php-cgi php-curl cifs-utils php-mbstring sudo php-common php-mysqlnd php-cli nfs-kernel-server curl nfs-common libowfat0 ldap-utils vim gcc make unattended-upgrades gnupg - libowfat-dev libssl-dev gcc make liblzma-dev tmate php-xml" + libowfat-dev libssl-dev gcc make liblzma-dev tmate php-xml net-tools" " # Enter here packages needing installation of recommended packages as determines by apt-get: diff --git a/satellit_installer/static_files/dnbd3-server.service b/satellit_installer/static_files/dnbd3-server.service new file mode 100644 index 0000000..e623e08 --- /dev/null +++ b/satellit_installer/static_files/dnbd3-server.service @@ -0,0 +1,13 @@ +[Unit] +Description=DNBD3 Server +ConditionPathExists=!/srv/openslx/nfs/.notmounted + +[Service] +User=dnbd3 +PermissionsStartOnly=true +ExecStartPre=/opt/openslx/dnbd3/is-enabled +ExecStart=/opt/openslx/dnbd3/dnbd3-server -n +Restart=always +RestartSec=5 +TimeoutStopSec=10 + diff --git a/satellit_installer/static_files/dnbd3/rpc.acl b/satellit_installer/static_files/dnbd3/rpc.acl new file mode 100644 index 0000000..576757c --- /dev/null +++ b/satellit_installer/static_files/dnbd3/rpc.acl @@ -0,0 +1,2 @@ +# Everything from localhost +127.0.0.0/8 ALL diff --git a/satellit_installer/static_files/is-enabled b/satellit_installer/static_files/is-enabled new file mode 100755 index 0000000..11d1fb0 --- /dev/null +++ b/satellit_installer/static_files/is-enabled @@ -0,0 +1,22 @@ +#!/bin/sh + +# Run as root! +# Check if dnbd3 is configured active in slx-admin +# If not, stop service and bail out, otherwise exit 0 to +# signal systemd that the daemon should start. +# Retry a couple of times if slx-admin returns +# neither YES nor NO + +for i in 1 2 3 4 END; do + RET=$(curl -m 3 -s 'http://127.0.0.1/slx-admin/api.php?do=dnbd3&get=enabled') + [ "$RET" = "YES" ] && exit 0 + if [ "$RET" = "NO" ]; then + systemctl stop dnbd3-server.service + exit 1 + fi + [ "$i" = "END" ] && break + sleep "$i" +done + +exit 2 + diff --git a/satellit_installer/static_files/rpc.acl b/satellit_installer/static_files/rpc.acl new file mode 100644 index 0000000..576757c --- /dev/null +++ b/satellit_installer/static_files/rpc.acl @@ -0,0 +1,2 @@ +# Everything from localhost +127.0.0.0/8 ALL diff --git a/satellit_installer/static_files/server.conf b/satellit_installer/static_files/server.conf new file mode 100644 index 0000000..404e4ff --- /dev/null +++ b/satellit_installer/static_files/server.conf @@ -0,0 +1,26 @@ +[dnbd3] +listenPort=5003 +basePath=/srv/openslx/nfs +serverPenalty=0 +clientPenalty=1000 +isProxy=false +removeMissingImages=true +clientTimeout=15000 +vmdkLegacyMode=true +closeUnusedFd=true + +; Log related config +[logging] +; protip: use SIGUSR2 to reopen log file +; DEACTIVATED +;;file=./dnbd3.log +fileMask=ERROR WARNING MINOR INFO DEBUG1 +consoleMask=ERROR WARNING MINOR INFO +; Valid types (warning: specifying invalid types will not yield an error!) +; ERROR Fatal error, server will terminate +; WARNING Major issue, something is broken but keep running +; MINOR Minor issue, more of a hickup than serious problem +; INFO Informational message +; DEBUG1 Debug information, used for medium verbosity +; DEBUG2 Used for debug messages that would show up a lot + diff --git a/satellit_upgrader/pack-update.sh b/satellit_upgrader/pack-update.sh index 78f3714..78e402d 100755 --- a/satellit_upgrader/pack-update.sh +++ b/satellit_upgrader/pack-update.sh @@ -25,6 +25,7 @@ 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 TGZ_LDADP="files/ldadp.tar.gz" +declare -rg TGZ_DNBD3="files/dnbd3-server.tar.gz" # Prepare installer cp "updater.template.sh" "$UPDATER" || perror "could not copy template" @@ -112,6 +113,7 @@ 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" if [ -z "$LEAN" ]; then addinstallfile "atftpd.service" @@ -122,6 +124,12 @@ if [ -z "$LEAN" ]; then addinstallfile "slxadmin-cronscript" addinstallfile "slxadmin-crontab" addinstallfile "patch_lighttpd_phpchildren" + + # Not quite ideal, watch out for similar names + addinstallfile "dnbd3-server.service" + addinstallfile "is-enabled" + addinstallfile "server.conf" + # TODO: Unify more source ../satellit_installer/includes/10-sudo_config.inc sudo_config files/tm-sudo-config 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" |