[Devel] Backup VE's network config file if it lacks of DON'T EDIT warning

Kir Kolyshkin kir at openvz.org
Sun Apr 28 21:28:12 PDT 2013


On 04/28/2013 08:31 PM, Igor Podlesny wrote:
> ---
>   etc/dists/scripts/debian-add_ip.sh |   11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/etc/dists/scripts/debian-add_ip.sh b/etc/dists/scripts/debian-add_ip.sh
> index 0fb1f36..80e8e73 100755
> --- a/etc/dists/scripts/debian-add_ip.sh
> +++ b/etc/dists/scripts/debian-add_ip.sh
> @@ -38,9 +38,18 @@ fix_networking_conf()
>   
>   setup_network()
>   {
> +	DONT_EDIT='WARNING: Do not edit this file'

1 please mark it as local
2 please use lowercase for local variables (and uppercase for global ones)

so s/DONT_EDIT/local dont_edit/g

> +	[ -r "$CFGFILE" ] &&
> +		head -n20 "$CFGFILE" | fgrep -q -- "$DONT_EDIT" || {
> +			# -- It has no our warning inside, so we'd better
> +			# back it up:
> +			cp "$CFGFILE" \
> +				"${CFGFILE}-$(date --rfc-3339=seconds).bak"
> +		}
> +
>   	echo "# This configuration file is auto-generated.
>   #
> -# WARNING: Do not edit this file, your changes will be lost.
> +# $DONT_EDIT, your changes will be lost.
>   # Please create/edit $CFGFILE.head and
>   # $CFGFILE.tail instead, their contents will be
>   # inserted at the beginning and at the end of this file, respectively.





More information about the Devel mailing list