diff options
Diffstat (limited to 'extra')
23 files changed, 519 insertions, 3 deletions
diff --git a/extra/acpid/acpid.confd b/extra/acpid/acpid.confd new file mode 100644 index 0000000..2b3d304 --- /dev/null +++ b/extra/acpid/acpid.confd @@ -0,0 +1,7 @@ +# Configuration file for /etc/init.d/acpid (from acpid package) + +# Additional arguments to pass to acpid. +command_args="--logevents" + +# Uncomment to use process supervisor. +#supervisor="supervise-daemon" diff --git a/extra/acpid/acpid.initd b/extra/acpid/acpid.initd new file mode 100644 index 0000000..c2d60f9 --- /dev/null +++ b/extra/acpid/acpid.initd @@ -0,0 +1,28 @@ +#!/sbin/openrc-run + +description="The ACPI Daemon" + +extra_started_commands="reload" +description_reload="Reload configuration" + +command="/sbin/acpid" +command_args="--foreground ${command_args:-}" +command_background="yes" +pidfile="/run/$RC_SVCNAME.pid" + +depend() { + need dev localmount + after hwdrivers modules + provide acpid + keyword -vserver -lxc +} + +reload() { + ebegin "Reloading $RC_SVCNAME configuration" + if [ "$supervisor" ]; then + $supervisor "$RC_SVCNAME" --signal HUP + else + start-stop-daemon --pidfile "$pidfile" --signal HUP + fi + eend $? +} diff --git a/extra/acpid/anything b/extra/acpid/anything new file mode 100644 index 0000000..d182898 --- /dev/null +++ b/extra/acpid/anything @@ -0,0 +1,3 @@ +# Pass all events to our one handler script +event=.* +action=/etc/acpi/handler.sh %e diff --git a/extra/acpid/handler.sh b/extra/acpid/handler.sh new file mode 100644 index 0000000..412ac02 --- /dev/null +++ b/extra/acpid/handler.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# vim: set ts=4: +# +# This is the default ACPI handler script that is configured in +# /etc/acpi/events/anything to be called for every ACPI event. +# You can edit it and add your own actions; treat it as a configuration file. +# +PATH="/usr/share/acpid:$PATH" +alias log='logger -t acpid' + +# <dev-class>:<dev-name>:<notif-value>:<sup-value> +case "$1:$2:$3:$4" in + +button/power:PWRF:*) + log 'Power button pressed' + # Shutdown the system unless it has a lid (notebook). + [ -e /proc/acpi/button/lid/LID ] || poweroff +;; +button/sleep:SLPB:*) + log 'Sleep button pressed' + # Suspend to RAM. + zzz +;; +button/lid:*:close:*) + log 'Lid closed' + # Suspend to RAM if AC adapter is not connected. + power-supply-ac || zzz +;; +ac_adapter:*:*:*0) + log 'AC adapter unplugged' + # Suspend to RAM if notebook's lid is closed. + lid-closed && zzz +;; +esac + +exit 0 diff --git a/extra/acpid/lid-closed b/extra/acpid/lid-closed new file mode 100644 index 0000000..57ffb71 --- /dev/null +++ b/extra/acpid/lid-closed @@ -0,0 +1,21 @@ +#!/bin/sh +# This script exits with status 0 if the latop's lid is closed, 1 if opened, +# 10 if /proc/acpi/button/lid/LID/state does not exist or is not readable. +set -u + +STATE_FILE='/proc/acpi/button/lid/LID/state' + +verbose=false +[ "${1:-}" = '-v' ] && verbose=true + +if ! [ -r "$STATE_FILE" ]; then + $verbose && echo "$STATE_FILE does not exist or is not readable!" >&2 + exit 10 +fi + +read -r _ state < "$STATE_FILE" || exit 10 + +[ "$state" = 'closed' ]; rc=$? + +$verbose && echo $rc +exit $rc diff --git a/extra/acpid/power-supply-ac b/extra/acpid/power-supply-ac new file mode 100644 index 0000000..337aae2 --- /dev/null +++ b/extra/acpid/power-supply-ac @@ -0,0 +1,25 @@ +#!/bin/sh +# This script exits with status 0 when the computer is on AC power (or no AC +# power supply found), 1 otherwise (i.e. running on battery). +set -u + +verbose=false +[ "${1:-}" = '-v' ] && verbose=true + +# If we do not have any power supplies, assume we are on AC. +rc=0 + +# Iterate through power supplies sysfs knows about. +for ps in /sys/class/power_supply/*; do + [ -r $ps/online ] || continue + # We know we have an AC adaptor, our default return changes to failed. + rc=1 + + if [ "$(cat $ps/online)" -eq 1 ]; then + rc=0 + break + fi +done + +$verbose && echo $rc +exit $rc diff --git a/extra/dbus/dbus.confd b/extra/dbus/dbus.confd new file mode 100644 index 0000000..0454047 --- /dev/null +++ b/extra/dbus/dbus.confd @@ -0,0 +1,7 @@ +# Configuration for /etc/init.d/dbus + +# Additional arguments to pass to dbus-daemon. +#command_args= + +# Uncomment to use process supervisor. +#supervisor=supervise-daemon diff --git a/extra/dbus/dbus.initd b/extra/dbus/dbus.initd new file mode 100644 index 0000000..f3f44da --- /dev/null +++ b/extra/dbus/dbus.initd @@ -0,0 +1,33 @@ +#!/sbin/openrc-run +name="System Message Bus" +description="D-Bus System Message Bus" + +extra_started_commands="reload" + +command="/usr/bin/dbus-daemon" +command_args="--system --nofork --nopidfile --syslog-only ${command_args:-}" +command_background="yes" +pidfile="/run/$RC_SVCNAME.pid" + +depend() { + need localmount + after bootmisc +} + +start_pre() { + checkpath -d -m755 -o root:messagebus /run/dbus || return 1 + + /usr/bin/dbus-uuidgen --ensure=/etc/machine-id +} + +stop_post() { + [ ! -S /run/dbus/system_bus_socket ] || rm -f /run/dbus/system_bus_socket +} + +reload() { + ebegin "Reloading $name configuration" + /usr/bin/dbus-send --print-reply --system --type=method_call \ + --dest=org.freedesktop.DBus \ + / org.freedesktop.DBus.ReloadConfig > /dev/null + eend $? +} diff --git a/extra/dbus/dbus.trigger b/extra/dbus/dbus.trigger new file mode 100644 index 0000000..a537bd8 --- /dev/null +++ b/extra/dbus/dbus.trigger @@ -0,0 +1,4 @@ +#!/bin/sh + +dbus-send --system --type=method_call --dest=org.freedesktop.DBus / \ + org.freedesktop.DBUS.ReloadConfig >/dev/null 2>&1 || : diff --git a/extra/dhcp/01-dhclient-script-fix-bare-ip.patch b/extra/dhcp/01-dhclient-script-fix-bare-ip.patch new file mode 100644 index 0000000..7b3165d --- /dev/null +++ b/extra/dhcp/01-dhclient-script-fix-bare-ip.patch @@ -0,0 +1,13 @@ +diff --git a/client/scripts/linux b/client/scripts/linux +index 0c42969..3cd2a75 100755 +--- a/client/scripts/linux ++++ b/client/scripts/linux +@@ -394,7 +394,7 @@ case "$reason" in + make_resolv_conf + else + # flush all IPs from interface +- ip -4 addr flush dev ${interface} ++ ${ip} -4 addr flush dev ${interface} + exit_with_hooks 2 + fi + diff --git a/extra/dhcp/02-dhclient-script-remove-bashisms.patch b/extra/dhcp/02-dhclient-script-remove-bashisms.patch new file mode 100644 index 0000000..afa1048 --- /dev/null +++ b/extra/dhcp/02-dhclient-script-remove-bashisms.patch @@ -0,0 +1,28 @@ +diff --git a/client/scripts/linux b/client/scripts/linux +index 0c42969..2e7274b 100755 +--- a/client/scripts/linux ++++ b/client/scripts/linux +@@ -1,4 +1,4 @@ +-#!/bin/bash ++#!/bin/sh + # dhclient-script for Linux. Dan Halbert, March, 1997. + # Updated for Linux 2.[12] by Brian J. Murrell, January 1999. + # No guarantees about this. I'm a novice at the details of Linux +@@ -428,7 +428,7 @@ case "$reason" in + # Check if any IPv6 address on this interface is marked as + # tentative. + ${ip} addr show ${interface} | grep inet6 | grep tentative \ +- &> /dev/null ++ > /dev/null 2>&1 + if [ $? -eq 0 ]; then + # Wait for duplicate address detection to complete or for + # the timeout specified as --dad-wait-time. +@@ -437,7 +437,7 @@ case "$reason" in + # We're going to poll for the tentative flag every second. + sleep 1 + ${ip} addr show ${interface} | grep inet6 | grep tentative \ +- &> /dev/null ++ > /dev/null 2>&1 + if [ $? -ne 0 ]; then + break; + fi diff --git a/extra/dhcp/03-fix-unwind-import.patch b/extra/dhcp/03-fix-unwind-import.patch new file mode 100644 index 0000000..8b87fdb --- /dev/null +++ b/extra/dhcp/03-fix-unwind-import.patch @@ -0,0 +1,16 @@ +bind assumes _Unwind_GetIP is a function which is not necessarily +true. In some implementations of libunwind it's a macro. +This fixes the build on Alpine on armhf and armv7. + +--- a/bind/bind-9.11.36/lib/isc/backtrace.c ++++ b/bind/bind-9.11.36/lib/isc/backtrace.c +@@ -81,8 +81,7 @@ isc_backtrace_gettrace(void **addrs, int + return (ISC_R_SUCCESS); + } + #elif defined(BACKTRACE_GCC) +-extern int _Unwind_Backtrace(void* fn, void* a); +-extern void* _Unwind_GetIP(void* ctx); ++#include <unwind.h> + + typedef struct { + void **result; diff --git a/extra/dhcp/dhcpd.confd b/extra/dhcp/dhcpd.confd new file mode 100644 index 0000000..5cd2eec --- /dev/null +++ b/extra/dhcp/dhcpd.confd @@ -0,0 +1,28 @@ +# /etc/conf.d/dhcpd: config file for /etc/init.d/dhcpd + +# If you require more than one instance of dhcpd you can create symbolic +# links to dhcpd service like so +# cd /etc/init.d +# ln -s dhcpd dhcpd.foo +# cd ../conf.d +# cp dhcpd dhcpd.foo +# Now you can edit dhcpd.foo and specify a different configuration file. +# You'll also need to specify a pidfile in that dhcpd.conf file. +# See the pid-file-name option in the dhcpd.conf man page for details. + +# If you wish to run dhcpd in a chroot, uncomment the following line +# DHCPD_CHROOT="/var/lib/dhcp/chroot" + +# All file paths below are relative to the chroot. +# You can specify a different chroot directory but MAKE SURE it's empty. + +# Specify a configuration file - the default is /etc/dhcp/dhcpd.conf +# DHCPD_CONF="/etc/dhcp/dhcpd.conf" + +# Configure which interface or interfaces to for dhcpd to listen on. +# List all interfaces space separated. If this is not specified then +# we listen on all interfaces. +# DHCPD_IFACE="" + +# Insert any other dhcpd options - see the man page for a full list. +# DHCPD_OPTS="" diff --git a/extra/dhcp/dhcpd.initd b/extra/dhcp/dhcpd.initd new file mode 100644 index 0000000..f69ae71 --- /dev/null +++ b/extra/dhcp/dhcpd.initd @@ -0,0 +1,115 @@ +#!/sbin/openrc-run +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/dhcp/files/dhcpd.init5,v 1.1 2011/12/04 22:45:07 vapier Exp $ + +extra_commands="configtest" + +: ${DHCPD_CONF:=/etc/dhcp/${SVCNAME}.conf} + +depend() { + need net + after firewall + use logger dns +} + +get_var() { + local var="$(sed -n 's/^[[:blank:]]\?'"$1"' "*\([^#";]\+\).*/\1/p' "${chroot}${DHCPD_CONF}")" + echo ${var:-$2} +} + +checkconfig() { + set -- ${DHCPD_OPTS} ${chroot:+-chroot} ${chroot} -t + + dhcpd "$@" 1>/dev/null 2>&1 + local ret=$? + if [ ${ret} -ne 0 ] ; then + eerror "${SVCNAME} has detected a syntax error in your configuration files:" + dhcpd "$@" + fi + + return ${ret} +} + +configtest() { + local chroot=${DHCPD_CHROOT%/} + + ebegin "Checking ${SVCNAME} configuration" + checkconfig + eend $? +} + +start() { + local chroot=${DHCPD_CHROOT%/} + + # Work out our cffile if it's in our DHCPD_OPTS + case " ${DHCPD_OPTS} " in + *" -cf "*) + DHCPD_CONF=" ${DHCPD_OPTS} " + DHCPD_CONF="${DHCPD_CONF##* -cf }" + DHCPD_CONF="${DHCPD_CONF%% *}" + ;; + *) DHCPD_OPTS="${DHCPD_OPTS} -cf ${DHCPD_CONF}" + ;; + esac + + if [ -n "${chroot}" ] ; then + # the config test want's these to exist + mkdir -p \ + "${chroot}"/run/dhcp \ + "${chroot}"/var/lib/dhcp \ + "${chroot}"/etc/dhcp + fi + + # see comment in get_var() above + if [ ! -f "${chroot}${DHCPD_CONF}" ] ; then + eerror "${chroot}${DHCPD_CONF} does not exist" + return 1 + fi + + checkconfig || return 1 + + checkpath -d -o dhcp:dhcp "${chroot}"/run/dhcp "${chroot}"/var/lib/dhcp + + local leasefile="$(get_var lease-file-name /var/lib/dhcp/${SVCNAME}.leases)" + checkpath -f -o dhcp:dhcp "${chroot}${leasefile}" + + # Setup LD_PRELOAD so name resolution works in our chroot. + if [ -n "${chroot}" ] ; then + checkpath -d -o root:root -m 755 "${chroot}"/dev "${chroot}"/etc "${chroot}"/proc + cp -pP /etc/localtime /etc/resolv.conf "${chroot}"/etc/ + export LD_PRELOAD="${LD_PRELOAD} libresolv.so libnss_dns.so" + if ! mountinfo -q "${chroot}/proc" ; then + mount --bind /proc "${chroot}/proc" + fi + fi + + local pidfile="$(get_var pid-file-name /run/dhcp/${SVCNAME}.pid)" + + ebegin "Starting ${chroot:+chrooted }${SVCNAME}" + start-stop-daemon --start --exec /usr/sbin/dhcpd \ + --pidfile "${chroot}/${pidfile}" \ + -- ${DHCPD_OPTS} -q -pf "${pidfile}" -lf "${leasefile}" \ + -user dhcp -group dhcp \ + ${chroot:+-chroot} ${chroot} ${DHCPD_IFACE} + eend $? \ + && save_options chroot "${chroot}" \ + && save_options pidfile "${pidfile}" +} + +stop() { + local chroot="$(get_options chroot)" + + ebegin "Stopping ${chroot:+chrooted }${SVCNAME}" + start-stop-daemon --stop --exec /usr/sbin/dhcpd \ + --pidfile "${chroot}/$(get_options pidfile)" + res=$? + + if [ ${res} -eq 0 ] && [ -n "${chroot}" ] ; then + if mountinfo -q "${chroot}/proc" ; then + umount "${chroot}/proc" + fi + fi + + eend $res +} diff --git a/extra/networkmanager/networkmanager-dispatcher.initd b/extra/networkmanager/networkmanager-dispatcher.initd new file mode 100644 index 0000000..552cc15 --- /dev/null +++ b/extra/networkmanager/networkmanager-dispatcher.initd @@ -0,0 +1,12 @@ +#!/sbin/openrc-run + +supervisor=supervise-daemon +command=/usr/libexec/nm-dispatcher +command_args_foreground="--persist" + +description="Network Manager Dispatcher Daemon" + +depend() { + need dbus + before networkmanager +} diff --git a/extra/networkmanager/networkmanager.conf b/extra/networkmanager/networkmanager.conf new file mode 100644 index 0000000..526d2e4 --- /dev/null +++ b/extra/networkmanager/networkmanager.conf @@ -0,0 +1,2 @@ +[main] +dhcp=internal diff --git a/extra/networkmanager/networkmanager.initd b/extra/networkmanager/networkmanager.initd new file mode 100644 index 0000000..4ca6a0d --- /dev/null +++ b/extra/networkmanager/networkmanager.initd @@ -0,0 +1,17 @@ +#!/sbin/openrc-run +# Copyright (c) 2008 Saleem Abdulrasool <compnerd@compnerd.org> +# Distributed under the terms of the GNU General Purpose License v2 +# $Header: $ + +supervisor=supervise-daemon +command=/usr/sbin/NetworkManager +command_args_foreground="-n" + +description="Network Manager Daemon" + +depend() { + need dbus + provide net +} + +# vim: set ft=gentoo-init-d ts=3 sw=3 et: diff --git a/extra/networkmanager/networkmanager.rules b/extra/networkmanager/networkmanager.rules new file mode 100644 index 0000000..66d21d6 --- /dev/null +++ b/extra/networkmanager/networkmanager.rules @@ -0,0 +1,9 @@ +// Let users in plugdev group modify NetworkManager +polkit.addRule(function(action, subject) { + if (action.id == "org.freedesktop.NetworkManager.settings.modify.system" && + subject.isInGroup("plugdev") && subject.active) { + return "yes"; + } +}); + + diff --git a/extra/openrc/hostname.initd b/extra/openrc/hostname.initd index bd20874..4581595 100644 --- a/extra/openrc/hostname.initd +++ b/extra/openrc/hostname.initd @@ -8,11 +8,11 @@ depend() { start() { if [ -s /etc/hostname ] ; then - opts="-F /etc/hostname" + name=$(cat /etc/hostname) else - opts="${hostname:-localhost}" + name="${hostname:-localhost}" fi ebegin "Setting hostname" - hostname $opts + hostname $name eend $? } diff --git a/extra/wpa_supplicant/wpa_cli.confd b/extra/wpa_supplicant/wpa_cli.confd new file mode 100644 index 0000000..aa481ac --- /dev/null +++ b/extra/wpa_supplicant/wpa_cli.confd @@ -0,0 +1 @@ +WPACLI_OPTS="-a /etc/wpa_supplicant/wpa_cli.sh" diff --git a/extra/wpa_supplicant/wpa_cli.initd b/extra/wpa_supplicant/wpa_cli.initd new file mode 100644 index 0000000..2bf7c0d --- /dev/null +++ b/extra/wpa_supplicant/wpa_cli.initd @@ -0,0 +1,22 @@ +#!/sbin/openrc-run + +supervisor=supervise-daemon + +# The wpa_cli services depends on wpa_supplicant. If wpa_supplicant is +# restarted, so is wpa_cli. Unfortunately, wpa_supplicant creates the +# socket, used for communication with wpa_cli, rather late thereby +# causing wpa_cli to be restarted before it is created and thus fail. +# By default supervise-daemon will restart wpa_cli immediately, often +# resulting in all restart attempts to be exhausted before the socket is +# created. To work around this issue, add a respawn-delay to wpa_cli. +supervise_daemon_args="--respawn-delay 3" + +name="WPA Command Line Client" +description="Text-based frontend for interacting with WPA Supplicant" + +command=/sbin/wpa_cli +command_args="${WPACLI_OPTS} >/dev/null" + +depend() { + need wpa_supplicant +} diff --git a/extra/wpa_supplicant/wpa_supplicant.confd b/extra/wpa_supplicant/wpa_supplicant.confd new file mode 100644 index 0000000..56a6c11 --- /dev/null +++ b/extra/wpa_supplicant/wpa_supplicant.confd @@ -0,0 +1,10 @@ +# conf.d file for wpa_supplicant +# +# Please check man 8 wpa_supplicant for more information about the options +# wpa_supplicant accepts. +wpa_supplicant_args="" + +# The dbus interface will be enabled by default if wpa_supplicant.conf is +# missing. use wpa_supplicant_dbus to explicitly enable/disable dbus interface + +#wpa_supplicant_dbus=no diff --git a/extra/wpa_supplicant/wpa_supplicant.initd b/extra/wpa_supplicant/wpa_supplicant.initd new file mode 100644 index 0000000..c1a4834 --- /dev/null +++ b/extra/wpa_supplicant/wpa_supplicant.initd @@ -0,0 +1,79 @@ +#!/sbin/openrc-run +# Copyright (c) 2009 Roy Marples <roy@marples.name> +# All rights reserved. Released under the 2-clause BSD license. +supervisor=supervise-daemon + +name="WPA Supplicant" +description="Wi-Fi Protected Access client and IEEE 802.1X supplicant" + +command=/sbin/wpa_supplicant +wpa_supplicant_if=${wpa_supplicant_if:+-i}$wpa_supplicant_if +command_args="$wpa_supplicant_args $wpa_supplicant_if" + +default_conf=/etc/wpa_supplicant/wpa_supplicant.conf + +depend() { + need localmount + use logger dbus + after bootmisc modules entropy udev-settle + before dns dhcpcd net + keyword -shutdown +} + +find_wireless() { + local iface= + for iface in /sys/class/net/*; do + if [ -e "$iface"/wireless -o -e "$iface"/phy80211 ]; then + echo "${iface##*/}" + return 0 + fi + done + + 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 + + # set default conf if dbus is explicitly disabled + if [ -n "${wpa_supplicant_dbus}" ] && ! yesno "${wpa_supplicant_dbus}"; then + : ${wpa_supplicant_conf:=${default_conf}} + fi + + # use default conf if it exists + if [ -f "${default_conf}" ]; then + : ${wpa_supplicant_conf:=${default_conf}} + fi + + # enable default dbus if we still dont have a config + if [ -z "${wpa_supplicant_conf}" ]; then + : ${wpa_supplicant_dbus:=yes} + else + command_args="${command_args} -c$wpa_supplicant_conf" + fi + case " ${command_args}" in + *" -u"*);; + *) if yesno "{wpa_supplicant_dbus}"; then + command_args="-u ${command_args}" + fi + ;; + esac + + checkpath -d -m 0755 -o root:root /var/run/wpa_supplicant +} |