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 database_cleanup_mode=false
13 # Parse the command line arguments
14 while getopts ":mdv:h:" o
22 echo "database cleanup mode";
23 database_cleanup_mode=true
35 echo "$0: usage: $0 [-v volume_name] [-h home_directory] [-m] [-d] container_image_name"
36 echo " -v volume_name Use or create a Citadel database stored in a Docker volume called 'volume_name'"
37 echo " -h home_directory Use or create a Citadel database stored in 'home_directory' on the host system"
38 echo " -m Enter migrate mode, to copy a remote Citadel installation to this host"
39 echo " -d Attempt to recover a corrupt database"
46 if ( ${volume_mode} && ${bind_mode} ) ; then
47 echo "$0: -v and -h cannot both be specified."
51 if ${volume_mode} ; then
53 elif ${bind_mode} ; then
58 CTDL_DIR=/usr/local/citadel
59 mkdir /usr/local/citadel >/dev/null 2>/dev/null
62 if ( ${migrate_mode} && ${database_cleanup_mode} ) ; then
63 echo "$0: -m and -d cannot both be specified."
67 docker run -i --rm citadel -c || exit 1
72 if ${migrate_mode} ; then
73 c_args="-m" # Tell ctdlvisor to run ctdlmigrate
74 elif ${database_cleanup_mode} ; then
75 c_args="-d" # Tell ctdlvisor to run database_cleanup.sh
77 n_args="--network=host" # Only open ports if we're running in normal mode
85 --mount type=${CTDL_VOL},source=${CTDL_DIR},target=/citadel-data \