[lxc-devel] [lxc/master] Installation of default.script for udhcpc

Rachid-Koucha on Github lxc-bot at linuxcontainers.org
Sun Jan 27 02:39:09 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 574 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190126/f738c357/attachment-0001.bin>
-------------- next part --------------
From 1c9bca6b88e63f7de45ebf8af91d84e6fea57447 Mon Sep 17 00:00:00 2001
From: Rachid Koucha <47061324+Rachid-Koucha at users.noreply.github.com>
Date: Sun, 27 Jan 2019 03:38:36 +0100
Subject: [PATCH] Installation of default.script for udhcpc

The busybox template installs default.script in /usr/share/udhcpc/.
But the pathname of "default.script" may vary from one busybox
build to another. As the pathname is displayed in udhcpc's help,
grab it from it.

Signed-off-by: Rachid Koucha <rachid.koucha at gmail.com>
---
 templates/lxc-busybox.in | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in
index 7243b36ef8..f90fa93cc9 100644
--- a/templates/lxc-busybox.in
+++ b/templates/lxc-busybox.in
@@ -23,6 +23,8 @@
 LXC_MAPPED_UID=
 LXC_MAPPED_GID=
 
+BUSYBOX_EXE=
+
 # Make sure the usual locations are in PATH
 export PATH=$PATH:/usr/sbin:/usr/bin:/sbin:/bin
 
@@ -128,7 +130,13 @@ EOF
   # writable and readable for other
   chmod 644 "${rootfs}/etc/inittab" || return 1
 
-  cat <<EOF >> "${rootfs}/usr/share/udhcpc/default.script"
+  # Look for the pathname of "default.script" from the help of udhcpc
+  DEF_SCRIPT=`${BUSYBOX_EXE} udhcpc -h 2>&1 | grep -- '-s,--script PROG' | cut -d'/' -f2- | cut -d')' -f1`
+  DEF_SCRIPT_DIR=`dirname /${DEF_SCRIPT}`
+  mkdir -p ${rootfs}/${DEF_SCRIPT_DIR}
+  chmod 644 ${rootfs}/${DEF_SCRIPT_DIR} || return 1
+
+  cat <<EOF >> ${rootfs}/${DEF_SCRIPT}
 #!/bin/sh
 case "\$1" in
   deconfig)
@@ -162,7 +170,7 @@ esac
 exit 0
 EOF
 
- chmod 744 "${rootfs}/usr/share/udhcpc/default.script"
+ chmod 744 ${rootfs}/${DEF_SCRIPT}
 
  return "${res}"
 }
@@ -297,6 +305,13 @@ if [ -z "${name}" ] || [ -z "${path}" ] || [ -z "${rootfs}" ]; then
     exit 1
 fi
 
+# Make sure busybox is present
+BUSYBOX_EXE=`which busybox`
+if [ $? -ne 0 ]; then
+    echo "ERROR: Failed to find busybox binary"
+    exit 1
+fi
+
 # detect rootfs
 config="$path/config"
 if [ -z "$rootfs" ]; then


More information about the lxc-devel mailing list