owfs: convert init scripts to procd style
Convert init.d scripts to use procd and take advantage of respawn feature. Signed-off-by: Marcin Jurkowski <marcin1j@gmail.com>
This commit is contained in:
parent
101fc3047c
commit
a240aa9579
|
@ -1,11 +1,10 @@
|
||||||
config owfs 'owfs'
|
config owfs 'owfs'
|
||||||
option enabled 0
|
option enabled 0
|
||||||
option uid 0
|
option user root
|
||||||
option gid 0
|
|
||||||
option readonly 0
|
option readonly 0
|
||||||
option mountpoint '/mnt/owfs'
|
option mountpoint '/mnt/owfs'
|
||||||
option fuse_allow_other 0
|
option fuse_allow_other 0
|
||||||
option fuse_open_opt ''
|
option fuse_open_opt ''
|
||||||
option error_level 0
|
option error_level 0
|
||||||
option options ''
|
list devices '-s'
|
||||||
list devices '-s localhost:4304'
|
list devices 'localhost:4304'
|
||||||
|
|
|
@ -1,75 +1,82 @@
|
||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
# Copyright (C) 2009-2012 OpenWrt.org
|
# Copyright (C) 2009-2015 OpenWrt.org
|
||||||
|
|
||||||
START=99
|
START=95
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
SERVICE_WRITE_PID=1
|
PROG=/usr/bin/owfs
|
||||||
SERVICE_DAEMONIZE=1
|
|
||||||
|
|
||||||
# Workaround insufficient /dev/fuse permissions and the lack of /etc/fuse.conf
|
append_arg() {
|
||||||
DEFAULT_SERVICE_UID=0
|
local cfg="$1"
|
||||||
DEFAULT_SERVICE_GID=0
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
append_device() {
|
config_get val "$cfg" "$var"
|
||||||
append devices "$1"
|
[ -n "$val" -o -n "$def" ] && procd_append_param command $opt "${val:-$def}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
append_bool() {
|
||||||
|
local cfg="$1"
|
||||||
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
start_owfs_daemon() {
|
config_get_bool val "$cfg" "$var" "$def"
|
||||||
local program="$1"
|
[ "$val" = 1 ] && procd_append_param command "$opt"
|
||||||
local config="$1"
|
}
|
||||||
local args="--foreground --error_print=1 $2"
|
|
||||||
|
|
||||||
|
append_plain() {
|
||||||
|
procd_append_param command "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
append_param() {
|
||||||
|
local cfg="$1"
|
||||||
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
|
config_get val "$cfg" "$var"
|
||||||
|
[ -n "$val" -o -n "$def" ] && procd_append_param "$opt" "${val:-$def}"
|
||||||
|
}
|
||||||
|
|
||||||
|
start_instance() {
|
||||||
|
local cfg="$1"
|
||||||
local enabled
|
local enabled
|
||||||
config_get_bool enabled "$config" enabled 0
|
|
||||||
[ "${enabled}" -eq 0 ] && return 1
|
|
||||||
|
|
||||||
local readonly
|
config_get_bool enabled "$cfg" 'enabled' '0'
|
||||||
config_get_bool readonly "$config" readonly 0
|
[ "$enabled" = 0 ] && return 1
|
||||||
[ "${readonly}" -eq 1 ] && append args "--readonly"
|
|
||||||
|
|
||||||
local error_level
|
procd_open_instance
|
||||||
config_get error_level "$config" error_level
|
|
||||||
[ -n "${error_level}" ] && append args "--error_level=${error_level}"
|
|
||||||
|
|
||||||
local options
|
procd_set_param command "$PROG" --foreground --error_print=1
|
||||||
config_get options "$config" options
|
|
||||||
|
|
||||||
devices=""
|
# common parameters
|
||||||
config_list_foreach "$config" devices append_device
|
append_bool "$cfg" readonly "--readonly"
|
||||||
|
append_arg "$cfg" error_level "--error_level"
|
||||||
|
config_list_foreach "$cfg" options append_plain
|
||||||
|
config_list_foreach "$cfg" devices append_plain
|
||||||
|
append_param "$cfg" user user
|
||||||
|
|
||||||
config_get SERVICE_UID "$config" uid "$DEFAULT_SERVICE_UID"
|
# owfs-specific
|
||||||
config_get SERVICE_GID "$config" gid "$DEFAULT_SERVICE_GID"
|
append_arg "$cfg" mountpoint "--mountpoint" /mnt/owfs
|
||||||
|
append_bool "$cfg" fuse_allow_other "--allow_other"
|
||||||
|
append_arg "$cfg" fuse_open_opt "--fuse_open_opt"
|
||||||
|
|
||||||
|
# don't respawn fuse
|
||||||
|
|
||||||
|
procd_close_instance
|
||||||
|
|
||||||
service_start "/usr/bin/$program" $args $options $devices
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_owfs() {
|
service_triggers() {
|
||||||
local config="owfs"
|
procd_add_reload_trigger owfs
|
||||||
local args=""
|
|
||||||
|
|
||||||
config_load "$config"
|
|
||||||
|
|
||||||
local mountpoint
|
|
||||||
config_get mountpoint "$config" mountpoint /mnt/owfs
|
|
||||||
append args "--mountpoint=${mountpoint}"
|
|
||||||
|
|
||||||
local fuse_allow_other
|
|
||||||
config_get_bool fuse_allow_other "$config" fuse_allow_other 0
|
|
||||||
[ "${fuse_allow_other}" -eq 1 ] && append args "--allow_other"
|
|
||||||
|
|
||||||
local fuse_open_opt
|
|
||||||
config_get fuse_open_opt "$config" fuse_open_opt
|
|
||||||
[ -n "${fuse_open_opt}" ] && append args "--fuse_open_opt=\"${fuse_open_opt}\""
|
|
||||||
|
|
||||||
start_owfs_daemon "$config" "$args"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start_service() {
|
||||||
start_owfs
|
config_load owfs
|
||||||
}
|
config_foreach start_instance owfs
|
||||||
|
|
||||||
stop() {
|
|
||||||
service_stop /usr/bin/owfs
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
config owftpd 'owftpd'
|
config owftpd 'owftpd'
|
||||||
option enabled 0
|
option enabled 0
|
||||||
option uid 0
|
option user root
|
||||||
option gid 0
|
|
||||||
option readonly 0
|
option readonly 0
|
||||||
option port 21
|
option port 21
|
||||||
option error_level 0
|
option error_level 0
|
||||||
option options ''
|
list devices '-s'
|
||||||
list devices '-s localhost:4304'
|
list devices 'localhost:4304'
|
||||||
|
|
|
@ -1,72 +1,81 @@
|
||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
# Copyright (C) 2009-2012 OpenWrt.org
|
# Copyright (C) 2009-2015 OpenWrt.org
|
||||||
|
|
||||||
START=99
|
START=95
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
SERVICE_WRITE_PID=1
|
PROG=/usr/bin/owftpd
|
||||||
SERVICE_DAEMONIZE=1
|
|
||||||
|
|
||||||
# Needed for restricted TCP port 21
|
append_arg() {
|
||||||
DEFAULT_SERVICE_UID=0
|
local cfg="$1"
|
||||||
DEFAULT_SERVICE_GID=0
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
append_device() {
|
config_get val "$cfg" "$var"
|
||||||
append devices "$1"
|
[ -n "$val" -o -n "$def" ] && procd_append_param command $opt "${val:-$def}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
append_bool() {
|
||||||
|
local cfg="$1"
|
||||||
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
start_owfs_daemon() {
|
config_get_bool val "$cfg" "$var" "$def"
|
||||||
local program="$1"
|
[ "$val" = 1 ] && procd_append_param command "$opt"
|
||||||
local config="$1"
|
}
|
||||||
local args="--foreground --error_print=1 $2"
|
|
||||||
|
|
||||||
|
append_plain() {
|
||||||
|
procd_append_param command "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
append_param() {
|
||||||
|
local cfg="$1"
|
||||||
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
|
config_get val "$cfg" "$var"
|
||||||
|
[ -n "$val" -o -n "$def" ] && procd_append_param "$opt" "${val:-$def}"
|
||||||
|
}
|
||||||
|
|
||||||
|
start_instance() {
|
||||||
|
local cfg="$1"
|
||||||
local enabled
|
local enabled
|
||||||
config_get_bool enabled "$config" enabled 0
|
|
||||||
[ "${enabled}" -eq 0 ] && return 1
|
|
||||||
|
|
||||||
local readonly
|
config_get_bool enabled "$cfg" 'enabled' '0'
|
||||||
config_get_bool readonly "$config" readonly 0
|
[ "$enabled" = 0 ] && return 1
|
||||||
[ "${readonly}" -eq 1 ] && append args "--readonly"
|
|
||||||
|
|
||||||
local error_level
|
procd_open_instance
|
||||||
config_get error_level "$config" error_level
|
|
||||||
[ -n "${error_level}" ] && append args "--error_level=${error_level}"
|
|
||||||
|
|
||||||
local options
|
procd_set_param command "$PROG" --foreground --error_print=1
|
||||||
config_get options "$config" options
|
|
||||||
|
|
||||||
devices=""
|
# common parameters
|
||||||
config_list_foreach "$config" devices append_device
|
append_bool "$cfg" readonly "--readonly"
|
||||||
|
append_arg "$cfg" error_level "--error_level"
|
||||||
|
config_list_foreach "$cfg" options append_plain
|
||||||
|
config_list_foreach "$cfg" devices append_plain
|
||||||
|
append_param "$cfg" user user
|
||||||
|
|
||||||
config_get SERVICE_UID "$config" uid "$DEFAULT_SERVICE_UID"
|
# owftpd-specific
|
||||||
config_get SERVICE_GID "$config" gid "$DEFAULT_SERVICE_GID"
|
append_arg "$cfg" port "--port"
|
||||||
|
append_arg "$cfg" max_connections "--max_connections"
|
||||||
|
|
||||||
|
procd_set_param respawn
|
||||||
|
|
||||||
|
procd_close_instance
|
||||||
|
|
||||||
service_start "/usr/bin/$program" $args $options $devices
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_owftpd() {
|
service_triggers() {
|
||||||
local config="owftpd"
|
procd_add_reload_trigger owftpd
|
||||||
local args=""
|
|
||||||
|
|
||||||
config_load "$config"
|
|
||||||
|
|
||||||
local port
|
|
||||||
config_get port "$config" port
|
|
||||||
[ -n "${port}" ] && append args "--port=${port}"
|
|
||||||
|
|
||||||
local max_connections
|
|
||||||
config_get max_connections "$config" max_connections
|
|
||||||
[ -n "${max_connections}" ] && append args "--max_connections=${max_connections}"
|
|
||||||
|
|
||||||
start_owfs_daemon "$config" "$args"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
start() {
|
config_load owftpd
|
||||||
start_owftpd
|
config_foreach start_instance owftpd
|
||||||
}
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
service_stop /usr/bin/owftpd
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
config owhttpd 'owhttpd'
|
config owhttpd 'owhttpd'
|
||||||
option enabled 0
|
option enabled 0
|
||||||
option uid 65534
|
option user root
|
||||||
option gid 65534
|
|
||||||
option readonly 0
|
option readonly 0
|
||||||
option port 3001
|
option port 3001
|
||||||
option error_level 0
|
option error_level 0
|
||||||
option options ''
|
list devices '-s'
|
||||||
list devices '-s localhost:4304'
|
list devices 'localhost:4304'
|
||||||
|
|
|
@ -1,71 +1,81 @@
|
||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
# Copyright (C) 2009-2012 OpenWrt.org
|
# Copyright (C) 2009-2015 OpenWrt.org
|
||||||
|
|
||||||
START=99
|
START=95
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
SERVICE_WRITE_PID=1
|
PROG=/usr/bin/owhttpd
|
||||||
SERVICE_DAEMONIZE=1
|
|
||||||
|
|
||||||
DEFAULT_SERVICE_UID=65534
|
append_arg() {
|
||||||
DEFAULT_SERVICE_GID=65534
|
local cfg="$1"
|
||||||
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
append_device() {
|
config_get val "$cfg" "$var"
|
||||||
append devices "$1"
|
[ -n "$val" -o -n "$def" ] && procd_append_param command $opt "${val:-$def}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
append_bool() {
|
||||||
|
local cfg="$1"
|
||||||
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
start_owfs_daemon() {
|
config_get_bool val "$cfg" "$var" "$def"
|
||||||
local program="$1"
|
[ "$val" = 1 ] && procd_append_param command "$opt"
|
||||||
local config="$1"
|
}
|
||||||
local args="--foreground --error_print=1 $2"
|
|
||||||
|
|
||||||
|
append_plain() {
|
||||||
|
procd_append_param command "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
append_param() {
|
||||||
|
local cfg="$1"
|
||||||
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
|
config_get val "$cfg" "$var"
|
||||||
|
[ -n "$val" -o -n "$def" ] && procd_append_param "$opt" "${val:-$def}"
|
||||||
|
}
|
||||||
|
|
||||||
|
start_instance() {
|
||||||
|
local cfg="$1"
|
||||||
local enabled
|
local enabled
|
||||||
config_get_bool enabled "$config" enabled 0
|
|
||||||
[ "${enabled}" -eq 0 ] && return 1
|
|
||||||
|
|
||||||
local readonly
|
config_get_bool enabled "$cfg" 'enabled' '0'
|
||||||
config_get_bool readonly "$config" readonly 0
|
[ "$enabled" = 0 ] && return 1
|
||||||
[ "${readonly}" -eq 1 ] && append args "--readonly"
|
|
||||||
|
|
||||||
local error_level
|
procd_open_instance
|
||||||
config_get error_level "$config" error_level
|
|
||||||
[ -n "${error_level}" ] && append args "--error_level=${error_level}"
|
|
||||||
|
|
||||||
local options
|
procd_set_param command "$PROG" --foreground --error_print=1
|
||||||
config_get options "$config" options
|
|
||||||
|
|
||||||
devices=""
|
# common parameters
|
||||||
config_list_foreach "$config" devices append_device
|
append_bool "$cfg" readonly "--readonly"
|
||||||
|
append_arg "$cfg" error_level "--error_level"
|
||||||
|
config_list_foreach "$cfg" options append_plain
|
||||||
|
config_list_foreach "$cfg" devices append_plain
|
||||||
|
append_param "$cfg" user user
|
||||||
|
|
||||||
config_get SERVICE_UID "$config" uid "$DEFAULT_SERVICE_UID"
|
# owhttpd-specific
|
||||||
config_get SERVICE_GID "$config" gid "$DEFAULT_SERVICE_GID"
|
append_arg "$cfg" port "--port"
|
||||||
|
append_arg "$cfg" max_connections "--max_connections"
|
||||||
|
|
||||||
|
procd_set_param respawn
|
||||||
|
|
||||||
|
procd_close_instance
|
||||||
|
|
||||||
service_start "/usr/bin/$program" $args $options $devices
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_owhttpd() {
|
service_triggers() {
|
||||||
local config="owhttpd"
|
procd_add_reload_trigger owhttpd
|
||||||
local args=""
|
|
||||||
|
|
||||||
config_load "$config"
|
|
||||||
|
|
||||||
local port
|
|
||||||
config_get port "$config" port
|
|
||||||
[ -n "${port}" ] && append args "--port=${port}"
|
|
||||||
|
|
||||||
local max_connections
|
|
||||||
config_get max_connections "$config" max_connections
|
|
||||||
[ -n "${max_connections}" ] && append args "--max_connections=${max_connections}"
|
|
||||||
|
|
||||||
start_owfs_daemon "$config" "$args"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
start() {
|
config_load owhttpd
|
||||||
start_owhttpd
|
config_foreach start_instance owhttpd
|
||||||
}
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
service_stop /usr/bin/owhttpd
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
config owserver 'owserver'
|
config owserver 'owserver'
|
||||||
option enabled 0
|
option enabled 0
|
||||||
option uid 65534
|
option user root
|
||||||
option gid 65534
|
|
||||||
option readonly 0
|
option readonly 0
|
||||||
option port 4304
|
option port 4304
|
||||||
option error_level 0
|
option error_level 0
|
||||||
option options ''
|
list devices '-d'
|
||||||
list devices '-d /dev/ttyUSB0'
|
list devices '/dev/ttyUSB0'
|
||||||
|
|
|
@ -1,70 +1,81 @@
|
||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
# Copyright (C) 2009-2012 OpenWrt.org
|
# Copyright (C) 2009-2015 OpenWrt.org
|
||||||
|
|
||||||
START=98
|
START=90
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
SERVICE_WRITE_PID=1
|
PROG=/usr/bin/owserver
|
||||||
SERVICE_DAEMONIZE=1
|
|
||||||
|
|
||||||
DEFAULT_SERVICE_UID=65534
|
append_arg() {
|
||||||
DEFAULT_SERVICE_GID=65534
|
local cfg="$1"
|
||||||
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
append_device() {
|
config_get val "$cfg" "$var"
|
||||||
append devices "$1"
|
[ -n "$val" -o -n "$def" ] && procd_append_param command $opt "${val:-$def}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
append_bool() {
|
||||||
|
local cfg="$1"
|
||||||
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
start_owfs_daemon() {
|
config_get_bool val "$cfg" "$var" "$def"
|
||||||
local program="$1"
|
[ "$val" = 1 ] && procd_append_param command "$opt"
|
||||||
local config="$1"
|
}
|
||||||
local args="--foreground --error_print=1 $2"
|
|
||||||
|
|
||||||
|
append_plain() {
|
||||||
|
procd_append_param command "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
append_param() {
|
||||||
|
local cfg="$1"
|
||||||
|
local var="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local def="$4"
|
||||||
|
local val
|
||||||
|
|
||||||
|
config_get val "$cfg" "$var"
|
||||||
|
[ -n "$val" -o -n "$def" ] && procd_append_param "$opt" "${val:-$def}"
|
||||||
|
}
|
||||||
|
|
||||||
|
start_instance() {
|
||||||
|
local cfg="$1"
|
||||||
local enabled
|
local enabled
|
||||||
config_get_bool enabled "$config" enabled 0
|
|
||||||
[ "${enabled}" -eq 0 ] && return 1
|
|
||||||
|
|
||||||
local readonly
|
config_get_bool enabled "$cfg" 'enabled' '0'
|
||||||
config_get_bool readonly "$config" readonly 0
|
[ "$enabled" = 0 ] && return 1
|
||||||
[ "${readonly}" -eq 1 ] && append args "--readonly"
|
|
||||||
|
|
||||||
local error_level
|
procd_open_instance
|
||||||
config_get error_level "$config" error_level
|
|
||||||
[ -n "${error_level}" ] && append args "--error_level=${error_level}"
|
|
||||||
|
|
||||||
local options
|
procd_set_param command "$PROG" --foreground --error_print=1
|
||||||
config_get options "$config" options
|
|
||||||
|
|
||||||
devices=""
|
# common parameters
|
||||||
config_list_foreach "$config" devices append_device
|
append_bool "$cfg" readonly "--readonly"
|
||||||
|
append_arg "$cfg" error_level "--error_level"
|
||||||
|
config_list_foreach "$cfg" options append_plain
|
||||||
|
config_list_foreach "$cfg" devices append_plain
|
||||||
|
append_param "$cfg" user user
|
||||||
|
|
||||||
config_get SERVICE_UID "$config" uid "$DEFAULT_SERVICE_UID"
|
# owserver-specific
|
||||||
config_get SERVICE_GID "$config" gid "$DEFAULT_SERVICE_GID"
|
append_arg "$cfg" port "--port"
|
||||||
|
append_arg "$cfg" max_connections "--max_connections"
|
||||||
|
|
||||||
|
procd_set_param respawn
|
||||||
|
|
||||||
|
procd_close_instance
|
||||||
|
|
||||||
service_start "/usr/bin/$program" $args $options $devices
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_owserver() {
|
service_triggers() {
|
||||||
local config="owserver"
|
procd_add_reload_trigger owserver
|
||||||
local args=""
|
|
||||||
|
|
||||||
config_load "$config"
|
|
||||||
|
|
||||||
local port
|
|
||||||
config_get port "$config" port
|
|
||||||
[ -n "${port}" ] && append args "--port=${port}"
|
|
||||||
|
|
||||||
local max_connections
|
|
||||||
config_get max_connections "$config" max_connections
|
|
||||||
[ -n "${max_connections}" ] && append args "--max_connections=${max_connections}"
|
|
||||||
|
|
||||||
start_owfs_daemon "$config" "$args"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start_service() {
|
||||||
start_owserver
|
config_load owserver
|
||||||
}
|
config_foreach start_instance owserver
|
||||||
|
|
||||||
stop() {
|
|
||||||
service_stop /usr/bin/owserver
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue