From 0224a491621fa0efc71b3cafff2028805cada47d 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 systemd unit We do not use a proper mount unit because that requires the mount point to be encoded in the filename which is variable and depends on the value coming from config.yml. Change-Id: Ibb637c533c94bc3db119111460ca647a50a205af --- ...ngcp-rtpengine-recording-nfs-mount.service | 20 +++++++++++++++++++ .../ngcp-rtpengine-recording-daemon.service | 3 ++- debian/ngcp-rtpengine-recording-nfs-setup | 7 ++++++- debian/rules | 4 ++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 debian/ngcp-rtpengine-recording-daemon.ngcp-rtpengine-recording-nfs-mount.service diff --git a/debian/ngcp-rtpengine-recording-daemon.ngcp-rtpengine-recording-nfs-mount.service b/debian/ngcp-rtpengine-recording-daemon.ngcp-rtpengine-recording-nfs-mount.service new file mode 100644 index 000000000..d39ce0af4 --- /dev/null +++ b/debian/ngcp-rtpengine-recording-daemon.ngcp-rtpengine-recording-nfs-mount.service @@ -0,0 +1,20 @@ +[Unit] +Description=NGCP RTP/media Recording Daemon NFS mount point +After=network-online.target +After=remote-fs.target +After=rpcbind.socket +After=rpcbind.service +After=nfs-client.target +Requires=network-online.target +Requires=rpcbind.socket +Requires=rpcbind.service +Requires=nfs-client.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/sbin/ngcp-rtpengine-recording-nfs-setup start +ExecStop=/usr/sbin/ngcp-rtpengine-recording-nfs-setup stop + +[Install] +WantedBy=multi-user.target diff --git a/debian/ngcp-rtpengine-recording-daemon.service b/debian/ngcp-rtpengine-recording-daemon.service index 85f3d33f0..ee0f9f605 100644 --- a/debian/ngcp-rtpengine-recording-daemon.service +++ b/debian/ngcp-rtpengine-recording-daemon.service @@ -2,12 +2,13 @@ Description=NGCP RTP/media Recording Daemon After=network-online.target After=remote-fs.target +After=ngcp-rtpengine-recording-nfs-mount.service Requires=network-online.target +Requires=ngcp-rtpengine-recording-nfs-mount.service [Service] Type=simple PIDFile=/run/ngcp-rtpengine-recording-daemon.pid -ExecStartPre=/usr/sbin/ngcp-rtpengine-recording-nfs-setup start ExecStart=/usr/sbin/rtpengine-recording -f -E --pidfile /run/ngcp-rtpengine-recording-daemon.pid --config-file /etc/rtpengine/rtpengine-recording.conf [Install] 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 6747ecbe0..68c2882d7 100755 --- a/debian/rules +++ b/debian/rules @@ -70,4 +70,8 @@ override_dh_install: override_dh_strip: dh_strip --dbgsym-migration='ngcp-rtpengine-dbg (<= 6.0.0.0+0~mr6.0.0.0)' +override_dh_systemd_enable: + dh_systemd_enable + dh_systemd_enable -pngcp-rtpengine-recording-daemon --name=ngcp-rtpengine-recording-nfs-mount + override_dh_auto_test: