summaryrefslogtreecommitdiff
path: root/helpers/lh_confignetwork
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/lh_confignetwork')
-rwxr-xr-xhelpers/lh_confignetwork60
1 files changed, 60 insertions, 0 deletions
diff --git a/helpers/lh_confignetwork b/helpers/lh_confignetwork
new file mode 100755
index 000000000..892020df2
--- /dev/null
+++ b/helpers/lh_confignetwork
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+# lh_patchnetwork.sh <action>
+
+# Packages which are manually installed inside the chroot are installed
+# from the network. Therefore, we need to be able to resolv hosts.
+
+case "${1}" in
+ apply-hosts)
+ # Save host lookup table
+ if [ -f "${LIVE_CHROOT}"/etc/hosts ]
+ then
+ cp "${LIVE_CHROOT}"/etc/hosts \
+ "${LIVE_CHROOT}"/etc/hosts.orig
+ fi
+
+ # Copy host lookup table
+ if [ -f /etc/hosts ]
+ then
+ cp /etc/hosts "${LIVE_CHROOT}"/etc/hosts
+ fi
+ ;;
+
+ apply-resolv)
+ # Save resolver configuration
+ if [ -f "${LIVE_CHROOT}"/etc/resolv.conf ]
+ then
+ cp "${LIVE_CHROOT}"/etc/resolv.conf \
+ "${LIVE_CHROOT}"/etc/resolv.conf.orig
+ fi
+
+ # Copy resolver configuration
+ if [ -f /etc/resolv.conf ]
+ then
+ cp /etc/resolv.conf "${LIVE_CHROOT}"/etc/resolv.conf
+ fi
+ ;;
+
+ deapply-hosts)
+ # Restore host lookup table
+ if [ -f "${LIVE_CHROOT}"/etc/hosts.orig ]
+ then
+ mv "${LIVE_CHROOT}"/etc/hosts.orig \
+ "${LIVE_CHROOT}"/etc/hosts
+ else
+ rm -f "${LIVE_CHROOT}"/etc/hosts
+ fi
+ ;;
+
+ deapply-resolv)
+ # Restore resolver configuration
+ if [ -f "${LIVE_CHROOT}"/etc/resolv.conf.orig ]
+ then
+ mv "${LIVE_CHROOT}"/etc/resolv.conf.orig \
+ "${LIVE_CHROOT}"/etc/resolv.conf
+ else
+ rm -f "${LIVE_CHROOT}"/etc/resolv.conf
+ fi
+ ;;
+esac