[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#18118: postgresql: postgresql modifies /etc/crontab rather than adding file



> Kevin Dalley wrote, referring to Bug#18118:
>   >It would be nice if postgresql upgrade would remove the lines from
>   >/etc/crontab which were added by previous version of postgresql.
> 
> For a while, it did.  Nevertheless, it is a violation of policy to 
> modify /etc/crontab, which is why I have taken it out.
> 
> Should I reinstate the removal?  It would add these lines to postinst:
> 
> if grep -s '^#-- postgresql begin *$' /etc/crontab
> then
> 	TMP=`mktemp /tmp/pg.XXXXXX` || exit 1
> 	awk 'BEGIN {found=0}
> /^#-- postgresql begin *$/ {found = 1}
> /^#-- postgresql end *$/ {found = -1}
> 	{if (!found) print}
> 	{if (found == -1) found=0}' /etc/crontab >$TMP
> 	if [ -f $TMP ]
> 	then
> 		mv $TMP /etc/crontab
> 	fi
> fi

sed seems like a simpler way of doing this than awk:

  sed -e '/^#-- postgresql begin /,/^#--  postgresql end /d'  \
    /etc/crontab > $TMP

BTW Is it worth worrying about broken files ?  Either method will delete
to the end of the file if the end comment is missing -- does this matter ?

Cheers, Phil.



--
To UNSUBSCRIBE, email to debian-policy-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: