2022-09-13 12:11:20 +02:00
|
|
|
post_install_script = '''
|
2021-07-29 12:38:18 +02:00
|
|
|
#!/bin/bash -e
|
2023-10-20 11:19:30 +02:00
|
|
|
#RPM_SYSTEMD_MACROS#
|
2021-07-29 12:38:18 +02:00
|
|
|
|
|
|
|
if [ $EUID -ne 0 ]; then
|
|
|
|
echo >&2 "ERROR: RTRTR postinst script must be run as root"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $1 -eq 1 ] ; then
|
|
|
|
# Initial installation
|
|
|
|
R_USER=rtrtr
|
|
|
|
R_GROUP=${R_USER}
|
|
|
|
R_HOME_DIR=/var/lib/rtrtr
|
|
|
|
R_HOME_DIR_PERMS=700
|
|
|
|
|
2023-10-20 11:19:30 +02:00
|
|
|
# https://github.com/NLnetLabs/routinator/issues/774
|
|
|
|
if ! id ${R_USER} > /dev/null 2>&1; then
|
|
|
|
# According to the CentOS 7 useradd man page:
|
|
|
|
# --user-group causes a group by the same name as the user to be created
|
|
|
|
# --create-home should force creation of a home dir even for a system account.
|
|
|
|
useradd --system --home-dir ${R_HOME_DIR} --system --create-home --user-group ${R_USER}
|
|
|
|
fi
|
2021-07-29 12:38:18 +02:00
|
|
|
|
|
|
|
# Ensure that the home directory has the correct ownership
|
|
|
|
chown -R ${R_USER}:${R_GROUP} ${R_HOME_DIR}
|
|
|
|
|
|
|
|
# Ensure that the home directory has the correct permissions
|
|
|
|
chmod ${R_HOME_DIR_PERMS} ${R_HOME_DIR}
|
|
|
|
|
2023-10-20 11:19:30 +02:00
|
|
|
# Run commands equivalent to what the RPM systemd macros would do
|
|
|
|
systemd_post rtrtr.service
|
|
|
|
systemd_triggers
|
2022-09-13 12:11:20 +02:00
|
|
|
fi
|
|
|
|
'''
|
2023-10-20 11:19:30 +02:00
|
|
|
|
|
|
|
pre_uninstall_script = '''
|
|
|
|
#!/bin/bash -e
|
|
|
|
#RPM_SYSTEMD_MACROS#
|
|
|
|
|
|
|
|
if [ $1 -eq 0 ] ; then
|
|
|
|
# Package removal, not upgrade
|
|
|
|
# Run commands equivalent to what the RPM systemd macros would do
|
|
|
|
systemd_preun rtrtr.service
|
|
|
|
systemd_triggers
|
|
|
|
fi
|
|
|
|
'''
|
|
|
|
|
|
|
|
post_uninstall_script = '''
|
|
|
|
#!/bin/bash -e
|
|
|
|
#RPM_SYSTEMD_MACROS#
|
|
|
|
|
|
|
|
if [ $1 -ge 1 ] ; then
|
|
|
|
# Run commands equivalent to what the RPM systemd macros would do
|
|
|
|
systemd_postun_with_restart rtrtr.service
|
|
|
|
systemd_triggers
|
|
|
|
fi
|
|
|
|
'''
|
|
|
|
|