[xen-tools-dev] [PATCH] Test file before modifying
Stéphane Jourdois
sjourdois at gmail.com
Sun Jul 11 15:38:52 CEST 2010
This shuts down errors during t/hook-inittab.t proving, and does
not modify hook during real run.
---
hooks/intrepid/30-disable-gettys | 8 +++++---
hooks/karmic/30-disable-gettys | 8 +++++---
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/hooks/intrepid/30-disable-gettys b/hooks/intrepid/30-disable-gettys
index 8b14381..333b61e 100755
--- a/hooks/intrepid/30-disable-gettys
+++ b/hooks/intrepid/30-disable-gettys
@@ -27,9 +27,11 @@ logMessage Script $0 starting
#
# Remove the links for upstart
#
-rm ${prefix}/etc/event.d/tty[!1]
-sed -i -e s/tty1/hvc0/ ${prefix}/etc/event.d/tty1
-mv ${prefix}/etc/event.d/tty1 ${prefix}/etc/event.d/hvc0
+rm -f ${prefix}/etc/event.d/tty[!1]
+[ -f ${prefix}/etc/event.d/tty1 ] && {
+ sed -i -e s/tty1/hvc0/ ${prefix}/etc/event.d/tty1
+ mv ${prefix}/etc/event.d/tty1 ${prefix}/etc/event.d/hvc0
+}
[ -f ${prefix}/etc/inittab ] && sed -i -e 's/^\([2-6].*:respawn*\)/#\1/' -e 's/^T/#\t/' -e 's/tty1$/hvc0/' ${prefix}/etc/inittab
#
diff --git a/hooks/karmic/30-disable-gettys b/hooks/karmic/30-disable-gettys
index c471be9..6752e0c 100755
--- a/hooks/karmic/30-disable-gettys
+++ b/hooks/karmic/30-disable-gettys
@@ -27,9 +27,11 @@ logMessage Script $0 starting
#
# Remove the links for upstart
#
-rm ${prefix}/etc/init/tty[!1].conf
-sed -i -e s/tty1/hvc0/ ${prefix}/etc/init/tty1.conf
-mv ${prefix}/etc/init/tty1.conf ${prefix}/etc/init/hvc0.conf
+rm -f ${prefix}/etc/init/tty[!1].conf
+[ -f ${prefix}/etc/event.d/tty1 ] && {
+ sed -i -e s/tty1/hvc0/ ${prefix}/etc/init/tty1.conf
+ mv ${prefix}/etc/init/tty1.conf ${prefix}/etc/init/hvc0.conf
+}
[ -f ${prefix}/etc/inittab ] && sed -i -e 's/^\([2-6].*:respawn*\)/#\1/' -e 's/^T/#\t/' -e 's/tty1$/hvc0/' ${prefix}/etc/inittab
#
--
1.5.6.5
More information about the xen-tools-dev
mailing list