mirror of
https://github.com/ggogel/seafile-containerized.git
synced 2024-11-16 09:01:38 +00:00
launcher: support serveral command line flags.
This commit is contained in:
parent
4a04b0cb5d
commit
e7871f5ede
43
launcher
43
launcher
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
usage () {
|
usage () {
|
||||||
echo "Usage: launcher COMMAND CONFIG [--skip-prereqs] [--docker-args STRING]"
|
echo "Usage: launcher COMMAND [--skip-prereqs] [--docker-args STRING]"
|
||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
echo " start: Start/initialize a container"
|
echo " start: Start/initialize a container"
|
||||||
echo " stop: Stop a running container"
|
echo " stop: Stop a running container"
|
||||||
|
@ -16,7 +16,6 @@ usage () {
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " --skip-prereqs Don't check launcher prerequisites"
|
echo " --skip-prereqs Don't check launcher prerequisites"
|
||||||
echo " --docker-args Extra arguments to pass when running docker"
|
echo " --docker-args Extra arguments to pass when running docker"
|
||||||
echo " --skip-mac-address Don't assign a mac address"
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +63,7 @@ init_shared() {
|
||||||
}
|
}
|
||||||
|
|
||||||
set_ports() {
|
set_ports() {
|
||||||
ports=$(docker run --rm -it \
|
ports=$(docker run $user_args --rm -it \
|
||||||
-v ${dockerdir}/scripts:/scripts \
|
-v ${dockerdir}/scripts:/scripts \
|
||||||
-v ${dockerdir}/bootstrap:/bootstrap:ro \
|
-v ${dockerdir}/bootstrap:/bootstrap:ro \
|
||||||
$image \
|
$image \
|
||||||
|
@ -122,7 +121,7 @@ bootstrap() {
|
||||||
set_bootstrap_volumes
|
set_bootstrap_volumes
|
||||||
set_ports
|
set_ports
|
||||||
|
|
||||||
docker run --rm -it --name seafile-bootstrap -e SEAFILE_BOOTSRAP=1 $volumes $ports $image /sbin/my_init -- /scripts/bootstrap.py
|
docker run $user_args --rm -it --name seafile-bootstrap -e SEAFILE_BOOTSRAP=1 $volumes $ports $image /sbin/my_init -- /scripts/bootstrap.py
|
||||||
|
|
||||||
docker build -f bootstrap/generated/Dockerfile -t local_seafile/server:latest .
|
docker build -f bootstrap/generated/Dockerfile -t local_seafile/server:latest .
|
||||||
}
|
}
|
||||||
|
@ -130,7 +129,7 @@ bootstrap() {
|
||||||
oldstart() {
|
oldstart() {
|
||||||
set_volumes
|
set_volumes
|
||||||
set_ports
|
set_ports
|
||||||
docker run --rm -it --name seafile $volumes $ports $image \
|
docker run $user_args --rm -it --name seafile $volumes $ports $image \
|
||||||
/sbin/my_init -- bash -l
|
/sbin/my_init -- bash -l
|
||||||
# /sbin/my_init -- /scripts/start.py
|
# /sbin/my_init -- /scripts/start.py
|
||||||
}
|
}
|
||||||
|
@ -155,9 +154,18 @@ start() {
|
||||||
set_volumes
|
set_volumes
|
||||||
set_ports
|
set_ports
|
||||||
|
|
||||||
|
|
||||||
|
local restart_policy attach_on_run
|
||||||
|
if [[ "${SUPERVISED}" = "true" ]]; then
|
||||||
|
restart_policy="--restart=no"
|
||||||
|
attach_on_run="-a stdout -a stderr"
|
||||||
|
else
|
||||||
|
attach_on_run="-d"
|
||||||
|
fi
|
||||||
|
|
||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
docker run -d -it --name seafile $volumes $ports $local_image
|
docker run $user_args $attach_on_run $restart_policy --name seafile $volumes $ports $local_image
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,9 +201,27 @@ restart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
check_prereqs() {
|
check_prereqs() {
|
||||||
|
if [[ $skip_prereqs == "true" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check docker
|
||||||
if ! which docker >/dev/null; then
|
if ! which docker >/dev/null; then
|
||||||
install_docker
|
install_docker
|
||||||
fi
|
fi
|
||||||
|
# TODO: check git version
|
||||||
|
}
|
||||||
|
|
||||||
|
logs() {
|
||||||
|
err_and_quit "Not implemented yet"
|
||||||
|
}
|
||||||
|
|
||||||
|
destroy() {
|
||||||
|
err_and_quit "Not implemented yet"
|
||||||
|
}
|
||||||
|
|
||||||
|
rebuild() {
|
||||||
|
err_and_quit "Not implemented yet"
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
@ -203,10 +229,11 @@ main() {
|
||||||
while [[ $# -gt 0 ]]
|
while [[ $# -gt 0 ]]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
bootstrap|oldstart|start|stop|restart|enter)
|
bootstrap|oldstart|start|stop|restart|enter|destroy|logs|rebuild)
|
||||||
action=$1 ; shift 1 ;;
|
action=$1 ; shift 1 ;;
|
||||||
--debug) debug=true ; shift 1 ;;
|
--debug) debug=true ; shift 1 ;;
|
||||||
# --dummy) dummy=$2 ; shift 2 ;;
|
--skip-prereqs) skip_prereqs=true ; shift 1 ;;
|
||||||
|
--docker-args) user_args=$2 ; shift 2 ;;
|
||||||
*) err_and_quit "Argument error. Please see help." ;;
|
*) err_and_quit "Argument error. Please see help." ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue