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 - Add the conman user to the group of the ttyS* devices
(boo#1081217). (boo#1081217).
- Only update config file for new user once, save backup
copy.
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Jan 10 19:27:27 UTC 2018 - eich@suse.com 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 getent group %conman_g >/dev/null || addgrp=1
[ $addgrp -eq 1 ] && groupadd -r %conman_g [ $addgrp -eq 1 ] && groupadd -r %conman_g
getent passwd %conman_u >/dev/null || addusr=1 getent passwd %conman_u >/dev/null || addusr=1
[ $addusr -eq 1 ] && useradd -r -g %conman_g ${TTYS_GRP:+-G $TTYS_GRP} \ [ $addusr -eq 1 ] && useradd -r -g %conman_g -d %conman_home \
-d %conman_home -s /bin/false -c %conman_descr %conman_u -s /bin/false -c %conman_descr %conman_u
[ $addgrp -eq 1 -a $addusr -eq 1 ] && touch %_tmppath/conman_userudate [ -n "$TTYS_GRP" ] && usermod -a -G $TTYS_GRP %conman_u
%endif %endif
exit 0 exit 0
%endif %endif
@ -183,36 +183,38 @@ exit 0
%endif %endif
%post %post
%define migrated conman_user_migrated
%fillup_only conman %fillup_only conman
%if 0%{?have_systemd} %if 0%{?have_systemd}
%{?tmpfiles_create:%{tmpfiles_create %{_tmpfilesdir}/%{name}.conf}} %{?tmpfiles_create:%{tmpfiles_create %{_tmpfilesdir}/%{name}.conf}}
%service_add_post conman.service %service_add_post conman.service
if [ -e %_tmppath/conman_userudate ] [ -d %_localstatedir/lib/conman ] || mkdir %_localstatedir/lib/conman || :
then if [ $1 -eq 2 -a ! -e %_localstatedir/lib/conman/%migrated ]; then
rm %_tmppath/conman_userudate tmpfile=$(mktemp /tmp/tmp-XXXX)
if [ $1 -eq 2 ]; then sed -e "s@^\(server\)\|\(SERVER\) \+logdir=.*@SERVER logdir=\"/var/log/%{conmandir}\"@" \
tmpfile=$(mktemp /tmp/tmp-XXXX) -e "s@^\(server\)\|\(SERVER\) \+logfile=.*@SERVER logfile=\"/var/log/%{conmandir}conman.log\"@" \
sed -e "s@^\(server\)\|\(SERVER\) \+logdir=.*@SERVER logdir=\"/var/log/%{conmandir}\"@" \ -e "s@^\(server\)\|\(SERVER\) \+pidfile=.*@SERVER pidfile=\"/var/run/%{conmandir}conman.pid\"@" \
-e "s@^\(server\)\|\(SERVER\) \+logfile=.*@SERVER logfile=\"/var/log/%{conmandir}conman.log\"@" \ < /etc/conman.conf > $tmpfile
-e "s@^\(server\)\|\(SERVER\) \+pidfile=.*@SERVER pidfile=\"/var/run/%{conmandir}conman.pid\"@" \ if ! cmp /etc/conman.conf $tmpfile; then
< /etc/conman.conf > $tmpfile mv /etc/conman.conf /etc/conman.conf.rpmsave
if ! cmp /etc/conman.conf $tmpfile; then
mv $tmpfile /etc/conman.conf mv $tmpfile /etc/conman.conf
chown %conman_u:%conman_g /etc/conman.conf chown %conman_u:%conman_g /etc/conman.conf
cat > %_localstatedir/adm/update-messages/%{name}-%{version}-%{release}-%{name}.txt <<EOF 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 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 EOF
else else
rm $tmpfile rm $tmpfile
fi
fi fi
fi fi
touch %_localstatedir/lib/conman/%migrated || :
%endif %endif
%postun %postun
%if 0%{?have_systemd} %if 0%{?have_systemd}
[ $1 -eq 0 ] && rm -rf %_localstatedir/lib/conman
%service_del_postun conman.service %service_del_postun conman.service
%else %else
%{restart_on_update conman} %{restart_on_update conman}