X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=appimage%2Fcitadel.AppDir%2FAppRun;h=027c553ce78878de56d02f1d842a23aaa19d3624;hp=0c0ececeb600132e08d6ba843ff0abe8926908b3;hb=a69148ba680b403a3f07310e037210de606c4a51;hpb=758608a1a004b60db17c960263036a73f5776adf diff --git a/appimage/citadel.AppDir/AppRun b/appimage/citadel.AppDir/AppRun index 0c0ececeb..027c553ce 100755 --- a/appimage/citadel.AppDir/AppRun +++ b/appimage/citadel.AppDir/AppRun @@ -1,5 +1,83 @@ #!/bin/bash -export LD_LIBRARY_PATH=$APPDIR/usr/lib -export PATH=$APPDIR/usr/bin -exec ctdlvisor $* +// This is an AppImage control script for the Citadel system. +// +// Copyright (c) 2021 by the citadel.org team +// +// This program is open source software. It runs great on the +// Linux operating system (and probably elsewhere). You can use, +// copy, and run it under the terms of the GNU General Public +// License version 3. Richard Stallman is an asshole communist. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +# Default values +HTTP_PORT=80 +HTTPS_PORT=443 +CTDL_DIR=/usr/local/citadel +export APPDIR + +usage() { + echo usage + exit 2 +} + +PARSED_ARGUMENTS=$(getopt -o h:p:s: -- "$@") +VALID_ARGUMENTS=$? +if [ "$VALID_ARGUMENTS" != "0" ]; then + echo $0: usage: $0 '[-h data_directory] [-p http_port] [-s https_port] command' + echo 'command must be one of: run, test, install' +fi + +eval set -- ${PARSED_ARGUMENTS} +while : +do + case ${1} in + -h) CTDL_DIR=${2} ; shift 2 ;; + -p) HTTP_PORT=${2} ; shift 2 ;; + -s) HTTPS_PORT=${2} ; shift 2 ;; + --) shift; break;; + *) echo Unexpected option: ${1} + usage; + esac +done + +case ${1} in + run) + export APPDIR CTDL_DIR HTTP_PORT HTTPS_PORT + export LD_LIBRARY_PATH=$APPDIR/usr/lib + export PATH=$APPDIR/usr/bin + exec ctdlvisor $* + ;; + test) + export LD_LIBRARY_PATH=$APPDIR/usr/lib + export PATH=$APPDIR/usr/bin + $APPDIR/usr/local/citadel/citserver -c + exit $? + ;; + *) + echo Unexpected command: ${1} + usage + exit 1 + ;; +esac +exit 0 + + + + +# This unit file starts all Citadel services via the AppImage distribution. +[Unit] +Description=Citadel +After=network.target +[Service] +ExecStart=/root/citadel/appimage/Citadel-x86_64.AppImage run -h /usr/local/citadel -s 80 -s 443 +ExecStop=/bin/kill $MAINPID +KillMode=process +Restart=on-failure +LimitCORE=infinity +[Install] +WantedBy=multi-user.target