SHA256
1
0
forked from pool/systemd
systemd/systemd-sysv-install
Dominique Leuenberger 49e3c4604e Accepting request 947453 from Base:System
- Move the systemd-network-generator stuff in udev package
  This generator can generate .link files and is mainly used in initrd where
  udev is mandatory.

- Restore /sbin/udevadm and /bin/systemctl (obsolete) paths when split_usr is
  true (bsc#1194519)

- Import commit 3743acbce3bd44208af453fc6dc384a1236dc83c (merge of v249.9)
  For a complete list of changes, visit:
  e2ca79dd77...3743acbce3

- Extract bits from 0008-sysv-generator-translate-Required-Start-into-a-Wants.patch
  which are not specific to the handling of 'Required-Start:' and move them into a
  new patch 0009-sysv-add-back-support-for-all-virtual-facility-and-f.patch

- Import commit e2ca79dd775d1f7d39861d57f23c43f6cd85a872 (merge of v249.8)
  For a complete list of changes, visit:
  458220239c...e2ca79dd77

- Import commit 458220239c69b8e5fe7be480929348daeccb70d1
  e95df40b09 shared/rm-rf: loop over nested directories instead of instead of recursing (CVE-2021-3997 bsc#1194178)
  078e04305d shared/rm_rf: refactor rm_rf() to shorten code a bit
  6d560d0aca shared/rm_rf: refactor rm_rf_children_inner() to shorten code a bit
  6666ff056c localectl: don't omit keymaps files that are symlinks (bsc#1191826)
- Drop the following patches as they have been merged into SUSE/v249 branch:
  5000-shared-rm_rf-refactor-rm_rf_children_inner-to-shorte.patch
  5001-shared-rm_rf-refactor-rm_rf-to-shorten-code-a-bit.patch
  5002-shared-rm-rf-loop-over-nested-directories-instead-of.patch

- Import commit 523f32df573d459551760b072cb62906f4a2cf23 (merge of v249.7)

OBS-URL: https://build.opensuse.org/request/show/947453
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=344
2022-01-21 00:25:13 +00:00

149 lines
2.9 KiB
Bash

#!/bin/bash
# This script is called by "systemctl enable/disable" when the given unit is a
# SysV init.d script. It needs to call the distribution's mechanism for
# enabling/disabling those, such as chkconfig, update-rc.d, or similar. This can
# optionally take a --root argument for enabling a SysV init script in a chroot
# or similar.
#
# chkconfig(8) and insserv(8) are no more available hence let's do the bare
# minimum and create/remove the symlinks for the well known runlevels and
# nothing more. Note that we don't take care of enabling/disabling the service
# dependencies as the sysv-generator will take care of them for us (openSUSE
# specific).
#
set -e
usage() {
echo >&2 "Usage: $0 [--quiet] [--root=path] enable|disable|is-enabled <sysv script name>"
exit 1
}
info() {
$quiet || echo "$*"
}
die() {
echo >&2 "error: $*, aborting."
exit 1
}
declare -A lsb_header
check_runlevels() {
for l in $*; do
# Sanity check
case $l in
0|1|2|3|4|5|6) continue ;;
*) return 1
esac
done
}
load_initscript() {
local found_lsb_start_marker=false
local found_lsb_end_marker=false
[ -r $1 ] || die "initscript /etc/init.d/$1 can't be read"
lsb_header=()
while read line; do
# skip anything that is not a comment
[[ "$line" =~ ^# ]] || continue
if ! $found_lsb_start_marker; then
[ "$line" == "### BEGIN INIT INFO" ] &&
found_lsb_start_marker=true
continue
fi
line=$(echo ${line:1})
case "$line" in
Default-Start:*)
levels=$(echo ${line:14})
check_runlevels $levels ||
die "Invalid runlevels specified in $line"
lsb_header[Default-Start]=$levels
;;
"## END INIT INFO")
found_lsb_end_marker=true
break ;;
esac
done <$1
$found_lsb_end_marker ||
die "malformated LSB header in $1: missing LSB end marker"
}
enable_initscript() {
load_initscript $1
for l in ${lsb_header[Default-Start]}; do
symlink="$(pwd)/rc${l}.d/S50$1"
info "ln -sf ../$1 $symlink"
ln -sf ../$1 "$symlink"
done
}
disable_initscript() {
for symlink in rc*.d/[SK]*; do
[ -L $symlink ] && [ $(readlink $symlink) = "../$1" ] && {
info "rm $(pwd)/$symlink"
rm $symlink
}
done
}
is_initscript_enabled() {
for symlink in rc*.d/S*; do
[ -L $symlink ] && [ $(readlink $symlink) = "../$1" ] &&
return 0
done
return 1
}
root=
quiet=false
# parse options
eval set -- "$(getopt --name $(basename $0) -o hqr: --long help,quiet,root: -- "$@")"
while true; do
case "$1" in
-h|--help)
usage ;;
-r|--root)
shift
root=$1 ;;
-q|--quiet)
quiet=true ;;
--)
shift
break ;;
*)
usage ;;
esac
shift
done
[ $# -eq 2 ] || usage
action=$1
name=$2
sysvinit_path=$(realpath -q -e $root/etc/init.d) ||
die "$root/etc/init.d: no such file or directory"
cd $sysvinit_path
case "$action" in
enable) enable_initscript $name ;;
disable) disable_initscript $name ;;
is-enabled) is_initscript_enabled $name ;;
*) usage
esac