diff options
Diffstat (limited to 'support/init.d.examples')
| -rw-r--r-- | support/init.d.examples/.gitignore | 11 | ||||
| -rw-r--r-- | support/init.d.examples/Makefile | 13 | ||||
| -rw-r--r-- | support/init.d.examples/README.md | 3 | ||||
| -rw-r--r-- | support/init.d.examples/avahi-dnsconfd.in | 22 | ||||
| -rw-r--r-- | support/init.d.examples/avahid.in | 22 | ||||
| -rw-r--r-- | support/init.d.examples/dbus.in | 26 | ||||
| -rw-r--r-- | support/init.d.examples/dhcpcd.in | 34 | ||||
| -rw-r--r-- | support/init.d.examples/dnsmasq.in | 31 | ||||
| -rw-r--r-- | support/init.d.examples/hald.in | 20 | ||||
| -rw-r--r-- | support/init.d.examples/named.in | 119 | ||||
| -rw-r--r-- | support/init.d.examples/ntpd.in | 44 | ||||
| -rw-r--r-- | support/init.d.examples/openvpn.in | 74 | ||||
| -rw-r--r-- | support/init.d.examples/polkitd.in | 20 | ||||
| -rw-r--r-- | support/init.d.examples/sshd.in | 42 | ||||
| -rw-r--r-- | support/init.d.examples/wpa_supplicant.in | 82 | 
15 files changed, 563 insertions, 0 deletions
| 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 +} | 
