Accepting request 577586 from home:eeich:branches:network:cluster

- Only update config file for new user once, save backup
  copy.

OBS-URL: https://build.opensuse.org/request/show/577586
OBS-URL: https://build.opensuse.org/package/show/network:cluster/conman?expand=0&rev=23
This commit is contained in:
Egbert Eich 2018-02-17 11:05:48 +00:00 committed by Git OBS Bridge
parent 03841e12c5
commit c15b3b7c58
2 changed files with 21 additions and 17 deletions

View File

@ -3,6 +3,8 @@ Fri Feb 16 13:15:00 UTC 2018 - eich@suse.com
- Add the conman user to the group of the ttyS* devices
(boo#1081217).
- Only update config file for new user once, save backup
copy.
-------------------------------------------------------------------
Wed Jan 10 19:27:27 UTC 2018 - eich@suse.com

View File

@ -168,9 +168,9 @@ addgrp=0; addusr=0
getent group %conman_g >/dev/null || addgrp=1
[ $addgrp -eq 1 ] && groupadd -r %conman_g
getent passwd %conman_u >/dev/null || addusr=1
[ $addusr -eq 1 ] && useradd -r -g %conman_g ${TTYS_GRP:+-G $TTYS_GRP} \
-d %conman_home -s /bin/false -c %conman_descr %conman_u
[ $addgrp -eq 1 -a $addusr -eq 1 ] && touch %_tmppath/conman_userudate
[ $addusr -eq 1 ] && useradd -r -g %conman_g -d %conman_home \
-s /bin/false -c %conman_descr %conman_u
[ -n "$TTYS_GRP" ] && usermod -a -G $TTYS_GRP %conman_u
%endif
exit 0
%endif
@ -183,36 +183,38 @@ exit 0
%endif
%post
%define migrated conman_user_migrated
%fillup_only conman
%if 0%{?have_systemd}
%{?tmpfiles_create:%{tmpfiles_create %{_tmpfilesdir}/%{name}.conf}}
%service_add_post conman.service
if [ -e %_tmppath/conman_userudate ]
then
rm %_tmppath/conman_userudate
if [ $1 -eq 2 ]; then
tmpfile=$(mktemp /tmp/tmp-XXXX)
sed -e "s@^\(server\)\|\(SERVER\) \+logdir=.*@SERVER logdir=\"/var/log/%{conmandir}\"@" \
-e "s@^\(server\)\|\(SERVER\) \+logfile=.*@SERVER logfile=\"/var/log/%{conmandir}conman.log\"@" \
-e "s@^\(server\)\|\(SERVER\) \+pidfile=.*@SERVER pidfile=\"/var/run/%{conmandir}conman.pid\"@" \
< /etc/conman.conf > $tmpfile
if ! cmp /etc/conman.conf $tmpfile; then
[ -d %_localstatedir/lib/conman ] || mkdir %_localstatedir/lib/conman || :
if [ $1 -eq 2 -a ! -e %_localstatedir/lib/conman/%migrated ]; then
tmpfile=$(mktemp /tmp/tmp-XXXX)
sed -e "s@^\(server\)\|\(SERVER\) \+logdir=.*@SERVER logdir=\"/var/log/%{conmandir}\"@" \
-e "s@^\(server\)\|\(SERVER\) \+logfile=.*@SERVER logfile=\"/var/log/%{conmandir}conman.log\"@" \
-e "s@^\(server\)\|\(SERVER\) \+pidfile=.*@SERVER pidfile=\"/var/run/%{conmandir}conman.pid\"@" \
< /etc/conman.conf > $tmpfile
if ! cmp /etc/conman.conf $tmpfile; then
mv /etc/conman.conf /etc/conman.conf.rpmsave
mv $tmpfile /etc/conman.conf
chown %conman_u:%conman_g /etc/conman.conf
cat > %_localstatedir/adm/update-messages/%{name}-%{version}-%{release}-%{name}.txt <<EOF
The conman configuration in %_sysconfdir/conman.conf has been updated to the new pid and log
directory. Please check this file to make sure it is correct.
directory. Please check this file to make sure it is correct. The original version is available
in /etc/conman.conf.rpmsave.
EOF
else
rm $tmpfile
fi
else
rm $tmpfile
fi
fi
touch %_localstatedir/lib/conman/%migrated || :
%endif
%postun
%if 0%{?have_systemd}
[ $1 -eq 0 ] && rm -rf %_localstatedir/lib/conman
%service_del_postun conman.service
%else
%{restart_on_update conman}