3 # This is a simple startup script to run Citadel in a Docker container.
4 # If you know your way around Docker, you don't have to use it; feel free to do whatever you want.
5 # The container expects a persistent volume called "citadel-data" in which it will keep everything.
6 # The remainder of the container is ephermal and can be deleted at any time.
9 # Parse the command line arguments
12 database_cleanup_mode=false
16 while getopts ":mdv:h:" o
24 echo "database cleanup mode";
25 database_cleanup_mode=true
37 echo "$0: usage: $0 [-v volume_name] [-h home_directory] [-m] [-d] container_image_name"
38 echo " -v volume_name Use or create a Citadel database stored in a Docker volume called 'volume_name'"
39 echo " -h home_directory Use or create a Citadel database stored in 'home_directory' on the host system"
40 echo " -m Enter migrate mode, to copy a remote Citadel installation to this host"
41 echo " -d Attempt to recover a corrupt database"
48 if ( ${volume_mode} && ${bind_mode} ) ; then
49 echo "$0: -v and -h cannot both be specified."
53 if ${volume_mode} ; then
55 elif ${bind_mode} ; then
63 if ( ${migrate_mode} && ${database_cleanup_mode} ) ; then
64 echo "$0: -m and -d cannot both be specified."
68 docker run -it --rm $1 -c || exit 1
73 if ${migrate_mode} ; then
74 c_args="-m" # Tell ctdlvisor to run ctdlmigrate
75 elif ${database_cleanup_mode} ; then
76 c_args="-d" # Tell ctdlvisor to run database_cleanup.sh
78 n_args="--network host" # Only open ports if we're running in normal mode
86 --mount type=${CTDL_VOL},source=${CTDL_DIR},target=/citadel-data \
89 # Explanation of the above options:
91 # --name citadel Create a container named "citadel"
92 # -it Run in the foreground
93 # --rm Delete the container when it exits
94 # --network host Bind directly to the host's network ports instead of creating a separate interface
95 # --mount This identifies where on the host our persistent Citadel database is found