mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
RedHat: Introduce client systemd helper script
Move the logic in our Exec* commands in our openafs-client.service unit file into a helper script: openafs-client-systemd-helper.sh. This makes it easier to control our increasingly-complex startup/shutdown checks (and makes them easier to read), and reduces the clutter in our openafs-client.service unit file. This commit does not intentionally change any of our startup/shutdown behavior yet; this just moves the existing logic into a script. Update openafs.spec.in to install the helper script. Change-Id: Iccbb4f7b28b840ee0c38b2cc57d899a1bda8b3e2 Reviewed-on: https://gerrit.openafs.org/15634 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
This commit is contained in:
parent
df3b8129ce
commit
0abbab24d2
33
src/packaging/RedHat/openafs-client-systemd-helper.sh
Executable file
33
src/packaging/RedHat/openafs-client-systemd-helper.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# systemd helper script for openafs-client.service. This is only intended to be
|
||||
# called from the openafs-client.service unit file.
|
||||
|
||||
set -e
|
||||
|
||||
[ -f /etc/sysconfig/openafs ] && . /etc/sysconfig/openafs
|
||||
|
||||
case $1 in
|
||||
ExecStartPre)
|
||||
if fs sysname >/dev/null 2>&1 ; then
|
||||
echo AFS client appears to be running -- not starting
|
||||
exit 1
|
||||
fi
|
||||
sed -n 'w/usr/vice/etc/CellServDB' /usr/vice/etc/CellServDB.local /usr/vice/etc/CellServDB.dist
|
||||
chmod 0644 /usr/vice/etc/CellServDB
|
||||
exec /sbin/modprobe openafs
|
||||
;;
|
||||
|
||||
ExecStart)
|
||||
exec /usr/vice/etc/afsd $AFSD_ARGS
|
||||
;;
|
||||
|
||||
ExecStop)
|
||||
/bin/umount /afs || true
|
||||
/usr/vice/etc/afsd -shutdown || true
|
||||
exec /sbin/rmmod openafs
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Usage: $0 {ExecStartPre|ExecStart|ExecStop}" >&2
|
||||
exit 1
|
@ -7,15 +7,9 @@ Before=remote-fs.target
|
||||
[Service]
|
||||
Type=forking
|
||||
RemainAfterExit=true
|
||||
EnvironmentFile=/etc/sysconfig/openafs
|
||||
ExecStartPre=/bin/bash -c "fs sysname > /dev/null 2>/dev/null; test $? -ne 0 || (echo AFS client appears to be running -- not starting && exit 1)"
|
||||
ExecStartPre=/bin/sed -n 'w/usr/vice/etc/CellServDB' /usr/vice/etc/CellServDB.local /usr/vice/etc/CellServDB.dist
|
||||
ExecStartPre=/bin/chmod 0644 /usr/vice/etc/CellServDB
|
||||
ExecStartPre=/sbin/modprobe openafs
|
||||
ExecStart=/usr/vice/etc/afsd $AFSD_ARGS
|
||||
ExecStop=/bin/umount /afs
|
||||
ExecStop=/usr/vice/etc/afsd -shutdown
|
||||
ExecStop=/sbin/rmmod openafs
|
||||
ExecStartPre=/usr/vice/etc/openafs-client-systemd-helper.sh ExecStartPre
|
||||
ExecStart= /usr/vice/etc/openafs-client-systemd-helper.sh ExecStart
|
||||
ExecStop= /usr/vice/etc/openafs-client-systemd-helper.sh ExecStop
|
||||
KillMode=process
|
||||
GuessMainPID=no
|
||||
SendSIGKILL=no
|
||||
|
@ -815,6 +815,7 @@ mkdir -p $RPM_BUILD_ROOT%{_unitdir}
|
||||
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/modules
|
||||
install -m 644 src/packaging/RedHat/openafs-client.service $RPM_BUILD_ROOT%{_unitdir}/openafs-client.service
|
||||
install -m 644 src/packaging/RedHat/openafs-server.service $RPM_BUILD_ROOT%{_unitdir}/openafs-server.service
|
||||
install -m 755 src/packaging/RedHat/openafs-client-systemd-helper.sh $RPM_BUILD_ROOT%{_prefix}/vice/etc/openafs-client-systemd-helper.sh
|
||||
%endif
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -1206,6 +1207,7 @@ dkms remove -m %{name} -v %{dkms_version} --rpm_safe_upgrade --all ||:
|
||||
%{initdir}/openafs-client
|
||||
%else
|
||||
%{_unitdir}/openafs-client.service
|
||||
%{_prefix}/vice/etc/openafs-client-systemd-helper.sh
|
||||
%endif
|
||||
%{_mandir}/man1/cmdebug.1.gz
|
||||
%{_mandir}/man1/up.1.gz
|
||||
|
Loading…
Reference in New Issue
Block a user