From: Guo Xiang Tan Date: Tue, 18 Sep 2018 09:06:20 +0000 (+0800) Subject: FEATURE: Add `./launcher run` command. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1ec142a14a08aa352ea869d17939e15ee53283b7;p=discourse_docker.git FEATURE: Add `./launcher run` command. This is useful for running custom commands with the config for a given template. --- diff --git a/launcher b/launcher index ae41c18..5b5d5dc 100755 --- a/launcher +++ b/launcher @@ -3,15 +3,16 @@ usage () { echo "Usage: launcher COMMAND CONFIG [--skip-prereqs] [--docker-args STRING]" echo "Commands:" - echo " start: Start/initialize a container" - echo " stop: Stop a running container" - echo " restart: Restart a container" - echo " destroy: Stop and remove a container" - echo " enter: Open a shell to run commands inside the container" - echo " logs: View the Docker logs for a container" - echo " bootstrap: Bootstrap a container for the config based on a template" - echo " rebuild: Rebuild a container (destroy old, bootstrap, start new)" - echo " cleanup: Remove all containers that have stopped for > 24 hours" + echo " start: Start/initialize a container" + echo " stop: Stop a running container" + echo " restart: Restart a container" + echo " destroy: Stop and remove a container" + echo " enter: Open a shell to run commands inside the container" + echo " logs: View the Docker logs for a container" + echo " bootstrap: Bootstrap a container for the config based on a template" + echo " run: Run the given command with the config for the given template." + echo " rebuild: Rebuild a container (destroy old, bootstrap, start new)" + echo " cleanup: Remove all containers that have stopped for > 24 hours" echo echo "Options:" echo " --skip-prereqs Don't check launcher prerequisites" @@ -24,6 +25,10 @@ command=$1 config=$2 user_args="" +if [[ $command == "run" ]]; then + run_command=$3 +fi + while [ ${#} -gt 0 ]; do case "${1}" in --debug) @@ -561,10 +566,7 @@ run_start() { } - -run_bootstrap() { - - # I got no frigging clue what this does, ask Sam Saffron. It RUNS STUFF ON THE HOST I GUESS? +setup_bootstrap() { host_run # Is the image available? @@ -585,7 +587,17 @@ run_bootstrap() { set_volumes set_links +} + +run_run() { + setup_bootstrap + $docker_path run --rm --shm-size=512m $user_args $links "${env[@]}" -e DOCKER_HOST_IP="$docker_ip" -i -a stdin -a stdout -a stderr $volumes $image \ + /bin/bash -c "$run_command" +} + +run_bootstrap() { + setup_bootstrap rm -f $cidbootstrap run_command="cd /pups &&" @@ -637,6 +649,11 @@ case "$command" in exit 0 ;; + run) + run_run + exit 0 + ;; + enter) exec $docker_path exec -it $config /bin/bash --login ;;