From 8e5b338dee7bc7142ab3cf8bed935c4aef0ec043 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 8 Aug 2018 18:25:47 +0200 Subject: [PATCH] TT#40459 Move the rtpengine NFS mount point into its own sysvinit script We detangle the two actions so that they can be performed independently and on different conditions. This makes it possible to start the rtpengine-recording-daemon only on the active node, and on some role-specific nodes, while mounting the NFS filesystem in other nodes. We do not remove the nfs-setup start from the recording daemon init script as sysvinit does not honor dependencies during direct init.d or service(8) invocations. [gjover@sipwise.com: Adapt changes to sysvinit. ] Change-Id: Ibb637c533c94bc3db119111460ca647a50a205af (cherry picked from commit 0224a491621fa0efc71b3cafff2028805cada47d) --- debian/ngcp-rtpengine-recording-daemon.init | 4 +- ...on.ngcp-rtpengine-recording-nfs-mount.init | 38 +++++++++++++++++++ debian/ngcp-rtpengine-recording-nfs-setup | 7 +++- debian/rules | 4 ++ 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100755 debian/ngcp-rtpengine-recording-daemon.ngcp-rtpengine-recording-nfs-mount.init diff --git a/debian/ngcp-rtpengine-recording-daemon.init b/debian/ngcp-rtpengine-recording-daemon.init index 92e6be99b..3bfe56d62 100755 --- a/debian/ngcp-rtpengine-recording-daemon.init +++ b/debian/ngcp-rtpengine-recording-daemon.init @@ -1,8 +1,8 @@ #! /bin/sh ### BEGIN INIT INFO # Provides: ngcp-rtpengine-recording-daemon -# Required-Start: $network $local_fs $remote_fs $syslog -# Required-Stop: $network $local_fs $remote_fs $syslog +# Required-Start: $network $local_fs $remote_fs ngcp-rtpengine-recording-nfs-mount $syslog +# Required-Stop: $network $local_fs $remote_fs ngcp-rtpengine-recording-nfs-mount $syslog # Should-Start: sshd # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 diff --git a/debian/ngcp-rtpengine-recording-daemon.ngcp-rtpengine-recording-nfs-mount.init b/debian/ngcp-rtpengine-recording-daemon.ngcp-rtpengine-recording-nfs-mount.init new file mode 100755 index 000000000..30c680383 --- /dev/null +++ b/debian/ngcp-rtpengine-recording-daemon.ngcp-rtpengine-recording-nfs-mount.init @@ -0,0 +1,38 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: ngcp-rtpengine-recording-nfs-mount +# Required-Start: $remote_fs $local_fs $remote_fs $syslog +# Required-Stop: $remote_fs $local_fs $remote_fs $syslog +# Should-Start: sshd +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: NGCP RTP/media Recording NFS mount point +### END INIT INFO + +set -e + +. /lib/lsb/init-functions + +### + +case "$1" in + start) + ngcp-rtpengine-recording-nfs-setup start + ;; + stop) + ngcp-rtpengine-recording-nfs-setup stop + ;; + force-reload|restart) + $0 stop + $0 start + ;; + status) + grep -E -q "^[^ :]+:[^ :]+ $NFS_LOCAL_MOUNT nfs.? " /proc/mounts + ;; + *) + echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/debian/ngcp-rtpengine-recording-nfs-setup b/debian/ngcp-rtpengine-recording-nfs-setup index 4b70ef0de..5a9fdef54 100755 --- a/debian/ngcp-rtpengine-recording-nfs-setup +++ b/debian/ngcp-rtpengine-recording-nfs-setup @@ -4,6 +4,7 @@ set -e PATH=/sbin:/bin:/usr/sbin:/usr/bin DEFAULTS=/etc/default/ngcp-rtpengine-recording-daemon +DESC="RTP engine recording NFS share" . /lib/lsb/init-functions @@ -20,13 +21,17 @@ case "$1" in start) if [ "$MUST_NFS" = yes ]; then if ! grep -E -q "^[^ :]+:[^ :]+ $NFS_LOCAL_MOUNT nfs.? " /proc/mounts; then - log_action_msg "Mounting NFS share" + log_action_msg "Mounting $DESC" test -d "$NFS_LOCAL_MOUNT" || mkdir -p "$NFS_LOCAL_MOUNT" mount -t nfs -o "$NFS_OPTIONS" "$NFS_HOST:$NFS_REMOTE_PATH" "$NFS_LOCAL_MOUNT" fi fi ;; stop) + if grep -E -q "^[^ :]+:[^ :]+ $NFS_LOCAL_MOUNT nfs.? " /proc/mounts; then + log_action_msg "Unmounting $DESC" + umount "$NFS_LOCAL_MOUNT" + fi ;; *) echo "Usage: $0 {start|stop}" >&2 diff --git a/debian/rules b/debian/rules index cbcf64520..ee978dd2e 100755 --- a/debian/rules +++ b/debian/rules @@ -70,4 +70,8 @@ override_dh_install: override_dh_strip: dh_strip --dbg-package=ngcp-rtpengine-dbg +override_dh_installinit: + dh_installinit -pngcp-rtpengine-recording-daemon --name=ngcp-rtpengine-recording-nfs-mount + dh_installinit + override_dh_auto_test: