From 72199c88dedef3f6c7a08d27bafb1e51f1e9458a Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 10 Aug 2021 23:50:30 -0400 Subject: [PATCH] Added a systemd unit file to the distribution --- citadel.service | 17 +++++++++++++++++ run-citadel.sh | 24 ++++++++---------------- 2 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 citadel.service diff --git a/citadel.service b/citadel.service new file mode 100644 index 0000000..4fcdc5c --- /dev/null +++ b/citadel.service @@ -0,0 +1,17 @@ +# Put this in /etc/systemd/system/citadel.service for the easiest installation ever! + +[Unit] +Description=Citadel Server +After=network.target +Requires=docker.service +ExecStartPre=-/usr/bin/mkdir /usr/local/citadel + +[Service] +ExecStart=/usr/bin/docker run -i --rm --network host --volume=/usr/local/citadel:/citadel-data citadeldotorg/citadel:latest +ExecReload=/bin/kill +KillMode=process +Restart=on-failure +LimitCORE=infinity + +[Install] +WantedBy=multi-user.target diff --git a/run-citadel.sh b/run-citadel.sh index 398c779..8b1ede5 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 @@ -56,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 @@ -65,7 +64,7 @@ if ( ${migrate_mode} && ${database_cleanup_mode} ) ; then exit 3 fi -docker run -it --rm $1 -c || exit 1 +docker run -i --rm citadel -c || exit 1 n_args="" c_args="" @@ -80,16 +79,9 @@ fi exec docker run \ --name citadel \ - -it \ + -i \ --rm \ ${n_args} \ --mount type=${CTDL_VOL},source=${CTDL_DIR},target=/citadel-data \ - $1 ${c_args} - -# 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} -- 2.30.2