X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=appimage%2Fcitadel.AppDir%2FAppRun;h=b8be1cfc4679dfdd880e1c194708a87ceb813dfb;hb=8c7d148fff250e73be6c5eabdc3a3cefe4786c2f;hp=0c0ececeb600132e08d6ba843ff0abe8926908b3;hpb=9911be8b93584d582dc3aaeb3e24a9b0cbb544c0;p=citadel.git diff --git a/appimage/citadel.AppDir/AppRun b/appimage/citadel.AppDir/AppRun index 0c0ececeb..b8be1cfc4 100755 --- a/appimage/citadel.AppDir/AppRun +++ b/appimage/citadel.AppDir/AppRun @@ -1,5 +1,101 @@ #!/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 ${APPIMAGE}: usage: ${APPIMAGE} '[-h data_directory] [-p http_port] [-s https_port] command' + echo 'command must be one of: run, test, install' + exit 2 +} + + +# Permanently install the Citadel AppImage to this system +installation() { + + # First ... check to make sure Citadel isn't runnings + if ps ax | grep citserver | grep -v grep ; then + echo Installation cannot proceed while Citadel is running. + echo Stop your services and try again. + exit 1 + fi + + echo Hi + exit +} + + +PARSED_ARGUMENTS=$(getopt -o h:p:s: -- "$@") +VALID_ARGUMENTS=$? +if [ "$VALID_ARGUMENTS" != "0" ]; then + usage +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 + exec $APPDIR/usr/local/citadel/citserver -c + ;; + install) + installation + ;; + *) + 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