X-Git-Url: https://code.citadel.org/?p=citadel-docker.git;a=blobdiff_plain;f=run-citadel.sh;h=f021bf5e52e8f7099a06dd41ab79cf10f9a1f8a7;hp=a763998e9862f83a88494d17e862f17e966cfcb5;hb=HEAD;hpb=f8943c6f2597101db46064435ef6a2af09cd0d79 diff --git a/run-citadel.sh b/run-citadel.sh index a763998..3372da6 100755 --- a/run-citadel.sh +++ b/run-citadel.sh @@ -5,14 +5,12 @@ # The container expects a persistent volume called "citadel-data" in which it will keep everything. # The remainder of the container is ephermal and can be deleted at any time. - -# Parse the command line arguments - migrate_mode=false database_cleanup_mode=false volume_mode=false bind_mode=false +# Parse the command line arguments while getopts ":mdv:h:" o do case "${o}" in @@ -33,7 +31,12 @@ do CTDL_DIR=${OPTARG} ;; *) - echo "$0: usage: $0 [-v volume_name] [-h home_directory] [-m] [-v] container_image_name [other parameters]" + echo + echo "$0: usage: $0 [-v volume_name] [-h home_directory] [-m] [-d] container_image_name" + echo " -v volume_name Use or create a Citadel database stored in a Docker volume called 'volume_name'" + echo " -h home_directory Use or create a Citadel database stored in 'home_directory' on the host system" + echo " -m Enter migrate mode, to copy a remote Citadel installation to this host" + echo " -d Attempt to recover a corrupt database" exit 1 ;; esac @@ -51,8 +54,9 @@ elif ${bind_mode} ; then CTDL_VOL=bind else volume_mode=true - CTDL_VOL=volume - CTDL_DIR=citadel-data + CTDL_VOL=bind + CTDL_DIR=/usr/local/citadel + mkdir /usr/local/citadel >/dev/null 2>/dev/null fi if ( ${migrate_mode} && ${database_cleanup_mode} ) ; then @@ -60,23 +64,24 @@ if ( ${migrate_mode} && ${database_cleanup_mode} ) ; then exit 3 fi -docker version >/dev/null 2>&1 || { - echo Docker engine is not installed on this host. - exit 1 -} +docker run -i --rm citadel -c || exit 1 + +n_args="" +c_args="" + +if ${migrate_mode} ; then + c_args="-m" # Tell ctdlvisor to run ctdlmigrate +elif ${database_cleanup_mode} ; then + c_args="-d" # Tell ctdlvisor to run database_cleanup.sh +else + n_args="--network=host" # Only open ports if we're running in normal mode +fi exec docker run \ - --name citadel \ - -it \ + --name=citadel \ + -i \ --rm \ - --network host \ + ${n_args} \ --mount type=${CTDL_VOL},source=${CTDL_DIR},target=/citadel-data \ - $* - -# Explanation of the above options: -# -# --name citadel Create a container named "citadel" -# -it Run in the foreground -# --rm Delete the container when it exits -# --network host Bind directly to the host's network ports instead of creating a separate interface -# --mount This identifies where on the host our persistent Citadel database is found + citadel \ + ${c_args}