[Devel] Backup VE's network config file if it lacks of DON'T EDIT warning
Igor Podlesny
openvz at poige.ru
Sun Apr 28 20:31:46 PDT 2013
---
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'
+ [ -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.
--
1.7.9.5
More information about the Devel
mailing list