From 6ef5b97beb9e0d3079660d2c3202568fb8b4f0d6 Mon Sep 17 00:00:00 2001 From: fbt Date: Fri, 4 Sep 2015 16:47:37 +0300 Subject: [PATCH] service_args is now an array --- init.d/acpid | 2 +- init.d/agetty | 2 +- init.d/alsa | 2 +- init.d/bitflu | 2 +- init.d/bitlbee | 2 +- init.d/chrony | 2 +- init.d/connmand | 2 +- init.d/cupsd | 2 +- init.d/dbus | 2 +- init.d/devfs | 31 ------------------------------- init.d/dhcpcd | 2 +- init.d/docker | 2 +- init.d/dropbear | 2 +- init.d/eudev | 6 +----- init.d/hostname | 2 +- init.d/isc-dhcpd | 2 +- init.d/kmscon | 2 +- init.d/lo.iface | 2 +- init.d/mariadb | 2 +- init.d/mdev | 9 ++------- init.d/memcached | 2 +- init.d/miscfs | 34 ---------------------------------- init.d/mpd | 2 +- init.d/nrpe | 2 +- init.d/ntp | 2 +- init.d/oidentd | 2 +- init.d/openntpd | 2 +- init.d/openvpn | 2 +- init.d/openvpn-server | 2 +- init.d/pamusb | 4 ++-- init.d/php-fpm | 2 +- init.d/preload | 2 +- init.d/privoxy | 4 ++-- init.d/rsyslogd | 2 +- init.d/scron | 2 +- init.d/smdev | 9 ++------- init.d/sshd | 9 ++------- init.d/sysctl | 26 ++++++++++++++++++-------- init.d/syslog-ng | 2 +- init.d/system | 13 ------------- init.d/systemd-udevd | 6 +----- init.d/teamviewerd | 2 +- init.d/unbound | 2 +- init.d/vdevd | 2 +- init.d/vixie-cron | 2 +- init.d/xinetd | 2 +- init.d/znet | 2 +- 47 files changed, 66 insertions(+), 157 deletions(-) delete mode 100755 init.d/devfs delete mode 100755 init.d/miscfs delete mode 100755 init.d/system diff --git a/init.d/acpid b/init.d/acpid index 44024ad..109d715 100755 --- a/init.d/acpid +++ b/init.d/acpid @@ -2,4 +2,4 @@ #service_respawn='true' service_command='/usr/bin/acpid' -service_args="-f" +service_args=( -f ) diff --git a/init.d/agetty b/init.d/agetty index 150729b..fdc9ed2 100755 --- a/init.d/agetty +++ b/init.d/agetty @@ -2,4 +2,4 @@ service_respawn='true' service_command='/usr/bin/agetty' -service_args="38400 ${service_name##*-} linux" +service_args=( 38400 "${service_name##*-}" linux ) diff --git a/init.d/alsa b/init.d/alsa index 7b3fb65..cd0c135 100755 --- a/init.d/alsa +++ b/init.d/alsa @@ -2,7 +2,7 @@ #service_respawn='true' service_command='/usr/bin/alsactl' -service_args="rdaemon" +service_args=( rdaemon ) stop() { "$service_command" kill save_and_quit diff --git a/init.d/bitflu b/init.d/bitflu index 4d81d83..87cee11 100755 --- a/init.d/bitflu +++ b/init.d/bitflu @@ -3,7 +3,7 @@ #service_respawn='true' service_username='torrent' service_command='/usr/bin/sudo' -service_args="-u $service_username -- /usr/bin/bitflu --config=/etc/bitflu.cfg" +service_args=( -u "$service_username" -- /usr/bin/bitflu --config=/etc/bitflu.cfg ) start() { umask 0007 diff --git a/init.d/bitlbee b/init.d/bitlbee index b18b008..f42e652 100755 --- a/init.d/bitlbee +++ b/init.d/bitlbee @@ -4,4 +4,4 @@ #service_respawn=true service_command='/usr/bin/bitlbee' -service_args='-n' +service_args=( -n ) diff --git a/init.d/chrony b/init.d/chrony index 18fd9ae..35b7fb9 100755 --- a/init.d/chrony +++ b/init.d/chrony @@ -2,4 +2,4 @@ #service_respawn='true' service_command='/usr/bin/chronyd' -service_args='-u chrony' +service_args=( -u chrony ) diff --git a/init.d/connmand b/init.d/connmand index 27c0e17..063d180 100755 --- a/init.d/connmand +++ b/init.d/connmand @@ -5,4 +5,4 @@ depends dbus || return 1 #service_respawn='true' service_command='/usr/bin/connmand' -service_args='-n' +service_args=( -n ) diff --git a/init.d/cupsd b/init.d/cupsd index 8bc310f..38062d8 100755 --- a/init.d/cupsd +++ b/init.d/cupsd @@ -2,4 +2,4 @@ #service_respawn='true' service_command='/usr/bin/cupsd' -service_args="-f" +service_args=( -f ) diff --git a/init.d/dbus b/init.d/dbus index 4ce4722..84acf9b 100755 --- a/init.d/dbus +++ b/init.d/dbus @@ -2,7 +2,7 @@ #service_respawn=true service_command='/usr/bin/dbus-daemon' -service_args='--system --nofork' +service_args=( --system --nofork ) service_tmpfiles=( '/run/dbus:dir' ) start_pre() { diff --git a/init.d/devfs b/init.d/devfs deleted file mode 100755 index b25176e..0000000 --- a/init.d/devfs +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env watchman - -service_type='oneshot' - -cfg_mounts+=( 'dev:devtmpfs:defaults:/dev' ) -cfg_mounts+=( '/dev/pts:devpts:noexec,nosuid,gid=5,mode=0620:/dev/pts' ) -cfg_mounts+=( '/dev/mqueue:mqueue:noexec,nosuid,nodev:/dev/mqueue' ) -cfg_mounts+=( 'tmpfs:tmpfs:defaults,mode=0777:/dev/shm' ) - -spawn() { - for m in ${cfg_mounts[@]}; do - fs_dev=`echo "$m" | cut -d':' -f1` - fs_type=`echo "$m" | cut -d':' -f2` - fs_opts=`echo "$m" | cut -d':' -f3` - fs_mountpoint=`echo "$m" | cut -d':' -f4` - - mountpoint -q "$fs_mountpoint" || { - [[ -d "$fs_mountpoint" ]] || { mkdir "$fs_mountpoint"; } - mount "$fs_dev" -n -t "$fs_type" -o "$fs_opts" "$fs_mountpoint" - } - done -} - -stop() { - for m in "${cfg_mounts[@]}"; do - fs_mountpoint=`echo "$m" | cut -d ':' -f 4` - mountpoint -q "$fs_mountpoint" && { - umount "$fs_mountpoint" - } - done -} diff --git a/init.d/dhcpcd b/init.d/dhcpcd index 090fb0f..1dacf4b 100755 --- a/init.d/dhcpcd +++ b/init.d/dhcpcd @@ -3,4 +3,4 @@ #service_respawn=true service_command='/usr/bin/dhcpcd' -service_args='-B' +service_args=( -B ) diff --git a/init.d/docker b/init.d/docker index 1d5a951..a607691 100755 --- a/init.d/docker +++ b/init.d/docker @@ -4,7 +4,7 @@ docker_dir='/home/docker' #service_respawn='true' service_command='/usr/bin/docker' -service_args="-g ${docker_dir} -d" +service_args=( -g "$docker_dir" -d ) update() { watchman.stop && { diff --git a/init.d/dropbear b/init.d/dropbear index 56dd0d9..58ffa15 100755 --- a/init.d/dropbear +++ b/init.d/dropbear @@ -2,4 +2,4 @@ service_respawn=true service_command='/usr/bin/dropbear' -service_args="-R -w -F" +service_args=( -R -w -F ) diff --git a/init.d/eudev b/init.d/eudev index 77ea262..067a366 100755 --- a/init.d/eudev +++ b/init.d/eudev @@ -15,11 +15,7 @@ udev.populate_dev() { udevadm control --property=do_not_run_plug_service= } -start() { - watchman.start - sleep 1 - udev.populate_dev -} +post_start() { sleep 1; udev.populate_dev; } reload() { udevadm control --reload diff --git a/init.d/hostname b/init.d/hostname index a704149..7e993af 100644 --- a/init.d/hostname +++ b/init.d/hostname @@ -9,4 +9,4 @@ fi service_type='oneshot' service_command='/usr/bin/hostname' -service_args="$cfg_hostname" +service_args=( "$cfg_hostname" ) diff --git a/init.d/isc-dhcpd b/init.d/isc-dhcpd index 236221d..2fd8c9e 100755 --- a/init.d/isc-dhcpd +++ b/init.d/isc-dhcpd @@ -3,4 +3,4 @@ #service_respawn=true service_command='/usr/sbin/dhcpd' -service_args='-f' +service_args=( -f ) diff --git a/init.d/kmscon b/init.d/kmscon index 6dcda75..dd0708a 100755 --- a/init.d/kmscon +++ b/init.d/kmscon @@ -4,4 +4,4 @@ tty=${service_name##*-}; service_respawn='true' service_command='/usr/bin/kmscon' -service_args="--vt ${tty}" +service_args=( --vt "$tty" ) diff --git a/init.d/lo.iface b/init.d/lo.iface index 4af61d0..589c46d 100755 --- a/init.d/lo.iface +++ b/init.d/lo.iface @@ -4,7 +4,7 @@ cfg_iface="${service_name%%.*}" service_type='oneshot' service_command='/usr/bin/ip' -service_args="link set $cfg_iface up" +service_args=( link set "$cfg_iface" up) wait_for_iface() { local iface="$1" timer='0' timeout='6' diff --git a/init.d/mariadb b/init.d/mariadb index 32f8f1b..6ac9322 100755 --- a/init.d/mariadb +++ b/init.d/mariadb @@ -3,4 +3,4 @@ #service_respawn='true' service_workdir='/usr' service_command='/usr/bin/mysqld_safe' -service_args='--datadir=/var/lib/mysql' +service_args=( --datadir=/var/lib/mysql ) diff --git a/init.d/mdev b/init.d/mdev index 9484a95..caa469c 100755 --- a/init.d/mdev +++ b/init.d/mdev @@ -2,14 +2,9 @@ service_type='oneshot' service_command='/usr/bin/mdev' -service_args='-s' +service_args=( -s ) -hotplug() { +post_start() { echo "Enabling hotplug..." echo /bin/mdev > /proc/sys/kernel/hotplug } - -start() { - watchman.start - hotplug -} diff --git a/init.d/memcached b/init.d/memcached index fccc1d1..20f284f 100755 --- a/init.d/memcached +++ b/init.d/memcached @@ -2,4 +2,4 @@ #service_respawn=true service_command='/usr/bin/memcached' -service_args='-m 64 -p 11211 -u nobody -l 127.0.0.1' +service_args=( -m 64 -p 11211 -u nobody -l 127.0.0.1 ) diff --git a/init.d/miscfs b/init.d/miscfs deleted file mode 100755 index d86146e..0000000 --- a/init.d/miscfs +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env watchman - -service_type='oneshot' - -cfg_mounts+=( 'proc:proc:defaults:/proc' ) -cfg_mounts+=( 'run:tmpfs:defaults:/run' ) -cfg_mounts+=( 'sys:sysfs:defaults:/sys' ) - -spawn() { - for m in ${cfg_mounts[@]}; do - fs_dev=`echo "$m" | cut -d':' -f1` - fs_type=`echo "$m" | cut -d':' -f2` - fs_opts=`echo "$m" | cut -d':' -f3` - fs_mountpoint=`echo "$m" | cut -d':' -f4` - - mountpoint -q "$fs_mountpoint" || { - [[ -d "$fs_mountpoint" ]] || { mkdir "$fs_mountpoint"; } - mount "$fs_dev" -n -t "$fs_type" -o "$fs_opts" "$fs_mountpoint" || { - watchman.err "could not mount $fs_dev on $fs_mountpoint :(" - } - } - done - - return 0 -} - -stop() { - for m in "${cfg_mounts[@]}"; do - fs_mountpoint=`echo "$m" | cut -d ':' -f 4` - mountpoint -q "$fs_mountpoint" && { - umount "$fs_mountpoint" - } - done -} diff --git a/init.d/mpd b/init.d/mpd index 1567f73..e7923e3 100755 --- a/init.d/mpd +++ b/init.d/mpd @@ -2,4 +2,4 @@ #service_respawn=true service_command='/usr/bin/mpd' -service_args='--no-daemon' +service_args=( --no-daemon ) diff --git a/init.d/nrpe b/init.d/nrpe index 0998eb0..6279c18 100755 --- a/init.d/nrpe +++ b/init.d/nrpe @@ -5,4 +5,4 @@ cfg_nrpe_config='/etc/nrpe/nrpe.cfg' #service_respawn=true service_command='/usr/bin/nrpe' service_pidfile='/run/nrpe.pid' -service_args="-c ${cfg_nrpe_config} -d" +service_args=( -c "$cfg_nrpe_config" -d ) diff --git a/init.d/ntp b/init.d/ntp index 6048d39..9571d25 100755 --- a/init.d/ntp +++ b/init.d/ntp @@ -2,4 +2,4 @@ #service_respawn='true' service_command='/usr/bin/ntpd' -service_args='-n' +service_args=( -n ) diff --git a/init.d/oidentd b/init.d/oidentd index 52d285c..08237a2 100755 --- a/init.d/oidentd +++ b/init.d/oidentd @@ -1,4 +1,4 @@ #!/usr/bin/watchman service_command='/usr/bin/oidentd' -service_args='-i' +service_args=( -i ) diff --git a/init.d/openntpd b/init.d/openntpd index b39d843..793a67a 100755 --- a/init.d/openntpd +++ b/init.d/openntpd @@ -2,4 +2,4 @@ #service_respawn='true' service_command='/usr/bin/ntpd' -service_args='-d' +service_args=( -d ) diff --git a/init.d/openvpn b/init.d/openvpn index cffb260..79fc0ff 100755 --- a/init.d/openvpn +++ b/init.d/openvpn @@ -5,4 +5,4 @@ cfg_ovpn_instance="${service_name##*-}" service_respawn='true' service_command="/usr/bin/openvpn" service_workdir="/etc/openvpn/$cfg_ovpn_instance" -service_args="client.cfg" +service_args=( client.cfg ) diff --git a/init.d/openvpn-server b/init.d/openvpn-server index f105aa3..2ec2a59 100755 --- a/init.d/openvpn-server +++ b/init.d/openvpn-server @@ -3,4 +3,4 @@ service_respawn='true' service_command="/usr/sbin/openvpn" service_workdir="/etc/openvpn" -service_args="server.conf" +service_args=( server.conf ) diff --git a/init.d/pamusb b/init.d/pamusb index d8fbc6e..2300747 100755 --- a/init.d/pamusb +++ b/init.d/pamusb @@ -1,5 +1,5 @@ #!/usr/bin/env watchman -service_command='/usr/bin/mkdir' -service_args='-p /run/lock' service_type='oneshot' +service_command='/usr/bin/mkdir' +service_args=( -p /run/lock ) diff --git a/init.d/php-fpm b/init.d/php-fpm index 078af66..9abfdbe 100755 --- a/init.d/php-fpm +++ b/init.d/php-fpm @@ -2,4 +2,4 @@ #service_respawn='true' service_command='/usr/bin/php-fpm' -service_args='-F --fpm-config /etc/php/php-fpm.conf -c /etc/php/php.ini' +service_args=( -F --fpm-config /etc/php/php-fpm.conf -c /etc/php/php.ini ) diff --git a/init.d/preload b/init.d/preload index 37dfcbc..98ce9bb 100755 --- a/init.d/preload +++ b/init.d/preload @@ -2,4 +2,4 @@ #service_respawn='true' service_command='/usr/bin/preload' -service_args='-f' +service_args=( -f ) diff --git a/init.d/privoxy b/init.d/privoxy index 780c339..7b85641 100755 --- a/init.d/privoxy +++ b/init.d/privoxy @@ -5,10 +5,10 @@ privoxy_configfile='/etc/privoxy/config' #service_respawn='true' service_command='/usr/bin/privoxy' -service_args="--no-daemon --user ${privoxy_username} ${privoxy_configfile}" +service_args=( --no-daemon --user "$privoxy_username" "$privoxy_configfile" ) privoxy::configtest() { - "${service_command}" --config-test ${service_args} + "$service_command" --config-test "${service_args[@]}" } restart() { diff --git a/init.d/rsyslogd b/init.d/rsyslogd index 61700ea..96ce19a 100755 --- a/init.d/rsyslogd +++ b/init.d/rsyslogd @@ -3,4 +3,4 @@ #service_respawn=true service_command='/usr/bin/rsyslogd' -service_args='-n' +service_args=( -n ) diff --git a/init.d/scron b/init.d/scron index b6b321d..e91c088 100755 --- a/init.d/scron +++ b/init.d/scron @@ -2,4 +2,4 @@ #service_respawn='true' service_command='/usr/bin/crond' -service_args='-n' +service_args=( -n ) diff --git a/init.d/smdev b/init.d/smdev index 8b527e6..af1af39 100755 --- a/init.d/smdev +++ b/init.d/smdev @@ -2,14 +2,9 @@ service_type='oneshot' service_command='/usr/bin/smdev' -service_args='-s' +service_args=( -s ) -hotplug() { +post_start() { echo "Enabling hotplug..." echo /bin/smdev > /proc/sys/kernel/hotplug } - -start() { - watchman.start - hotplug -} diff --git a/init.d/sshd b/init.d/sshd index d629fc9..8ce2cfd 100755 --- a/init.d/sshd +++ b/init.d/sshd @@ -4,13 +4,8 @@ cfg_sshd_cfgdir='/etc/ssh' service_respawn=true service_command='/usr/bin/sshd' -service_args="-D -f $cfg_sshd_cfgdir/sshd_config" +service_args=( -D -f "$cfg_sshd_cfgdir/sshd_config" ) -sshd_genkeys() { +pre_start() { [[ -e "/etc/ssh/ssh_host_key" ]] || { ssh-keygen -A; } } - -start() { - sshd_genkeys - watchman.start -} diff --git a/init.d/sysctl b/init.d/sysctl index 0369064..99bfa41 100755 --- a/init.d/sysctl +++ b/init.d/sysctl @@ -1,13 +1,23 @@ #!/usr/bin/env watchman - -for i in /etc/sysctl.conf /etc/sysctl.d/* /usr/lib/sysctl.d/*; do - [[ -f "$i" ]] && { - sysctl_config_files+=( "$i" ) - } -done +unset reload service_type='oneshot' service_command='/usr/bin/sysctl' -service_args="-p ${sysctl_config_files[@]}" -unset restart reload +pre_start() { + for i in /etc/sysctl.conf /etc/sysctl.d/* /usr/lib/sysctl.d/*; do + [[ -f "$i" ]] && { + sysctl_config_files+=( "$i" ) + } + done + + service_args=( -p "${sysctl_config_files[@]}" ) +} + +start() { + if ! [[ "$sysctl_config_files" ]]; then + return 0 + fi + + watchman.start +} diff --git a/init.d/syslog-ng b/init.d/syslog-ng index bbf888c..bb0adaa 100755 --- a/init.d/syslog-ng +++ b/init.d/syslog-ng @@ -2,4 +2,4 @@ #service_respawn=true service_command='/usr/bin/syslog-ng' -service_args='-F' +service_args=( -F ) diff --git a/init.d/system b/init.d/system deleted file mode 100755 index 19aad44..0000000 --- a/init.d/system +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env watchman - -unset start stop restart reload status - -reboot() { - echo "Rebooting..." - kill -2 1 -} - -poweroff() { - echo "Powering off..." - kill -10 1 -} diff --git a/init.d/systemd-udevd b/init.d/systemd-udevd index dc465ff..6305def 100755 --- a/init.d/systemd-udevd +++ b/init.d/systemd-udevd @@ -15,11 +15,7 @@ udev.populate_dev() { udevadm control --property=do_not_run_plug_service= } -start() { - watchman.start - sleep 1 - udev.populate_dev -} +post_start() { sleep 1; udev.populate_dev; } reload() { udevadm control --reload diff --git a/init.d/teamviewerd b/init.d/teamviewerd index 01cbecf..80f3808 100755 --- a/init.d/teamviewerd +++ b/init.d/teamviewerd @@ -3,4 +3,4 @@ #service_respawn=true service_pidfile='/run/teamviewerd.pid' service_command='/opt/teamviewer8/tv_bin/teamviewerd' -service_args='-d' +service_args=( -d ) diff --git a/init.d/unbound b/init.d/unbound index 5151eb2..b3deb79 100755 --- a/init.d/unbound +++ b/init.d/unbound @@ -2,4 +2,4 @@ #service_respawn='true' service_command='/usr/bin/unbound' -service_args='-d' +service_args=( -d ) diff --git a/init.d/vdevd b/init.d/vdevd index 96affd0..67ba0cd 100755 --- a/init.d/vdevd +++ b/init.d/vdevd @@ -2,5 +2,5 @@ #service_respawn='true' service_command='/usr/bin/vdevd' -service_args='-f /dev' +service_args=( -f /dev ) service_tmpfiles=( '/run/vdev:dir' '/run/udev:symlink:/dev/metadata/udev' ) diff --git a/init.d/vixie-cron b/init.d/vixie-cron index 93df6cb..419fdd9 100755 --- a/init.d/vixie-cron +++ b/init.d/vixie-cron @@ -2,4 +2,4 @@ #service_respawn='true' service_command='/usr/bin/crond' -service_args='-f' +service_args=( -f ) diff --git a/init.d/xinetd b/init.d/xinetd index 6fc41ce..ffcb34b 100755 --- a/init.d/xinetd +++ b/init.d/xinetd @@ -2,4 +2,4 @@ #service_respawn=true service_command='/usr/bin/xinetd' -service_args='-dontfork' +service_args=( -dontfork ) diff --git a/init.d/znet b/init.d/znet index 22786fa..489baf6 100755 --- a/init.d/znet +++ b/init.d/znet @@ -2,7 +2,7 @@ service_type='oneshot' service_command='/usr/local/sbin/znet' -service_args='-d' +service_args=( -d ) stop() { "$service_command" $service_args down