Merge "Add support for OpenRC to dib-init-system"

This commit is contained in:
Jenkins 2016-02-05 04:15:53 +00:00 committed by Gerrit Code Review
commit 5ee1cbac4a
3 changed files with 39 additions and 5 deletions

View File

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

View File

@ -14,12 +14,13 @@ if [ -d "$scripts_dir" ]; then
dest=
case $DIB_INIT_SYSTEM in
upstart) dest=/etc/init/ ;;
openrc) dest=/etc/init.d/ ;;
systemd) dest=/usr/lib/systemd/system/ ;;
sysv) dest=/etc/init.d/ ;;
esac
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
fi
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