aboutsummaryrefslogtreecommitdiff
path: root/net/nbdkit/files
diff options
context:
space:
mode:
Diffstat (limited to 'net/nbdkit/files')
-rw-r--r--net/nbdkit/files/nbdkit.in136
-rw-r--r--net/nbdkit/files/patch-configure56
2 files changed, 136 insertions, 56 deletions
diff --git a/net/nbdkit/files/nbdkit.in b/net/nbdkit/files/nbdkit.in
new file mode 100644
index 000000000000..3adcbb0e772f
--- /dev/null
+++ b/net/nbdkit/files/nbdkit.in
@@ -0,0 +1,136 @@
+#!/bin/sh
+
+# PROVIDE: nbdkit
+# REQUIRE: NETWORKING
+#
+# Configuration settings for nbdkit in /etc/rc.conf:
+#
+# nbdkit_enable (bool): Enable nbdkit. (default=NO)
+# nbdkit_flags (str): Arguments used by all profiles.
+# nbdkit_profiles (list): Profiles.
+# nbdkit_<profile>_flags (str): Per profile arguments.
+
+. /etc/rc.subr
+
+name="nbdkit"
+desc="Network Block Device server toolkit with stable ABI and permissive license"
+rcvar="${name}_enable"
+start_precmd="nbdkit_prestart"
+start_cmd="nbdkit_start"
+stop_cmd="nbdkit_stop"
+restart_cmd="nbdkit_restart"
+status_cmd="nbdkit_status"
+nbdkit_bin="%%PREFIX%%/sbin/${name}"
+sig_stop=SIGTERM
+pid_directory="/var/run/${name}"
+
+load_rc_config $name
+
+: ${nbdkit_enable:="NO"}
+
+nbdkit_check_pidfile()
+{
+ local profile
+ profile="$1"
+
+ local pidfile
+ pidfile="${pid_directory}/${profile}.pid"
+
+ local rc_pid
+ rc_pid=$(check_pidfile "${pidfile}" "${nbdkit_bin}")
+
+ echo "${rc_pid}"
+}
+
+nbdkit_prestart()
+{
+ if [ ! -d "${pid_directory}" ]; then
+ mkdir -p -- "${pid_directory}"
+ fi
+}
+
+nbdkit_start()
+{
+ local profile
+ profile="$1"
+
+ local rc_pid
+ rc_pid=$(nbdkit_check_pidfile "${profile}")
+
+ if [ -n "${rc_pid}" ]; then
+ echo 1>&2 "nbdkit profile '${profile}' already running? (pid=${rc_pid})"
+ return 1
+ fi
+
+ startmsg "Starting nbdkit profile '${profile}'."
+
+ local flags
+
+ eval flags="\${nbdkit_${profile}_flags}"
+
+ local pidfile
+ pidfile="${pid_directory}/${profile}.pid"
+
+ eval "${nbdkit_bin}" --pidfile "${pidfile}" ${nbdkit_flags} ${flags}
+}
+
+nbdkit_stop()
+{
+ local profile
+ profile="$1"
+
+ local rc_pid
+ rc_pid=$(nbdkit_check_pidfile "${profile}")
+
+ local pidfile
+ pidfile="${pid_directory}/${profile}.pid"
+
+ if [ -z "${rc_pid}" ]; then
+ echo 1>&2 "nbdkit profile '${profile}' not running? (check ${pidfile})"
+ return 1
+ fi
+
+ echo "Stopping nbdkit profile '${profile}'."
+
+ kill -${sig_stop} "${rc_pid}"
+ wait_for_pids "${rc_pid}"
+}
+
+nbdkit_restart()
+{
+ nbdkit_stop "$1"
+ nbdkit_start "$1"
+}
+
+nbdkit_status()
+{
+ local profile
+ profile="$1"
+
+ local rc_pid
+ rc_pid=$(nbdkit_check_pidfile "${profile}")
+
+ if [ -n "${rc_pid}" ]; then
+ echo "nbdkit profile '${profile}' is running as pid ${rc_pid}"
+ else
+ echo "nbdkit profile '${profile}' is not running."
+ fi
+}
+
+cmd="$1"
+
+if [ $# -gt 0 ]; then
+ shift
+fi
+
+if [ -n "$1" ]; then
+ nbdkit_profiles="$1"
+fi
+
+if [ -z "${nbdkit_profiles}" ]; then
+ warn "No profiles are configured, configure one to make this rc script useful!"
+fi
+
+for profile in ${nbdkit_profiles}; do
+ run_rc_command "${cmd}" "${profile}"
+done
diff --git a/net/nbdkit/files/patch-configure b/net/nbdkit/files/patch-configure
deleted file mode 100644
index 15d66aa2d192..000000000000
--- a/net/nbdkit/files/patch-configure
+++ /dev/null
@@ -1,56 +0,0 @@
---- configure.orig 2020-05-02 09:04:50 UTC
-+++ configure
-@@ -911,6 +911,7 @@ enable_largefile
- enable_gcc_warnings
- with_iconv
- with_tls_priority
-+with_linuxdisk
- enable_valgrind
- enable_libfuzzer
- enable_plugins
-@@ -1645,6 +1646,7 @@ Optional Packages:
- compiler's sysroot if not specified).
- --without-iconv don't try to link against iconv [default=check]
- --with-tls-priority default TLS session priority string [default=NORMAL]
-+ --without-linuxdisk disable linuxdisk plugin [default=check]
- --without-curl disable curl plugin [default=check]
- --without-ssh disable ssh plugin [default=check]
- --without-iso disable iso plugin [default=check]
-@@ -18598,20 +18600,32 @@ done
-
- fi
-
-+
-+# Check whether --with-linuxdisk was given.
-+if test "${with_linuxdisk+set}" = set; then :
-+ withval=$with_linuxdisk;
-+else
-+ with_linuxdisk=check
-+fi
-+
- mke2fs_with_d=no
--{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mke2fs supporting the -d option" >&5
-+if test "$with_linuxdisk" != "no"; then :
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mke2fs supporting the -d option" >&5
- $as_echo_n "checking for mke2fs supporting the -d option... " >&6; }
--if mke2fs -V >/dev/null 2>&1; then :
-+ if mke2fs -V >/dev/null 2>&1; then :
-
-- if LANG=C mke2fs -d 2>&1 | grep -sq "option requires an argument"; then :
-+ if LANG=C mke2fs -d 2>&1 | grep -sq "option requires an argument"; then :
-
-- mke2fs_with_d=yes
-+ mke2fs_with_d=yes
-
- fi
-
- fi
--{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $mke2fs_with_d" >&5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $mke2fs_with_d" >&5
- $as_echo "$mke2fs_with_d" >&6; }
-+
-+fi
- if test "x$mke2fs_with_d" = "xyes"; then
- HAVE_MKE2FS_WITH_D_TRUE=
- HAVE_MKE2FS_WITH_D_FALSE='#'