Skip to content

Enabling run.sh to work with busybox 'ash' #19

Description

@PhracturedBlue

I am trying to use the run.sh script on Alpine linux (which uses busybox). I ran into 2 issues with the run.sh script:

  1. Busybox 'ash' does not have arrays like bash does
  2. Busybox tail does not support the --pid argument
  3. Busybox 'trap' does not properly handle 'EXIT' signals

I fixed (1) by manually splitting the $LAN_PARENT, and (2) by using 'docker wait'. I haven't found a good solution for (3) yet. using trap _cleanup EXIT INT TERM doesn't seem to work either. Even if I end up installing bash, the fix for (2) is still needed though.

diff --git a/run.sh b/run.sh
index a09bf3a..88c06f3 100755
--- a/run.sh
+++ b/run.sh
@@ -172,9 +172,10 @@ _prepare_network() {
 			LAN_IFACE=br-${LAN_ID:0:12}
 
 			# test if $LAN_PARENT is a VLAN of $WAN_PARENT, create it if it doesn't exist and add it to the bridge
-			local lan_array=(${LAN_PARENT//./ })
-			if [[ ${lan_array[0]} = $WAN_PARENT ]] && ! ip link show $LAN_PARENT >/dev/null 2>&1 ; then
-				sudo ip link add link ${lan_array[0]} name $LAN_PARENT type vlan id ${lan_array[1]}
+			local lan_parent_iface=$(echo $LAN_PARENT | cut -d. -f1)
+			local lan_parent_vlan=$(echo $LAN_PARENT | cut -d. -f2)
+			if [[ ${lan_parent_iface} = $WAN_PARENT ]] && ! ip link show $LAN_PARENT >/dev/null 2>&1 ; then
+				sudo ip link add link ${lan_parent_iface} name $LAN_PARENT type vlan id ${lan_parent_vlan}
 			fi
 			sudo ip link set $LAN_PARENT master $LAN_IFACE
 		;;
@@ -220,4 +221,4 @@ main() {
 
 main
 trap "_cleanup" EXIT
-tail --pid=$pid -f /dev/null
+docker wait $CONTAINER

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions