From 4207e46622f584eb5f0cc10bbfd36f92f001a2e2 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Wed, 22 Feb 2017 12:26:09 -0600 Subject: move init.d examples under support and install them --- README.md | 4 - init.d.misc/.gitignore | 11 --- init.d.misc/Makefile | 11 --- init.d.misc/avahi-dnsconfd.in | 22 ------ init.d.misc/avahid.in | 22 ------ init.d.misc/dbus.in | 26 ------- init.d.misc/dhcpcd.in | 34 --------- init.d.misc/dnsmasq.in | 31 -------- init.d.misc/hald.in | 20 ----- init.d.misc/named.in | 119 ------------------------------ init.d.misc/ntpd.in | 44 ----------- init.d.misc/openvpn.in | 74 ------------------- init.d.misc/polkitd.in | 20 ----- init.d.misc/sshd.in | 42 ----------- init.d.misc/wpa_supplicant.in | 82 -------------------- support/Makefile | 2 +- support/init.d.examples/.gitignore | 11 +++ support/init.d.examples/Makefile | 13 ++++ support/init.d.examples/README.md | 3 + support/init.d.examples/avahi-dnsconfd.in | 22 ++++++ support/init.d.examples/avahid.in | 22 ++++++ support/init.d.examples/dbus.in | 26 +++++++ support/init.d.examples/dhcpcd.in | 34 +++++++++ support/init.d.examples/dnsmasq.in | 31 ++++++++ support/init.d.examples/hald.in | 20 +++++ support/init.d.examples/named.in | 119 ++++++++++++++++++++++++++++++ support/init.d.examples/ntpd.in | 44 +++++++++++ support/init.d.examples/openvpn.in | 74 +++++++++++++++++++ support/init.d.examples/polkitd.in | 20 +++++ support/init.d.examples/sshd.in | 42 +++++++++++ support/init.d.examples/wpa_supplicant.in | 82 ++++++++++++++++++++ 31 files changed, 564 insertions(+), 563 deletions(-) delete mode 100644 init.d.misc/.gitignore delete mode 100644 init.d.misc/Makefile delete mode 100644 init.d.misc/avahi-dnsconfd.in delete mode 100644 init.d.misc/avahid.in delete mode 100644 init.d.misc/dbus.in delete mode 100644 init.d.misc/dhcpcd.in delete mode 100644 init.d.misc/dnsmasq.in delete mode 100644 init.d.misc/hald.in delete mode 100644 init.d.misc/named.in delete mode 100644 init.d.misc/ntpd.in delete mode 100644 init.d.misc/openvpn.in delete mode 100644 init.d.misc/polkitd.in delete mode 100644 init.d.misc/sshd.in delete mode 100644 init.d.misc/wpa_supplicant.in create mode 100644 support/init.d.examples/.gitignore create mode 100644 support/init.d.examples/Makefile create mode 100644 support/init.d.examples/README.md create mode 100644 support/init.d.examples/avahi-dnsconfd.in create mode 100644 support/init.d.examples/avahid.in create mode 100644 support/init.d.examples/dbus.in create mode 100644 support/init.d.examples/dhcpcd.in create mode 100644 support/init.d.examples/dnsmasq.in create mode 100644 support/init.d.examples/hald.in create mode 100644 support/init.d.examples/named.in create mode 100644 support/init.d.examples/ntpd.in create mode 100644 support/init.d.examples/openvpn.in create mode 100644 support/init.d.examples/polkitd.in create mode 100644 support/init.d.examples/sshd.in create mode 100644 support/init.d.examples/wpa_supplicant.in diff --git a/README.md b/README.md index 9e61d193..80b28a9b 100644 --- a/README.md +++ b/README.md @@ -72,10 +72,6 @@ Obviously, if you're installing this onto a system that does not use OpenRC by default then you may wish to backup the above listed files, remove them and then install so that the OS hooks into OpenRC. -`init.d.misc` is not installed by default as the scripts will need -tweaking on a per distro basis. They are also non essential to the -operation of the system. - ## Reporting Bugs If you are using Gentoo Linux, bugs can be filed on their bugzilla under diff --git a/init.d.misc/.gitignore b/init.d.misc/.gitignore deleted file mode 100644 index 9f1ce287..00000000 --- a/init.d.misc/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -avahi-dnsconfd -avahid -dhcpcd -dbus -hald -named -ntpd -openvpn -polkitd -sshd -wpa_supplicant diff --git a/init.d.misc/Makefile b/init.d.misc/Makefile deleted file mode 100644 index ce973c1b..00000000 --- a/init.d.misc/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -DIR= ${INITDIR} -SRCS= avahi-dnsconfd.in avahid.in dhcpcd.in dbus.in \ - hald.in named.in ntpd.in \ - openvpn.in polkitd.in sshd.in wpa_supplicant.in - -MK= ../mk - -SED_EXTRA+= -e 's:@VARBASE@:/var:g' - -include ${MK}/os.mk -include ${MK}/scripts.mk diff --git a/init.d.misc/avahi-dnsconfd.in b/init.d.misc/avahi-dnsconfd.in deleted file mode 100644 index b87b6d58..00000000 --- a/init.d.misc/avahi-dnsconfd.in +++ /dev/null @@ -1,22 +0,0 @@ -#!@SBINDIR@/openrc-run -# Copyright (c) 2007-2015 The OpenRC Authors. -# See the Authors file at the top-level directory of this distribution and -# https://github.com/OpenRC/openrc/blob/master/AUTHORS -# -# This file is part of OpenRC. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -command=@PKG_PREFIX@/sbin/avahi-dnsconfd -command_args="$avahi_dnsconfd_args -D" -pidfile=@VARBASE@/run/avahi-dnsconfd.pid -name="Avahi DNS Configuration Daemon" - -depend() -{ - use dns - need localmount dbus - after bootmisc -} diff --git a/init.d.misc/avahid.in b/init.d.misc/avahid.in deleted file mode 100644 index b809d7b0..00000000 --- a/init.d.misc/avahid.in +++ /dev/null @@ -1,22 +0,0 @@ -#!@SBINDIR@/openrc-run -# Copyright (c) 2007-2015 The OpenRC Authors. -# See the Authors file at the top-level directory of this distribution and -# https://github.com/OpenRC/openrc/blob/master/AUTHORS -# -# This file is part of OpenRC. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -command=@PKG_PREFIX@/sbin/avahi-daemon -command_args="$avahid_args -D" -pidfile=@VARBASE@/run/avahi-daemon/pid -name="Avahi Service Advertisement Daemon" - -depend() -{ - use dns - need localmount dbus - after bootmisc -} diff --git a/init.d.misc/dbus.in b/init.d.misc/dbus.in deleted file mode 100644 index 0275767d..00000000 --- a/init.d.misc/dbus.in +++ /dev/null @@ -1,26 +0,0 @@ -#!@SBINDIR@/openrc-run -# Copyright (c) 2007-2015 The OpenRC Authors. -# See the Authors file at the top-level directory of this distribution and -# https://github.com/OpenRC/openrc/blob/master/AUTHORS -# -# This file is part of OpenRC. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -command=@PKG_PREFIX@/bin/dbus-daemon -pidfile=@VARBASE@/run/dbus/pid -command_args="${dbusd_args---system}" -name="Message Bus Daemon" - -depend() -{ - need localmount net - after bootmisc -} - -start_pre() -{ - mkdir -p $(dirname $pidfile) -} diff --git a/init.d.misc/dhcpcd.in b/init.d.misc/dhcpcd.in deleted file mode 100644 index 1eee3d13..00000000 --- a/init.d.misc/dhcpcd.in +++ /dev/null @@ -1,34 +0,0 @@ -#!@SBINDIR@/openrc-run -# Copyright (c) 2007-2015 The OpenRC Authors. -# See the Authors file at the top-level directory of this distribution and -# https://github.com/OpenRC/openrc/blob/master/AUTHORS -# -# This file is part of OpenRC. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -command=/sbin/dhcpcd -pidfile=/var/run/dhcpcd.pid -command_args=-q -name="DHCP Client Daemon" - -depend() -{ - provide net - need localmount - use logger - after bootmisc modules - before dns -} - -stop_pre() -{ - # When shutting down, kill dhcpcd but preserve network - # We do this as /var/run/dhcpcd could be cleaned out when we - # return to multiuser. - if yesno $RC_GOINGDOWN; then - : ${stopsig:=SIGKILL} - fi -} diff --git a/init.d.misc/dnsmasq.in b/init.d.misc/dnsmasq.in deleted file mode 100644 index f711b2e3..00000000 --- a/init.d.misc/dnsmasq.in +++ /dev/null @@ -1,31 +0,0 @@ -#!@SBINDIR@/openrc-run -# Copyright (c) 2007-2015 The OpenRC Authors. -# See the Authors file at the top-level directory of this distribution and -# https://github.com/OpenRC/openrc/blob/master/AUTHORS -# -# This file is part of OpenRC. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -command=@PKG_PREFIX@/sbin/dnsmasq -command_args=$dnsmasq_args -pidfile=@VARBASE@/run/dnsmasq.pid -required_files=/etc/dnsmasq.conf - -extra_started_commands="reload" - -depend() -{ - provide dns - need localmount net - after bootmisc -} - -reload() -{ - ebegin "Reloading $RC_SVCNAME" - start-stop-daemon --signal SIGHUP --pidfile "$pidfile" - eend $? -} diff --git a/init.d.misc/hald.in b/init.d.misc/hald.in deleted file mode 100644 index bde173c2..00000000 --- a/init.d.misc/hald.in +++ /dev/null @@ -1,20 +0,0 @@ -#!@SBINDIR@/openrc-run -# Copyright (c) 2007-2015 The OpenRC Authors. -# See the Authors file at the top-level directory of this distribution and -# https://github.com/OpenRC/openrc/blob/master/AUTHORS -# -# This file is part of OpenRC. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -command=@PKG_PREFIX@/sbin/hald -pidfile=@VARBASE@/run/hald/hald.pid -command_args=$hald_args -name="Hardware Abstraction Layer Daemon" - -depend() -{ - need dbus -} diff --git a/init.d.misc/named.in b/init.d.misc/named.in deleted file mode 100644 index 1348787f..00000000 --- a/init.d.misc/named.in +++ /dev/null @@ -1,119 +0,0 @@ -#!@SBINDIR@/openrc-run -# Copyright (c) 2007-2015 The OpenRC Authors. -# See the Authors file at the top-level directory of this distribution and -# https://github.com/OpenRC/openrc/blob/master/AUTHORS -# -# This file is part of OpenRC. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -command=/usr/sbin/named -command_args=$named_args -pidfile=@VARBASE@/run/named.pid -name="Domain Name server" -extra_started_commands="reload" - -namedb=/etc/namedb -uid=named -case "$RC_UNAME" in - FreeBSD) - uid=bind - pidfile=@VARBASE@/run/named/pid - ;; - Linux) - uid=bind - ;; -esac -: ${named_uid:=${uid}} - -depend() -{ - provide dns - need localmount - after bootmisc -} - -start_pre() -{ - if [ -n "$named_chroot" ]; then - # Create (or update) the chroot directory structure - if [ -r /etc/mtree/BIND.chroot.dist ]; then - mtree -deU -f /etc/mtree/BIND.chroot.dist -p "$named_chroot" - else - ewarn "/etc/mtree/BIND.chroot.dist missing," - ewarn "chroot directory structure not updated" - fi - - if [ ! -d "$named_chroot"/. ]; then - eerror "chroot directory $named_chroot missing" - exit 1 - fi - - # Create /etc/namedb symlink - if [ ! -L "$namedb" ]; then - if [ -d "$namedb" ]; then - ewarn "named chroot: $namedb is a directory!" - elif [ -e "$namedb" ]; then - ewarn "named chroot: $namedb exists!" - else - ln -s "$named_chroot$namedb" "$namedb" - fi - else - # Make sure it points to the right place. - ln -shf "$named_chroot$namedb" "$namedb" - fi - - case "$RC_UNAME" in - *BSD|DragonFly) - # Mount a devfs in the chroot directory if needed - umount "$named_chroot"/dev 2>/dev/null - mount -t devfs dev "$named_chroot"/dev - devfs -m "$named_chroot"/dev \ - ruleset devfsrules_hide_all - devfs -m "$named_chroot"/dev \ - rule apply path null unhide - devfs -m "$named_chroot"/dev \ - rule apply path random unhide - ;; - esac - - # Copy local timezone information if it is not up to date. - if [ -r /etc/localtime ]; then - cmp -s /etc/localtime "$named_chroot/etc/localtime" || - cp -p /etc/localtime "$named_chroot/etc/localtime" - fi - - command_args="$command_args -t $named_chroot" - - ln -fs "$named_chroot$pidfile" "$pidfile" - fi - - if [ ! -s "$named_chroot$namedb/rndc.conf" ]; then - local confgen="${command%/named}/rndc-confgen -a -b256 -u $named_uid \ - -c $named_chrootdir/etc/namedb/rndc.key" - if [ -s "$named_chroot$namedb/rndc.key" ]; then - local getuser="stat -f%Su" - [ "$RC_UNAME" = Linux ] && getuser="stat -c%U" - case $(${getuser} "$named_chroot$namedb"/rndc.key) in - root|"$named_uid");; - *) $confgen;; - esac - else - $confgen - fi - fi -} - -reload() -{ - rndc reload -} - -stop_post() -{ - if [ -n "$named_chroot" -a -c "$named_chroot"/dev/null ]; then - umount "$named_chroot"/dev 2>/dev/null || true - fi -} diff --git a/init.d.misc/ntpd.in b/init.d.misc/ntpd.in deleted file mode 100644 index 786c022d..00000000 --- a/init.d.misc/ntpd.in +++ /dev/null @@ -1,44 +0,0 @@ -#!@SBINDIR@/openrc-run -# Copyright (c) 2007-2015 The OpenRC Authors. -# See the Authors file at the top-level directory of this distribution and -# https://github.com/OpenRC/openrc/blob/master/AUTHORS -# -# This file is part of OpenRC. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -: ${ntpd_config:=/etc/ntp.conf} -: ${ntpd_drift:=/var/db/ntpd.drift} - -command=/usr/sbin/ntpd -required_files=$ntpd_config -pidfile=/var/run/ntpd.pid -command_args="$ntpd_args -c $ntpd_config -f $ntpd_drift -p $pidfile" -name="Network Time Protocol Daemon" - -depend() -{ - use dns - need localmount - after bootmisc ntp-client -} - -start_pre() -{ - if [ -n "$ntpd_chroot" ]; then - case "$RC_UNAME" in - *BSD|DragonFly) - if [ ! -c "$ntpd_chroot/dev/clockctl" ]; then - rm -f "$ntpd_chroot/dev/clockctl" - (cd /dev; /bin/pax -rw -pe clockctl \ - "$ntpd_chroot/dev") - fi - ;; - esac - ln -fs "$ntpd_chroot$ntpd_drift" "$ntpd_drift" - - command_args="$command_args -u ntpd:ntpd -i $ntpd_chroot" - fi -} diff --git a/init.d.misc/openvpn.in b/init.d.misc/openvpn.in deleted file mode 100644 index 95e94821..00000000 --- a/init.d.misc/openvpn.in +++ /dev/null @@ -1,74 +0,0 @@ -#!@SBINDIR@/openrc-run -# Copyright (c) 2007-2015 The OpenRC Authors. -# See the Authors file at the top-level directory of this distribution and -# https://github.com/OpenRC/openrc/blob/master/AUTHORS -# -# This file is part of OpenRC. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -vpn=${RC_SVCNAME#*.} -name="OpenVPN" -[ "$vpn" != openvpn ] && name="$name ($vpn)" -command=@PKG_PREFIX@/sbin/openvpn - -pidfile=@VARBASE@/run/"$RC_SVCNAME".pid -: ${openvpn_dir:=@PKG_PREFIX@/etc/openvpn} -: ${openvpn_config:=$openvpn_dir/$vpn.conf} -command_args="$openvpn_args --daemon --config $openvpn_config" -command_args="$command_args --writepid $pidfile" -required_dirs=$openvpn_dir -required_files=$openvpn_config - -# If we're an openvpn client, then supply a nice default config -# You can find sample up/down scripts in the OpenRC support/openvpn dir -if yesno $openvpn_client; then - : ${openvpn_up:=${openvpn_dir}/up.sh} - : ${openvpn_down:=${openvpn_dir}/down.sh} - command_args="$command_args --nobind --up-delay --up-restart --down-pre" - command_args="$command_args --up $openvpn_up" - command_args="$command_args --down $openvpn_down" - required_files="$required_files $openvpn_up $openvpn_down" - - in_background_fake="start stop" - start_inactive=YES -fi - -depend() -{ - need localmount net - use dns - after bootmisc -} - -start_pre() -{ - # Linux has good dynamic tun/tap creation - if [ "$RC_UNAME" = Linux ]; then - if [ ! -e /dev/net/tun ]; then - if ! modprobe tun; then - eerror "TUN/TAP support is not available in this kernel" - return 1 - fi - fi - if [ -h /dev/net/tun -a -c /dev/misc/net/tun ]; then - ebegin "Detected broken /dev/net/tun symlink, fixing..." - rm -f /dev/net/tun - ln -s /dev/misc/net/tun /dev/net/tun - eend $? - fi - else - if command -v kldload >/dev/null 2>&1; then - # Hammer the modules home by default - sysctl -a | grep -q '\.tun\.' || kldload if_tun - sysctl -a | grep -q '\.tap\.' || kldload if_tap - fi - fi - - # If the config file does not specify the cd option, we do - if ! grep -q "^[ \t]*cd[ \t].*" "$openvpn_config"; then - command_args="$command_args --cd $openvpn_dir" - fi -} diff --git a/init.d.misc/polkitd.in b/init.d.misc/polkitd.in deleted file mode 100644 index a36e3395..00000000 --- a/init.d.misc/polkitd.in +++ /dev/null @@ -1,20 +0,0 @@ -#!@SBINDIR@/openrc-run -# Copyright (c) 2007-2015 The OpenRC Authors. -# See the Authors file at the top-level directory of this distribution and -# https://github.com/OpenRC/openrc/blob/master/AUTHORS -# -# This file is part of OpenRC. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -command=@PKG_PREFIX@/sbin/polkitd -pidfile=@VARBASE@/run/polkitd/polkitd.pid -command_args="$polkitd_args" -name="PolicyKit Daemon" - -depend() -{ - need dbus -} diff --git a/init.d.misc/sshd.in b/init.d.misc/sshd.in deleted file mode 100644 index d89224d3..00000000 --- a/init.d.misc/sshd.in +++ /dev/null @@ -1,42 +0,0 @@ -#!@SBINDIR@/openrc-run -# Copyright (c) 2007-2015 The OpenRC Authors. -# See the Authors file at the top-level directory of this distribution and -# https://github.com/OpenRC/openrc/blob/master/AUTHORS -# -# This file is part of OpenRC. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -command=/usr/sbin/sshd -command_args=$sshd_args -pidfile=@VARBASE@/run/sshd.pid -required_files=/etc/ssh/sshd_config - -depend() -{ - use logger dns - need net -} - -start_pre() -{ - if [ ! -e /etc/ssh/ssh_host_key ]; then - ebegin "Generating Hostkey" - ssh-keygen -t rsa1 -b 1024 -f /etc/ssh/ssh_host_key -N '' - eend $? || return 1 - fi - if [ ! -e /etc/ssh/ssh_host_dsa_key ]; then - ebegin "Generating DSA Hostkey" - ssh-keygen -d -f /etc/ssh/ssh_host_dsa_key -N '' - eend $? || return 1 - fi - if [ ! -e /etc/ssh/ssh_host_rsa_key ]; then - ebegin "Generating RSA Hostkey" - ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' - eend $? || return 1 - fi - - $command -t -} diff --git a/init.d.misc/wpa_supplicant.in b/init.d.misc/wpa_supplicant.in deleted file mode 100644 index 7b7ddc57..00000000 --- a/init.d.misc/wpa_supplicant.in +++ /dev/null @@ -1,82 +0,0 @@ -#!@SBINDIR@/openrc-run -# Copyright (c) 2007-2015 The OpenRC Authors. -# See the Authors file at the top-level directory of this distribution and -# https://github.com/OpenRC/openrc/blob/master/AUTHORS -# -# This file is part of OpenRC. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -command=/usr/sbin/wpa_supplicant -: ${wpa_supplicant_conf:=/etc/wpa_supplicant.conf} -wpa_supplicant_if=${wpa_supplicant_if:+-i}$wpa_supplicant_if -command_args="$wpa_supplicant_args -B -c$wpa_supplicant_conf $wpa_supplicant_if" -name="WPA Supplicant Daemon" - -depend() -{ - need localmount - use logger - after bootmisc modules - before dns dhcpcd net - keyword -shutdown -} - -find_wireless() -{ - local iface= - - case "$RC_UNAME" in - Linux) - for iface in /sys/class/net/*; do - if [ -e "$iface"/wireless -o \ - -e "$iface"/phy80211 ] - then - echo "${iface##*/}" - return 0 - fi - done - ;; - FreeBSD) - for iface in $(sysctl -b net.wlan.devices 2>/dev/null); do - echo "${iface##*/}" - done - ;; - *) - for iface in /dev/net/* $(ifconfig -l 2>/dev/null); do - if ifconfig "${iface##*/}" 2>/dev/null | \ - grep -q "[ ]*ssid " - then - echo "${iface##*/}" - return 0 - fi - done - ;; - esac - - return 1 -} - -append_wireless() -{ - local iface= i= - - iface=$(find_wireless) - if [ -n "$iface" ]; then - for i in $iface; do - command_args="$command_args -i$i" - done - else - eerror "Could not find a wireless interface" - fi -} - -start_pre() -{ - case " $command_args" in - *" -i"*) ;; - *) append_wireless;; - esac -} diff --git a/support/Makefile b/support/Makefile index a183e9f7..c8d6ffd2 100644 --- a/support/Makefile +++ b/support/Makefile @@ -11,7 +11,7 @@ MK= ../mk include ${MK}/os.mk -SUBDIR= deptree2dot openvpn +SUBDIR= deptree2dot init.d.examples openvpn ifeq (${OS},Linux) SUBDIR+= sysvinit diff --git a/support/init.d.examples/.gitignore b/support/init.d.examples/.gitignore new file mode 100644 index 00000000..9f1ce287 --- /dev/null +++ b/support/init.d.examples/.gitignore @@ -0,0 +1,11 @@ +avahi-dnsconfd +avahid +dhcpcd +dbus +hald +named +ntpd +openvpn +polkitd +sshd +wpa_supplicant diff --git a/support/init.d.examples/Makefile b/support/init.d.examples/Makefile new file mode 100644 index 00000000..b65c1fd4 --- /dev/null +++ b/support/init.d.examples/Makefile @@ -0,0 +1,13 @@ +DIR= ${DATADIR}/support/init.d.examples +INC= README.md +SRCS= avahi-dnsconfd.in avahid.in dhcpcd.in dbus.in \ + hald.in named.in ntpd.in \ + openvpn.in polkitd.in sshd.in wpa_supplicant.in +BIN= ${OBJS} + +MK= ../../mk + +SED_EXTRA+= -e 's:@VARBASE@:/var:g' + +include ${MK}/os.mk +include ${MK}/scripts.mk diff --git a/support/init.d.examples/README.md b/support/init.d.examples/README.md new file mode 100644 index 00000000..2c32fd6f --- /dev/null +++ b/support/init.d.examples/README.md @@ -0,0 +1,3 @@ +The service scripts in this directory are meant as examples only. +They are not installed by default as the scripts will need tweaking on a +per distro basis. They are also non essential to the operation of the system. diff --git a/support/init.d.examples/avahi-dnsconfd.in b/support/init.d.examples/avahi-dnsconfd.in new file mode 100644 index 00000000..b87b6d58 --- /dev/null +++ b/support/init.d.examples/avahi-dnsconfd.in @@ -0,0 +1,22 @@ +#!@SBINDIR@/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +command=@PKG_PREFIX@/sbin/avahi-dnsconfd +command_args="$avahi_dnsconfd_args -D" +pidfile=@VARBASE@/run/avahi-dnsconfd.pid +name="Avahi DNS Configuration Daemon" + +depend() +{ + use dns + need localmount dbus + after bootmisc +} diff --git a/support/init.d.examples/avahid.in b/support/init.d.examples/avahid.in new file mode 100644 index 00000000..b809d7b0 --- /dev/null +++ b/support/init.d.examples/avahid.in @@ -0,0 +1,22 @@ +#!@SBINDIR@/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +command=@PKG_PREFIX@/sbin/avahi-daemon +command_args="$avahid_args -D" +pidfile=@VARBASE@/run/avahi-daemon/pid +name="Avahi Service Advertisement Daemon" + +depend() +{ + use dns + need localmount dbus + after bootmisc +} diff --git a/support/init.d.examples/dbus.in b/support/init.d.examples/dbus.in new file mode 100644 index 00000000..0275767d --- /dev/null +++ b/support/init.d.examples/dbus.in @@ -0,0 +1,26 @@ +#!@SBINDIR@/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +command=@PKG_PREFIX@/bin/dbus-daemon +pidfile=@VARBASE@/run/dbus/pid +command_args="${dbusd_args---system}" +name="Message Bus Daemon" + +depend() +{ + need localmount net + after bootmisc +} + +start_pre() +{ + mkdir -p $(dirname $pidfile) +} diff --git a/support/init.d.examples/dhcpcd.in b/support/init.d.examples/dhcpcd.in new file mode 100644 index 00000000..1eee3d13 --- /dev/null +++ b/support/init.d.examples/dhcpcd.in @@ -0,0 +1,34 @@ +#!@SBINDIR@/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +command=/sbin/dhcpcd +pidfile=/var/run/dhcpcd.pid +command_args=-q +name="DHCP Client Daemon" + +depend() +{ + provide net + need localmount + use logger + after bootmisc modules + before dns +} + +stop_pre() +{ + # When shutting down, kill dhcpcd but preserve network + # We do this as /var/run/dhcpcd could be cleaned out when we + # return to multiuser. + if yesno $RC_GOINGDOWN; then + : ${stopsig:=SIGKILL} + fi +} diff --git a/support/init.d.examples/dnsmasq.in b/support/init.d.examples/dnsmasq.in new file mode 100644 index 00000000..f711b2e3 --- /dev/null +++ b/support/init.d.examples/dnsmasq.in @@ -0,0 +1,31 @@ +#!@SBINDIR@/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +command=@PKG_PREFIX@/sbin/dnsmasq +command_args=$dnsmasq_args +pidfile=@VARBASE@/run/dnsmasq.pid +required_files=/etc/dnsmasq.conf + +extra_started_commands="reload" + +depend() +{ + provide dns + need localmount net + after bootmisc +} + +reload() +{ + ebegin "Reloading $RC_SVCNAME" + start-stop-daemon --signal SIGHUP --pidfile "$pidfile" + eend $? +} diff --git a/support/init.d.examples/hald.in b/support/init.d.examples/hald.in new file mode 100644 index 00000000..bde173c2 --- /dev/null +++ b/support/init.d.examples/hald.in @@ -0,0 +1,20 @@ +#!@SBINDIR@/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +command=@PKG_PREFIX@/sbin/hald +pidfile=@VARBASE@/run/hald/hald.pid +command_args=$hald_args +name="Hardware Abstraction Layer Daemon" + +depend() +{ + need dbus +} diff --git a/support/init.d.examples/named.in b/support/init.d.examples/named.in new file mode 100644 index 00000000..1348787f --- /dev/null +++ b/support/init.d.examples/named.in @@ -0,0 +1,119 @@ +#!@SBINDIR@/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +command=/usr/sbin/named +command_args=$named_args +pidfile=@VARBASE@/run/named.pid +name="Domain Name server" +extra_started_commands="reload" + +namedb=/etc/namedb +uid=named +case "$RC_UNAME" in + FreeBSD) + uid=bind + pidfile=@VARBASE@/run/named/pid + ;; + Linux) + uid=bind + ;; +esac +: ${named_uid:=${uid}} + +depend() +{ + provide dns + need localmount + after bootmisc +} + +start_pre() +{ + if [ -n "$named_chroot" ]; then + # Create (or update) the chroot directory structure + if [ -r /etc/mtree/BIND.chroot.dist ]; then + mtree -deU -f /etc/mtree/BIND.chroot.dist -p "$named_chroot" + else + ewarn "/etc/mtree/BIND.chroot.dist missing," + ewarn "chroot directory structure not updated" + fi + + if [ ! -d "$named_chroot"/. ]; then + eerror "chroot directory $named_chroot missing" + exit 1 + fi + + # Create /etc/namedb symlink + if [ ! -L "$namedb" ]; then + if [ -d "$namedb" ]; then + ewarn "named chroot: $namedb is a directory!" + elif [ -e "$namedb" ]; then + ewarn "named chroot: $namedb exists!" + else + ln -s "$named_chroot$namedb" "$namedb" + fi + else + # Make sure it points to the right place. + ln -shf "$named_chroot$namedb" "$namedb" + fi + + case "$RC_UNAME" in + *BSD|DragonFly) + # Mount a devfs in the chroot directory if needed + umount "$named_chroot"/dev 2>/dev/null + mount -t devfs dev "$named_chroot"/dev + devfs -m "$named_chroot"/dev \ + ruleset devfsrules_hide_all + devfs -m "$named_chroot"/dev \ + rule apply path null unhide + devfs -m "$named_chroot"/dev \ + rule apply path random unhide + ;; + esac + + # Copy local timezone information if it is not up to date. + if [ -r /etc/localtime ]; then + cmp -s /etc/localtime "$named_chroot/etc/localtime" || + cp -p /etc/localtime "$named_chroot/etc/localtime" + fi + + command_args="$command_args -t $named_chroot" + + ln -fs "$named_chroot$pidfile" "$pidfile" + fi + + if [ ! -s "$named_chroot$namedb/rndc.conf" ]; then + local confgen="${command%/named}/rndc-confgen -a -b256 -u $named_uid \ + -c $named_chrootdir/etc/namedb/rndc.key" + if [ -s "$named_chroot$namedb/rndc.key" ]; then + local getuser="stat -f%Su" + [ "$RC_UNAME" = Linux ] && getuser="stat -c%U" + case $(${getuser} "$named_chroot$namedb"/rndc.key) in + root|"$named_uid");; + *) $confgen;; + esac + else + $confgen + fi + fi +} + +reload() +{ + rndc reload +} + +stop_post() +{ + if [ -n "$named_chroot" -a -c "$named_chroot"/dev/null ]; then + umount "$named_chroot"/dev 2>/dev/null || true + fi +} diff --git a/support/init.d.examples/ntpd.in b/support/init.d.examples/ntpd.in new file mode 100644 index 00000000..786c022d --- /dev/null +++ b/support/init.d.examples/ntpd.in @@ -0,0 +1,44 @@ +#!@SBINDIR@/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +: ${ntpd_config:=/etc/ntp.conf} +: ${ntpd_drift:=/var/db/ntpd.drift} + +command=/usr/sbin/ntpd +required_files=$ntpd_config +pidfile=/var/run/ntpd.pid +command_args="$ntpd_args -c $ntpd_config -f $ntpd_drift -p $pidfile" +name="Network Time Protocol Daemon" + +depend() +{ + use dns + need localmount + after bootmisc ntp-client +} + +start_pre() +{ + if [ -n "$ntpd_chroot" ]; then + case "$RC_UNAME" in + *BSD|DragonFly) + if [ ! -c "$ntpd_chroot/dev/clockctl" ]; then + rm -f "$ntpd_chroot/dev/clockctl" + (cd /dev; /bin/pax -rw -pe clockctl \ + "$ntpd_chroot/dev") + fi + ;; + esac + ln -fs "$ntpd_chroot$ntpd_drift" "$ntpd_drift" + + command_args="$command_args -u ntpd:ntpd -i $ntpd_chroot" + fi +} diff --git a/support/init.d.examples/openvpn.in b/support/init.d.examples/openvpn.in new file mode 100644 index 00000000..95e94821 --- /dev/null +++ b/support/init.d.examples/openvpn.in @@ -0,0 +1,74 @@ +#!@SBINDIR@/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +vpn=${RC_SVCNAME#*.} +name="OpenVPN" +[ "$vpn" != openvpn ] && name="$name ($vpn)" +command=@PKG_PREFIX@/sbin/openvpn + +pidfile=@VARBASE@/run/"$RC_SVCNAME".pid +: ${openvpn_dir:=@PKG_PREFIX@/etc/openvpn} +: ${openvpn_config:=$openvpn_dir/$vpn.conf} +command_args="$openvpn_args --daemon --config $openvpn_config" +command_args="$command_args --writepid $pidfile" +required_dirs=$openvpn_dir +required_files=$openvpn_config + +# If we're an openvpn client, then supply a nice default config +# You can find sample up/down scripts in the OpenRC support/openvpn dir +if yesno $openvpn_client; then + : ${openvpn_up:=${openvpn_dir}/up.sh} + : ${openvpn_down:=${openvpn_dir}/down.sh} + command_args="$command_args --nobind --up-delay --up-restart --down-pre" + command_args="$command_args --up $openvpn_up" + command_args="$command_args --down $openvpn_down" + required_files="$required_files $openvpn_up $openvpn_down" + + in_background_fake="start stop" + start_inactive=YES +fi + +depend() +{ + need localmount net + use dns + after bootmisc +} + +start_pre() +{ + # Linux has good dynamic tun/tap creation + if [ "$RC_UNAME" = Linux ]; then + if [ ! -e /dev/net/tun ]; then + if ! modprobe tun; then + eerror "TUN/TAP support is not available in this kernel" + return 1 + fi + fi + if [ -h /dev/net/tun -a -c /dev/misc/net/tun ]; then + ebegin "Detected broken /dev/net/tun symlink, fixing..." + rm -f /dev/net/tun + ln -s /dev/misc/net/tun /dev/net/tun + eend $? + fi + else + if command -v kldload >/dev/null 2>&1; then + # Hammer the modules home by default + sysctl -a | grep -q '\.tun\.' || kldload if_tun + sysctl -a | grep -q '\.tap\.' || kldload if_tap + fi + fi + + # If the config file does not specify the cd option, we do + if ! grep -q "^[ \t]*cd[ \t].*" "$openvpn_config"; then + command_args="$command_args --cd $openvpn_dir" + fi +} diff --git a/support/init.d.examples/polkitd.in b/support/init.d.examples/polkitd.in new file mode 100644 index 00000000..a36e3395 --- /dev/null +++ b/support/init.d.examples/polkitd.in @@ -0,0 +1,20 @@ +#!@SBINDIR@/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +command=@PKG_PREFIX@/sbin/polkitd +pidfile=@VARBASE@/run/polkitd/polkitd.pid +command_args="$polkitd_args" +name="PolicyKit Daemon" + +depend() +{ + need dbus +} diff --git a/support/init.d.examples/sshd.in b/support/init.d.examples/sshd.in new file mode 100644 index 00000000..d89224d3 --- /dev/null +++ b/support/init.d.examples/sshd.in @@ -0,0 +1,42 @@ +#!@SBINDIR@/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +command=/usr/sbin/sshd +command_args=$sshd_args +pidfile=@VARBASE@/run/sshd.pid +required_files=/etc/ssh/sshd_config + +depend() +{ + use logger dns + need net +} + +start_pre() +{ + if [ ! -e /etc/ssh/ssh_host_key ]; then + ebegin "Generating Hostkey" + ssh-keygen -t rsa1 -b 1024 -f /etc/ssh/ssh_host_key -N '' + eend $? || return 1 + fi + if [ ! -e /etc/ssh/ssh_host_dsa_key ]; then + ebegin "Generating DSA Hostkey" + ssh-keygen -d -f /etc/ssh/ssh_host_dsa_key -N '' + eend $? || return 1 + fi + if [ ! -e /etc/ssh/ssh_host_rsa_key ]; then + ebegin "Generating RSA Hostkey" + ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' + eend $? || return 1 + fi + + $command -t +} diff --git a/support/init.d.examples/wpa_supplicant.in b/support/init.d.examples/wpa_supplicant.in new file mode 100644 index 00000000..7b7ddc57 --- /dev/null +++ b/support/init.d.examples/wpa_supplicant.in @@ -0,0 +1,82 @@ +#!@SBINDIR@/openrc-run +# Copyright (c) 2007-2015 The OpenRC Authors. +# See the Authors file at the top-level directory of this distribution and +# https://github.com/OpenRC/openrc/blob/master/AUTHORS +# +# This file is part of OpenRC. It is subject to the license terms in +# the LICENSE file found in the top-level directory of this +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE +# This file may not be copied, modified, propagated, or distributed +# except according to the terms contained in the LICENSE file. + +command=/usr/sbin/wpa_supplicant +: ${wpa_supplicant_conf:=/etc/wpa_supplicant.conf} +wpa_supplicant_if=${wpa_supplicant_if:+-i}$wpa_supplicant_if +command_args="$wpa_supplicant_args -B -c$wpa_supplicant_conf $wpa_supplicant_if" +name="WPA Supplicant Daemon" + +depend() +{ + need localmount + use logger + after bootmisc modules + before dns dhcpcd net + keyword -shutdown +} + +find_wireless() +{ + local iface= + + case "$RC_UNAME" in + Linux) + for iface in /sys/class/net/*; do + if [ -e "$iface"/wireless -o \ + -e "$iface"/phy80211 ] + then + echo "${iface##*/}" + return 0 + fi + done + ;; + FreeBSD) + for iface in $(sysctl -b net.wlan.devices 2>/dev/null); do + echo "${iface##*/}" + done + ;; + *) + for iface in /dev/net/* $(ifconfig -l 2>/dev/null); do + if ifconfig "${iface##*/}" 2>/dev/null | \ + grep -q "[ ]*ssid " + then + echo "${iface##*/}" + return 0 + fi + done + ;; + esac + + return 1 +} + +append_wireless() +{ + local iface= i= + + iface=$(find_wireless) + if [ -n "$iface" ]; then + for i in $iface; do + command_args="$command_args -i$i" + done + else + eerror "Could not find a wireless interface" + fi +} + +start_pre() +{ + case " $command_args" in + *" -i"*) ;; + *) append_wireless;; + esac +} -- cgit v1.2.3