Add support for OpenRC to dib-init-system

Adds a post-install function that enables installed initscripts,
as that is not done by default in gentoo.

Change-Id: I04e8d506ddcbefa8a983dd31ad16df5e13cb26e7
Closes-Bug: 1539276
This commit is contained in:
Matthew Thode 2016-01-28 15:53:13 -06:00
parent 4526cf23ec
commit 265b31e6b5
No known key found for this signature in database
GPG Key ID: 64A37BEAAE19A4E8
3 changed files with 39 additions and 5 deletions

View File

@ -6,12 +6,18 @@ fi
set -eu set -eu
set -o pipefail set -o pipefail
if [ -f /sbin/initctl ]; then if [[ -f /sbin/initctl ]]; then
echo "upstart" echo "upstart"
elif [ -f /usr/bin/systemctl ]; then elif [[ -f /etc/gentoo-release ]]; then
if [[ "${GENTOO_PROFILE}" =~ systemd ]]; then
echo "systemd"
else
echo "openrc"
fi
elif [[ -f /usr/bin/systemctl ]]; then
echo "systemd" echo "systemd"
elif [ -f /sbin/init ]; then elif [[ -f /sbin/init ]]; then
if [ -f /bin/systemd ]; then if [[ -f /bin/systemd ]]; then
echo "systemd" echo "systemd"
else else
echo "sysv" echo "sysv"

View File

@ -14,12 +14,13 @@ if [ -d "$scripts_dir" ]; then
dest= dest=
case $DIB_INIT_SYSTEM in case $DIB_INIT_SYSTEM in
upstart) dest=/etc/init/ ;; upstart) dest=/etc/init/ ;;
openrc) dest=/etc/init.d/ ;;
systemd) dest=/usr/lib/systemd/system/ ;; systemd) dest=/usr/lib/systemd/system/ ;;
sysv) dest=/etc/init.d/ ;; sysv) dest=/etc/init.d/ ;;
esac esac
if [ -z "$dest" ]; then if [ -z "$dest" ]; then
echo "ERROR: DIB_INIT_SYSTEM ($DIB_INIT_SYSTEM) is not an unknown type" echo "ERROR: DIB_INIT_SYSTEM ($DIB_INIT_SYSTEM) is not a known type"
exit 1 exit 1
fi fi
cp -RP $scripts_dir. $dest || true cp -RP $scripts_dir. $dest || true

View File

@ -0,0 +1,27 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
SCRIPTS_DIR="$(dirname $0)/../init-scripts/${DIB_INIT_SYSTEM}/"
if [[ -d "${SCRIPTS_DIR}" ]]; then
# figure out init prefix
case "${DIB_INIT_SYSTEM}" in
upstart) ;;
openrc)
# only gentoo needs manual runlevel adding
for INIT_SCRIPT in "${SCRIPTS_DIR}"*; do
rc-update add $(basename "${INIT_SCRIPT}") default
done
;;
systemd) ;;
sysv) ;;
*)
echo "ERROR: DIB_INIT_SYSTEM (${DIB_INIT_SYSTEM}) is not a known type"
exit 1
;;
esac
fi