systemd/systemd-sysv-install

149 lines
2.9 KiB
Plaintext
Raw Normal View History

#!/bin/bash
Accepting request 437403 from home:fbui:systemd:Factory - Own a couple of directories even if they don't belong to systemd otherwise the build system will complain. Some directories (owned by others packages) are simply used by systemd to ship some scripts or config files to customize others *optional* components. Since thos components are not build required by systemd those directories are not owned by any packages and the BS complains... - Import commit 15ea716 journal-remote: change owner of /var/log/journal/remote and create /var/lib/systemd/journal-upload (bsc#1006372) - %sysusers_create and %tmpfiles_create must be called in %post Calling %pre is broken since the respective conf files are not yet installed. - %{_libexecdir}/{tmpfiles.d,sysusers.d}/systemd-remote.conf are part of systemd-journal-remote package (only). - systemd-journal-{gatewayd,remote,upload} units are only part of "systemd-journal-remote" package. So exclude them from the main package. - Import commit a1c145e6ad6588555dca64402f9103fb1e02b1a0 7f34037 man: explain that *KeyIgnoreInhibited only apply to a subset of locks df5798b Revert "logind: really handle *KeyIgnoreInhibited options in logind.conf" (bsc#1001790 bsc#1005404) f79fee7 Revert "kbd-model-map: add more mappings offered by Yast" 3760c10 manager: tighten incoming notification message checks d6efd71 core: only warn on short reads on signal fd 6eebd91 manager: be stricter with incomining notifications, warn properly about too large ones OBS-URL: https://build.opensuse.org/request/show/437403 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=959
2016-10-26 16:59:15 +02:00
# 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
}
Accepting request 437403 from home:fbui:systemd:Factory - Own a couple of directories even if they don't belong to systemd otherwise the build system will complain. Some directories (owned by others packages) are simply used by systemd to ship some scripts or config files to customize others *optional* components. Since thos components are not build required by systemd those directories are not owned by any packages and the BS complains... - Import commit 15ea716 journal-remote: change owner of /var/log/journal/remote and create /var/lib/systemd/journal-upload (bsc#1006372) - %sysusers_create and %tmpfiles_create must be called in %post Calling %pre is broken since the respective conf files are not yet installed. - %{_libexecdir}/{tmpfiles.d,sysusers.d}/systemd-remote.conf are part of systemd-journal-remote package (only). - systemd-journal-{gatewayd,remote,upload} units are only part of "systemd-journal-remote" package. So exclude them from the main package. - Import commit a1c145e6ad6588555dca64402f9103fb1e02b1a0 7f34037 man: explain that *KeyIgnoreInhibited only apply to a subset of locks df5798b Revert "logind: really handle *KeyIgnoreInhibited options in logind.conf" (bsc#1001790 bsc#1005404) f79fee7 Revert "kbd-model-map: add more mappings offered by Yast" 3760c10 manager: tighten incoming notification message checks d6efd71 core: only warn on short reads on signal fd 6eebd91 manager: be stricter with incomining notifications, warn properly about too large ones OBS-URL: https://build.opensuse.org/request/show/437403 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=959
2016-10-26 16:59:15 +02:00
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
Accepting request 437403 from home:fbui:systemd:Factory - Own a couple of directories even if they don't belong to systemd otherwise the build system will complain. Some directories (owned by others packages) are simply used by systemd to ship some scripts or config files to customize others *optional* components. Since thos components are not build required by systemd those directories are not owned by any packages and the BS complains... - Import commit 15ea716 journal-remote: change owner of /var/log/journal/remote and create /var/lib/systemd/journal-upload (bsc#1006372) - %sysusers_create and %tmpfiles_create must be called in %post Calling %pre is broken since the respective conf files are not yet installed. - %{_libexecdir}/{tmpfiles.d,sysusers.d}/systemd-remote.conf are part of systemd-journal-remote package (only). - systemd-journal-{gatewayd,remote,upload} units are only part of "systemd-journal-remote" package. So exclude them from the main package. - Import commit a1c145e6ad6588555dca64402f9103fb1e02b1a0 7f34037 man: explain that *KeyIgnoreInhibited only apply to a subset of locks df5798b Revert "logind: really handle *KeyIgnoreInhibited options in logind.conf" (bsc#1001790 bsc#1005404) f79fee7 Revert "kbd-model-map: add more mappings offered by Yast" 3760c10 manager: tighten incoming notification message checks d6efd71 core: only warn on short reads on signal fd 6eebd91 manager: be stricter with incomining notifications, warn properly about too large ones OBS-URL: https://build.opensuse.org/request/show/437403 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=959
2016-10-26 16:59:15 +02:00
# 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
Accepting request 437403 from home:fbui:systemd:Factory - Own a couple of directories even if they don't belong to systemd otherwise the build system will complain. Some directories (owned by others packages) are simply used by systemd to ship some scripts or config files to customize others *optional* components. Since thos components are not build required by systemd those directories are not owned by any packages and the BS complains... - Import commit 15ea716 journal-remote: change owner of /var/log/journal/remote and create /var/lib/systemd/journal-upload (bsc#1006372) - %sysusers_create and %tmpfiles_create must be called in %post Calling %pre is broken since the respective conf files are not yet installed. - %{_libexecdir}/{tmpfiles.d,sysusers.d}/systemd-remote.conf are part of systemd-journal-remote package (only). - systemd-journal-{gatewayd,remote,upload} units are only part of "systemd-journal-remote" package. So exclude them from the main package. - Import commit a1c145e6ad6588555dca64402f9103fb1e02b1a0 7f34037 man: explain that *KeyIgnoreInhibited only apply to a subset of locks df5798b Revert "logind: really handle *KeyIgnoreInhibited options in logind.conf" (bsc#1001790 bsc#1005404) f79fee7 Revert "kbd-model-map: add more mappings offered by Yast" 3760c10 manager: tighten incoming notification message checks d6efd71 core: only warn on short reads on signal fd 6eebd91 manager: be stricter with incomining notifications, warn properly about too large ones OBS-URL: https://build.opensuse.org/request/show/437403 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=959
2016-10-26 16:59:15 +02:00
[ $# -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