On 04/30/2013 04:58 PM, Igor Podlesny wrote:
-- Here-doc is generally more readable/writeable way to implement
"patterns" in SHELL.
indeed
---
etc/dists/scripts/debian-add_ip.sh | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/etc/dists/scripts/debian-add_ip.sh
b/etc/dists/scripts/debian-add_ip.sh
index 2ba555a..153e67d 100755
--- a/etc/dists/scripts/debian-add_ip.sh
+++ b/etc/dists/scripts/debian-add_ip.sh
@@ -47,7 +47,8 @@ setup_network()
"${CFGFILE}-$(date --rfc-3339=seconds).bak"
}
- echo "# This configuration file is auto-generated.
+ cat > "$CFGFILE" <<__ETC_NET_INT__
+# This configuration file is auto-generated.
#
# $dont_edit, your changes will be lost.
# Please create/edit $CFGFILE.head and
@@ -57,7 +58,7 @@ setup_network()
# NOTE: it is NOT guaranteed that the contents of $CFGFILE.tail
# will be at the very end of this file.
#
-" > ${CFGFILE}
+__ETC_NET_INT__
if [ -f ${CFGFILE}.head ]; then
cat ${CFGFILE}.head >> ${CFGFILE}
@@ -84,7 +85,7 @@ iface ${LOOPBACK} inet loopback" >> ${CFGFILE}
if [ -n "${IP_ADDR}" ]; then
# Set up venet0
- echo "
+ cat >> "$CFGFILE" <<__VENET__
# Auto generated ${VENET_DEV} interface
I think you accidentally removed an empty line here.
auto ${VENET_DEV}
iface ${VENET_DEV} inet manual
@@ -93,7 +94,7 @@ iface ${VENET_DEV} inet manual
up route add default dev ${VENET_DEV}
down route del default dev ${VENET_DEV}
down ifconfig ${VENET_DEV} down
-" >> ${CFGFILE}
+__VENET__
if [ "${IPV6}" = "yes" ]; then
echo "
Overall looks good, although you don't have to have unique identifiers
for here-doc delimiters, something like EOF should work just fine.
Also please make sure checkbashism script is OK with your changes;
one day I found out that it doesn't like delimiters such as -EOF-
(see commit 845a257).
PS would be great if you next iteration with have v3 added, and
be a reply to this email, so it's easier to track. Same for other stuff
you send.
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel