diff options
author | 2019-07-15 13:48:22 +0200 | |
---|---|---|
committer | 2019-07-15 13:53:27 +0200 | |
commit | 69df69393d605f53c39b4f4f3a824856aa6c7354 (patch) | |
tree | 0685aa5c56c1a9f518126e20d5d0c923feb0d621 | |
parent | 7a8627fd5002ae832e902fcc9ceeae846a1531b8 (diff) |
Add option to enable binding port on tftp/nbd.halibut_8.0.0halibut/8.0.08.0.0
- binding on tftp and nbd should be optional.
If user have a local tftp or nbd serveur,
the container will be in conflict with it.
- port 69/udp must be fix, is useless to start
a tftp server on an other port.
Signed-off-by: ronan <ronan.lemartret@iot.bzh>
Change-Id: I5c60a70d1d3a94b6cf894b0fe58d5212ad415609
-rwxr-xr-x | contrib/create_container | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/contrib/create_container b/contrib/create_container index ca22f32..64fd28c 100755 --- a/contrib/create_container +++ b/contrib/create_container @@ -20,23 +20,45 @@ CURDIR=$(cd $(dirname $0) && pwd -P) PREFIX=agl-worker DEFIMAGE=$(make -s -C $CURDIR/.. show-image) OCCUPIED_ID=$(docker ps -a -f name=${PREFIX} --format "{{.Names}}" | grep -oE "[0-9]" | sort -n | sed ':a;N;$!ba;s/\n/ /g') +BOOTSRV="" +ID="" +IMAGE="" function usage() { - echo "Usage: $(basename $0) <instance ID> [image name]" >&2 + echo "Usage: $(basename $0) <instance ID> [image name] [--enable-boot-srv]" >&2 echo "Instance ID must be 0 or a positive integer (1,2,...)" >&2 echo "Image name is optional: 'make show-image' is used by default to get image" >&2 + echo "--enable-boot-srv: Enable binding tftp/nbd port." >&2 echo "Default image: $DEFIMAGE" >&2 exit 1 } -case $1 in - -h|--help|"") - usage - ;; -esac +while [ $# -ne 0 ]; do + case $1 in + -h|--help|"") + usage + ;; + --enable-boot-srv) + BOOTSRV="TRUE"; + shift + ;; + *) + if [ -z "${ID}" ] ; then + ID=$1 + shift + elif [ -z "${IMAGE}" ] ; then + IMAGE=$1 + shift + else + usage + fi + ;; + esac +done -ID=$1 -IMAGE=${2:-$DEFIMAGE} +if [ -z "${IMAGE}" ] ; then + IMAGE=${DEFIMAGE} +fi USER=$(id -un) echo "Using instance ID #$ID (user $(id -un))" @@ -60,15 +82,19 @@ SHAREDDIR=$HOME/ssd/share SSH_PORT=$((2222 + ID)) WWW_PORT=$((8000 + ID)) -BOOT_PORT=$((69 + ID)) -NBD_PORT=$((10809 + ID)) +BOOT_PORT=69 +NBD_PORT=10809 mkdir -p $MIRRORDIR $XDTDIR $SHAREDDIR + +if [ -n "${BOOTSRV}" ] ; then + BOOTSRV_CONFIG="--publish=${BOOT_PORT}:69/udp --publish=${NBD_PORT}:10809"; +fi + docker run \ --publish=${SSH_PORT}:22 \ --publish=${WWW_PORT}:8000 \ - --publish=${BOOT_PORT}:69/udp \ - --publish=${NBD_PORT}:10809 \ + ${BOOTSRV_CONFIG} \ --detach=true \ --hostname=$NAME --name=$NAME \ --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro \ @@ -77,6 +103,11 @@ docker run \ -v $XDTDIR:/xdt \ -it $IMAGE +if [ $? -ne 0 ]; then + echo "Failed to run docker" + exit 1 +fi + echo "Copying your identity to container $NAME" #wait ssh service echo -n wait ssh service . |