2d11a6b026
- Import commit fdce77ce2067f9dd90d816bad28b51efed0b6dc1 05fff5bd02 generator: use kmsg in system-level generators, journal otherwise ecc07954de log: normalize log target condition check d32ceea42b log: update comment 2ebad02b60 basic/virt: Detect PowerVM hypervisor (bsc#1176800) - Simplify systemd-sysv-convert - the previous code incorrectly assumed that the sysv init scripts were uninstalled before %post get executed. It therefore save the enablement state in %pre and restore it in %post. Now all is done in %post (making --save option useless) and there's no more need to remember the enablement state. - "--save" option is a NOP but is still kept for backward compatibility. - the previous simplifcation made /var/lib/systemd/migrated no more used. - we do not search for units in /lib/systemd anymore, this shouldn't be needed anymore these days especially since this path was only used when systemd was introduced in openSUSE and it was never used in SLE (checked SLE12-GA). - the option --show has been dropped. It's never been used even internally. - the DB is populated only once even if the script was enabled at multiple runlevels. The runlevel info was never used. A dummy value is still added to keep the same format just in case. - No more need to clean the journal-upload stuff with --without=journal_remote Since -Dremote build option has been introduced with meson, this workaround is no more needed. OBS-URL: https://build.opensuse.org/request/show/846415 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=1124
113 lines
2.5 KiB
Bash
113 lines
2.5 KiB
Bash
#!/bin/bash
|
|
|
|
info() {
|
|
echo "$(basename $0): $*"
|
|
}
|
|
|
|
warn() {
|
|
echo >&2 "$(basename $0): warning, $*"
|
|
}
|
|
|
|
usage() {
|
|
echo >&2 "usage: $(basename $0) --apply <service> [<service> ...]"
|
|
}
|
|
|
|
if [ "$UID" != "0" ]; then
|
|
warn "need to be root, aborting"
|
|
exit 1
|
|
fi
|
|
|
|
if [ $# -lt 2 ]; then
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
database_lookup() {
|
|
local service unused
|
|
|
|
# 'priority' field is not used but is kept for backward compat reason.
|
|
while read service unused; do
|
|
if [ $service == $1 ]; then
|
|
return 0
|
|
fi
|
|
done </var/lib/systemd/sysv-convert/database
|
|
|
|
return 1
|
|
}
|
|
|
|
database_add() {
|
|
# Write a dumb priority as it is not used.
|
|
echo "$1 $2 50" >>/var/lib/systemd/sysv-convert/database
|
|
}
|
|
|
|
# Initialize the database.
|
|
if [ ! -e /var/lib/systemd/sysv-convert/database ]; then
|
|
touch /var/lib/systemd/sysv-convert/database
|
|
fi
|
|
|
|
case "$1" in
|
|
--save)
|
|
# --save is kept for backward compatibility.
|
|
;;
|
|
--apply)
|
|
shift
|
|
for service in $@; do
|
|
# For backward compat we accept the name of the
|
|
# service with or without the unit type suffix. If the
|
|
# suffix is not there, assume .service type.
|
|
case "$service" in
|
|
*.*) initscript="${service%.*}" ;;
|
|
*) initscript="$service"
|
|
service="$service.service"
|
|
esac
|
|
|
|
# Did we already migrate this service during a previous update ?
|
|
database_lookup $initscript &&
|
|
continue
|
|
|
|
# Sanity check.
|
|
unit="/usr/lib/systemd/system/$service"
|
|
if [ ! -f "$unit" ]; then
|
|
warn "$unit not found, skipping"
|
|
continue
|
|
fi
|
|
|
|
# Mark the service as processed to make sure we will do the migration only
|
|
# once. This is important especially for packages that keep their init
|
|
# scripts around even if they're no more used. Since the saved info won't
|
|
# be reused again we simply use an invalid runlevel and add the service
|
|
# in the db only once.
|
|
database_add $initscript -1
|
|
|
|
# The package is introducing new services and never has any sysv init
|
|
# scripts (bsc#982303).
|
|
if [ ! -r /etc/init.d/$initscript ] &&
|
|
[ ! -r /etc/init.d/boot.$initscript ]; then
|
|
continue
|
|
fi
|
|
|
|
for rcnd in rc2.d rc3.d rc4.d rc5.d boot.d; do
|
|
# Was the sysvinit script enabled ? (bsc#982211)
|
|
case $rcnd in
|
|
boot.d) [ -L /etc/rc.d/boot.d/S??boot.$initscript ] || continue ;;
|
|
*) [ -L /etc/rc.d/$rcnd/S??$initscript ] || continue
|
|
esac
|
|
|
|
case $rcnd in
|
|
boot.d) runlevel=3 ;;
|
|
*) runlevel=${rcnd:2:1}
|
|
esac
|
|
|
|
target=runlevel$runlevel.target
|
|
info "enabling $unit (wanted by $target)..."
|
|
|
|
mkdir -p "/etc/systemd/system/$target.wants"
|
|
ln -sf $unit /etc/systemd/system/$target.wants/$service
|
|
done
|
|
done
|
|
;;
|
|
*)
|
|
usage
|
|
exit 1
|
|
esac
|