Browse Source

nbd: use procd style init script for nbd-server

Runs nbd-server in foreground.

Signed-off-by: Marcin Jurkowski <marcin1j@gmail.com>
lilik-openwrt-22.03
Marcin Jurkowski 9 years ago
parent
commit
5ba490239a
2 changed files with 23 additions and 19 deletions
  1. +1
    -1
      net/nbd/Makefile
  2. +22
    -18
      net/nbd/files/nbd-server.init

+ 1
- 1
net/nbd/Makefile View File

@ -53,7 +53,7 @@ endef
CONFIGURE_ARGS += \
--disable-glibtest
TARGET_CFLAGS += --std=gnu99
TARGET_CFLAGS += --std=gnu99 -DNODAEMON
define Package/nbd/install
$(INSTALL_DIR) $(1)/usr/sbin


+ 22
- 18
net/nbd/files/nbd-server.init View File

@ -1,9 +1,11 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2012 OpenWrt.org
# Copyright (C) 2015 OpenWrt.org
START=60
SERVICE_USE_PID=1
STOP=40
USE_PROCD=1
PROG=/usr/bin/nbd-server
CONFIGFILE="/var/etc/nbd-server.conf"
@ -81,28 +83,30 @@ config_handle_share() {
append_val_str listenaddr "$cfg" oldstyle_listenaddr
}
config_read() {
start_instance() {
local cfg="$1"
local enabled
mkdir -p $(dirname $CONFIGFILE)
echo -n > $CONFIGFILE
config_get_bool enabled "$cfg" 'enabled' '0'
[ "$enabled" = 0 ] && return 1
procd_open_instance
procd_set_param command $PROG --config-file=$CONFIGFILE
procd_set_param file $CONFIGFILE
procd_close_instance
}
start_service() {
config_load nbd-server
mkdir -p $(dirname $CONFIGFILE)
echo "# auto-generated config file from /etc/config/nbd-server" > $CONFIGFILE
config_foreach config_handle_generic nbd-server
config_foreach config_handle_share share
}
start() {
config_read
if [ "$SERVICE_ENABLED" = "1" ]; then
service_start /usr/bin/nbd-server \
--pid-file /var/run/nbd-server.pid \
--config-file=$CONFIGFILE
fi
config_foreach start_instance nbd-server
}
stop() {
service_stop /usr/bin/nbd-server
service_triggers() {
procd_add_reload_trigger "nbd-server"
}

Loading…
Cancel
Save