4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 cd "$(dirname "$0")"/..
22 CONT_NAME="remote-installer"
26 IMG_NAME="remote-installer"
38 echo -e "$(basename $0) [-h -a <api-port> -c <cont> -i <image> -r <pw> -s <https-port> ] -b <basedir> -e <ip-addr>"
39 echo -e " -h display this help"
40 echo -e " -a rest API port, default $API_PORT"
41 echo -e " -b base directory, which contains images, certificates, etc."
42 echo -e " -c container name, default $CONT_NAME"
43 echo -e " -d use docker bridged networking, default host"
44 echo -e " -e external ip address of the docker"
45 echo -e " -i image name, default $IMG_NAME"
46 echo -e " -l login port for ssh, default $SSH_NAME"
47 echo -e " -p root password, default $ROOT_PW"
48 echo -e " -s secure https port, default $HTTPS_PORT"
51 while getopts "ha:b:de:l:s:c:p:i:" arg; do
85 error "Unknow argument!" showhelp
90 [ -n "$EXT_IP" ] || error "No external IP defined!" showhelp
91 [ -n "$BASE_DIR" ] || error "No base directory defined!" showhelp
93 DOCKER_ENV="--env API_PORT=$API_PORT \
94 --env HOST_ADDR=$EXT_IP \
95 --env HTTPS_PORT=$HTTPS_PORT \
97 --env SSH_PORT=$SSH_PORT "
100 if [ -n "$DOCKER_BRIDGE" ]
102 echo -e "Start container with bridged networking..."
103 cont_id="$(docker run --detach --rm --privileged \
106 --volume "$BASE_DIR":/opt/remoteinstaller \
107 --publish "$HTTPS_PORT":"$HTTPS_PORT" --publish 2049:2049 --publish "$API_PORT":"$API_PORT" \
108 --name "$CONT_NAME" "$IMG_NAME")" \
109 || error "failed to start container"
110 echo -e "IP : $(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$cont_id")"
113 echo -e "Start container with host networking..."
114 cont_id="$(docker run --detach --rm --privileged \
117 --volume "$BASE_DIR":/opt/remoteinstaller \
118 --name "$CONT_NAME" "$IMG_NAME")" \
119 || error "failed to start container"
121 echo -e "Container successfully started"
122 echo -e "ID : $cont_id"
123 echo -e "Using ssh port : $SSH_PORT"