From c15b3b7c583eaa19c7fd5f75550ce16d9e0b421e8d87d769d92ca2e07646f0b4 Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Sat, 17 Feb 2018 11:05:48 +0000 Subject: [PATCH] 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 --- conman.changes | 2 ++ conman.spec | 36 +++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/conman.changes b/conman.changes index db551c3..81d85e4 100644 --- a/conman.changes +++ b/conman.changes @@ -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 diff --git a/conman.spec b/conman.spec index 417d543..64ef5bd 100644 --- a/conman.spec +++ b/conman.spec @@ -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 <