aports/main/openssh/openssh-server.post-upgrade
Sertonix f5c720767f main/openssh: replace deprecated flag in trigger
--installed will be deprecated in apkv3. Using -e instead since it is
available in apkv2 and apkv3
2025-04-16 12:44:48 +00:00

51 lines
1.2 KiB
Bash

#!/bin/sh
ver_old="$2"
# Only when upgrading from an older version than 10.0_p1-r2
# and the openssh-server-common-openrc package is installed
if [ "$(apk version -t "$ver_old" '10.0_p1-r2')" = '<' ] \
&& apk info -e openssh-server-common-openrc > /dev/null
then
# If started, print message
rc-service sshd status | grep -q started && cat >&2 <<-EOF
*
* The sshd service will now be restarted.
*
* This is a special exception to our rule
* of not managing services through apk.
*
* From openssh version 10.0_p1 the user
* authentication is split from sshd-session
* into a separate sshd-auth binary and
* without a restart of sshd it will not be
* possible to log in.
*
* This restart of sshd is to prevent you
* from being locked out of your system
* during or after the upgrade.
*
EOF
# Then restart, if started
if rc-service --ifstarted sshd restart
then
# The above will exit with success even if sshd is stopped
exit 0
else
# If the command would fail for any reason, print this
cat >&2 <<-EOF
*
* WARNING!
*
* The sshd service has failed to restart.
*
* You need to manually sort the issues and
* restart sshd.
*
EOF
# Return error, so that the user won't miss this
exit 1
fi
fi
exit 0