initial commit
This commit is contained in:
20
support/Makefile
Normal file
20
support/Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
# Copyright (c) 2017 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.
|
||||
|
||||
MK= ../mk
|
||||
include ${MK}/os.mk
|
||||
|
||||
SUBDIR= deptree2dot init.d.examples openvpn
|
||||
|
||||
ifeq (${OS},Linux)
|
||||
SUBDIR+= sysvinit
|
||||
endif
|
||||
|
||||
include ${MK}/subdir.mk
|
||||
9
support/deptree2dot/Makefile
Normal file
9
support/deptree2dot/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
MK= ../../mk
|
||||
include ${MK}/os.mk
|
||||
|
||||
DIR= ${DATADIR}/support/deptree2dot
|
||||
BIN= deptree2dot
|
||||
INC= README.md
|
||||
|
||||
|
||||
include ${MK}/scripts.mk
|
||||
11
support/deptree2dot/README.md
Normal file
11
support/deptree2dot/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# deptree2dot - Graph the OpenRC Dependency Tree
|
||||
|
||||
This utility can be used to graph the OpenRC dependency tree. It
|
||||
requires perl5.x and converts the tree to a .dot file which can be
|
||||
processed by graphviz.
|
||||
|
||||
Example usage:
|
||||
|
||||
$ chmod +x deptree2dot
|
||||
$deptree2dot > deptree.dot
|
||||
$deptree2dot | dot -Tpng -o deptree.png
|
||||
44
support/deptree2dot/deptree2dot
Normal file
44
support/deptree2dot/deptree2dot
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/perl -w
|
||||
# -*- cperl -*-
|
||||
# Copyright © 2012 Diego Elio Pettenò <flameeyes@flameeyes.eu>
|
||||
# Released under the 2-clause BSD license.
|
||||
#
|
||||
#Example usage:
|
||||
#deptree2dot > deptree.dot
|
||||
#deptree2dot | dot -Tpng -o deptree.png
|
||||
|
||||
my $deptree = defined($ARGV[0]) ? $ARGV[0] : "/run/openrc/deptree";
|
||||
|
||||
open DEPTREE, $deptree or exit 1;
|
||||
|
||||
print "digraph deptree {\n";
|
||||
|
||||
my @deptree;
|
||||
|
||||
while(my $line = readline(DEPTREE)) {
|
||||
$line =~ /^depinfo_([0-9]+)_([a-z]+)(?:_[0-9]+)?='(.*)'\n$/;
|
||||
my $index = $1;
|
||||
my $prop = $2;
|
||||
my $value = $3; $value =~ s/[-\.:~]/_/g;
|
||||
|
||||
if ( $prop eq "service" ) {
|
||||
$deptree[$index] = $value;
|
||||
printf "%s [shape=box];\n", $value;
|
||||
} else {
|
||||
my $service = $deptree[$index];
|
||||
|
||||
if ( $prop eq "ineed" ) {
|
||||
printf "%s -> %s;\n", $service, $value;
|
||||
} elsif ( $prop eq "iuse" ) {
|
||||
printf "%s -> %s [color=blue];\n", $service, $value;
|
||||
} elsif ( $prop eq "ibefore" ) {
|
||||
printf "%s -> %s [style=dotted];\n", $service, $value;
|
||||
} elsif ( $prop eq "iafter" ) {
|
||||
printf "%s -> %s [style=dotted color=purple];\n", $value, $service;
|
||||
} elsif ( $prop eq "iprovide" ) {
|
||||
printf "%s -> %s [color=red];\n", $value, $service;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "}\n";
|
||||
11
support/init.d.examples/.gitignore
vendored
Normal file
11
support/init.d.examples/.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
avahi-dnsconfd
|
||||
avahid
|
||||
dhcpcd
|
||||
dbus
|
||||
hald
|
||||
named
|
||||
ntpd
|
||||
openvpn
|
||||
polkitd
|
||||
sshd
|
||||
wpa_supplicant
|
||||
13
support/init.d.examples/Makefile
Normal file
13
support/init.d.examples/Makefile
Normal file
@@ -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
|
||||
3
support/init.d.examples/README.md
Normal file
3
support/init.d.examples/README.md
Normal file
@@ -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.
|
||||
22
support/init.d.examples/avahi-dnsconfd.in
Normal file
22
support/init.d.examples/avahi-dnsconfd.in
Normal file
@@ -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
|
||||
}
|
||||
22
support/init.d.examples/avahid.in
Normal file
22
support/init.d.examples/avahid.in
Normal file
@@ -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
|
||||
}
|
||||
26
support/init.d.examples/dbus.in
Normal file
26
support/init.d.examples/dbus.in
Normal file
@@ -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)
|
||||
}
|
||||
34
support/init.d.examples/dhcpcd.in
Normal file
34
support/init.d.examples/dhcpcd.in
Normal file
@@ -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
|
||||
}
|
||||
31
support/init.d.examples/dnsmasq.in
Normal file
31
support/init.d.examples/dnsmasq.in
Normal file
@@ -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 $?
|
||||
}
|
||||
20
support/init.d.examples/hald.in
Normal file
20
support/init.d.examples/hald.in
Normal file
@@ -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
|
||||
}
|
||||
119
support/init.d.examples/named.in
Normal file
119
support/init.d.examples/named.in
Normal file
@@ -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
|
||||
}
|
||||
44
support/init.d.examples/ntpd.in
Normal file
44
support/init.d.examples/ntpd.in
Normal file
@@ -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
|
||||
}
|
||||
74
support/init.d.examples/openvpn.in
Normal file
74
support/init.d.examples/openvpn.in
Normal file
@@ -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
|
||||
}
|
||||
20
support/init.d.examples/polkitd.in
Normal file
20
support/init.d.examples/polkitd.in
Normal file
@@ -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
|
||||
}
|
||||
42
support/init.d.examples/sshd.in
Normal file
42
support/init.d.examples/sshd.in
Normal file
@@ -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
|
||||
}
|
||||
82
support/init.d.examples/wpa_supplicant.in
Normal file
82
support/init.d.examples/wpa_supplicant.in
Normal file
@@ -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
|
||||
}
|
||||
9
support/openvpn/Makefile
Normal file
9
support/openvpn/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
MK= ../../mk
|
||||
include ${MK}/os.mk
|
||||
|
||||
DIR= ${DATADIR}/support/openvpn
|
||||
BIN= down.sh up.sh
|
||||
INC= README.md
|
||||
|
||||
|
||||
include ${MK}/scripts.mk
|
||||
8
support/openvpn/README.md
Normal file
8
support/openvpn/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
These handy scripts setup any dns information that OpenVPN may push.
|
||||
They also handle the interaction with OpenRC so that the OpenVPN service
|
||||
can become "inactive". This means that when it starts, it goes inactive and
|
||||
OpenRC continues on its merry way booting the system. When OpenVPN connects
|
||||
to an endpoint it then re-starts the OpenVPN service and starts up any
|
||||
services that depend on us. A similar thing happens when we shut down.
|
||||
|
||||
Of course, this is all optional.
|
||||
34
support/openvpn/down.sh
Executable file
34
support/openvpn/down.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
# 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.
|
||||
|
||||
# If we have a service specific script, run this now
|
||||
[ -x "${RC_SVCNAME}"-down.sh ] && "${RC_SVCNAME}"-down.sh
|
||||
|
||||
# Restore resolv.conf to how it was
|
||||
if command -v resolvconf >/dev/null 2>&1; then
|
||||
resolvconf -d "${dev}"
|
||||
elif [ -e /etc/resolv.conf-"${dev}".sv ]; then
|
||||
# Important that we copy instead of move incase resolv.conf is
|
||||
# a symlink and not an actual file
|
||||
cp -p /etc/resolv.conf-"${dev}".sv /etc/resolv.conf
|
||||
rm -f /etc/resolv.conf-"${dev}".sv
|
||||
fi
|
||||
|
||||
# Re-enter the init script to stop any dependant services
|
||||
if [ -x "${RC_SERVICE}" ]; then
|
||||
if "${RC_SERVICE}" --quiet status; then
|
||||
IN_BACKGROUND=YES
|
||||
export IN_BACKGROUND
|
||||
"${RC_SERVICE}" --quiet stop
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
80
support/openvpn/up.sh
Executable file
80
support/openvpn/up.sh
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/bin/sh
|
||||
# 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.
|
||||
|
||||
# Setup our resolv.conf
|
||||
# Vitally important that we use the domain entry in resolv.conf so we
|
||||
# can setup the nameservers are for the domain ONLY in resolvconf if
|
||||
# we're using a decent dns cache/forwarder like dnsmasq and NOT nscd/libc.
|
||||
# nscd/libc users will get the VPN nameservers before their other ones
|
||||
# and will use the first one that responds - maybe the LAN ones?
|
||||
# non resolvconf users just the the VPN resolv.conf
|
||||
|
||||
# FIXME:- if we have >1 domain, then we have to use search :/
|
||||
# We need to add a flag to resolvconf to say
|
||||
# "these nameservers should only be used for the listed search domains
|
||||
# if other global nameservers are present on other interfaces"
|
||||
# This however, will break compatibility with Debians resolvconf
|
||||
# A possible workaround would be to just list multiple domain lines
|
||||
# and try and let resolvconf handle it
|
||||
|
||||
NS=
|
||||
DOMAIN=
|
||||
SEARCH=
|
||||
i=1
|
||||
while true; do
|
||||
eval opt=\$foreign_option_${i}
|
||||
[ -z "${opt}" ] && break
|
||||
if [ "${opt}" != "${opt#dhcp-option DOMAIN *}" ]; then
|
||||
if [ -z "${DOMAIN}" ]; then
|
||||
DOMAIN="${opt#dhcp-option DOMAIN *}"
|
||||
else
|
||||
SEARCH="${SEARCH:+ }${opt#dhcp-option DOMAIN *}"
|
||||
fi
|
||||
elif [ "${opt}" != "${opt#dhcp-option DNS *}" ]; then
|
||||
NS="${NS}nameserver ${opt#dhcp-option DNS *}\n"
|
||||
fi
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
|
||||
if [ -n "${NS}" ]; then
|
||||
DNS="# Generated by openvpn for interface ${dev}\n"
|
||||
if [ -n "${SEARCH}" ]; then
|
||||
DNS="${DNS}search ${DOMAIN} ${SEARCH}\n"
|
||||
else
|
||||
DNS="${DNS}domain ${DOMAIN}\n"
|
||||
fi
|
||||
DNS="${DNS}${NS}"
|
||||
if command -v resolvconf >/dev/null 2>&1; then
|
||||
printf "${DNS}" | resolvconf -a "${dev}"
|
||||
else
|
||||
# Preserve the existing resolv.conf
|
||||
if [ -e /etc/resolv.conf ]; then
|
||||
cp -p /etc/resolv.conf /etc/resolv.conf-"${dev}".sv
|
||||
fi
|
||||
(umask 022; printf "${DNS}" > /etc/resolv.conf)
|
||||
fi
|
||||
fi
|
||||
|
||||
# Below section is OpenRC specific
|
||||
|
||||
# If we have a service specific script, run this now
|
||||
[ -x "${RC_SVCNAME}"-up.sh ] && "${RC_SVCNAME}"-up.sh
|
||||
|
||||
# Re-enter the init script to start any dependant services
|
||||
if [ -x "${RC_SERVICE}" ]; then
|
||||
if ! "${RC_SERVICE}" --quiet status; then
|
||||
IN_BACKGROUND=YES
|
||||
export IN_BACKGROUND
|
||||
"${RC_SERVICE}" --quiet start
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
8
support/sysvinit/Makefile
Normal file
8
support/sysvinit/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
MK= ../../mk
|
||||
include ${MK}/os.mk
|
||||
|
||||
DIR= ${DATADIR}/support/sysvinit
|
||||
INC= inittab README.md
|
||||
|
||||
|
||||
include ${MK}/scripts.mk
|
||||
2
support/sysvinit/README.md
Normal file
2
support/sysvinit/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
Here's a sample inittab for use with sysvinit for Linux based systems.
|
||||
We don't install it by default as sysvinit packages normally own this file.
|
||||
41
support/sysvinit/inittab
Normal file
41
support/sysvinit/inittab
Normal file
@@ -0,0 +1,41 @@
|
||||
# /etc/inittab: This file describes how the INIT process should set up
|
||||
# the system in a certain run-level.
|
||||
|
||||
# Default runlevel.
|
||||
id:3:initdefault:
|
||||
|
||||
# System initialization, mount local filesystems, etc.
|
||||
si::sysinit:/sbin/openrc sysinit
|
||||
|
||||
# Further system initialization, brings up the boot runlevel.
|
||||
rc::bootwait:/sbin/openrc boot
|
||||
|
||||
l0:0:wait:/sbin/openrc shutdown
|
||||
l0s:0:wait:/sbin/halt -dhip
|
||||
l1:S1:wait:/sbin/openrc single
|
||||
l2:2:wait:/sbin/openrc nonetwork
|
||||
l3:3:wait:/sbin/openrc default
|
||||
l4:4:wait:/sbin/openrc default
|
||||
l5:5:wait:/sbin/openrc default
|
||||
l6:6:wait:/sbin/openrc reboot
|
||||
l6r:6:wait:/sbin/reboot -d
|
||||
#z6:6:respawn:/sbin/sulogin
|
||||
|
||||
# new-style single-user
|
||||
su0:S:wait:/sbin/openrc single
|
||||
su1:S:wait:/sbin/sulogin
|
||||
|
||||
# TERMINALS
|
||||
c1:12345:respawn:/sbin/agetty 38400 tty1 linux
|
||||
c2:2345:respawn:/sbin/agetty 38400 tty2 linux
|
||||
c3:2345:respawn:/sbin/agetty 38400 tty3 linux
|
||||
c4:2345:respawn:/sbin/agetty 38400 tty4 linux
|
||||
c5:2345:respawn:/sbin/agetty 38400 tty5 linux
|
||||
c6:2345:respawn:/sbin/agetty 38400 tty6 linux
|
||||
|
||||
# SERIAL CONSOLES
|
||||
#s0:12345:respawn:/sbin/agetty 9600 ttyS0 vt100
|
||||
#s1:12345:respawn:/sbin/agetty 9600 ttyS1 vt100
|
||||
|
||||
# What to do at the "Three Finger Salute".
|
||||
ca:12345:ctrlaltdel:/sbin/shutdown -r now
|
||||
Reference in New Issue
Block a user