+ echo Ready to install ${APPIMAGE} in ${CTDL_DIR}
+ echo Copying the AppImage...
+ rm -f ${CTDL_DIR}/citadel.appimage 2>/dev/null
+ cp ${APPIMAGE} ${CTDL_DIR}/citadel.appimage || {
+ echo Installation has failed with error code $? .
+ exit 4
+ }
+
+ echo Creating the systemd unit file...
+ (
+ echo '# This unit file starts all Citadel services via the AppImage distribution.'
+ echo '# Automatically installed on' `date`
+ echo ''
+ echo '[Unit]'
+ echo 'Description=Citadel'
+ echo 'After=network.target'
+ echo ''
+ echo '[Service]'
+ echo 'ExecStart='${CTDL_DIR}'/citadel.appimage run -h '${CTDL_DIR}' -p '${HTTP_PORT}' -s '${HTTPS_PORT}
+ echo 'ExecStop=/bin/kill $MAINPID'
+ echo 'KillMode=process'
+ echo 'Restart=on-failure'
+ echo 'LimitCORE=infinity'
+ echo ''
+ echo '[Install]'
+ echo 'WantedBy=multi-user.target'
+ ) >/etc/systemd/system/citadel.service || {
+ echo Installation has failed with error code $? .
+ exit 5
+ }
+ echo OK
+ echo
+
+ echo Enabling the service...
+ systemctl enable citadel || {
+ echo Installation has failed with error code $? .
+ exit 6
+ }
+ echo OK
+ echo
+
+ echo Starting the service...
+ systemctl start citadel || {
+ echo Installation has failed with error code $? .
+ exit 6
+ }
+ echo OK
+ echo
+
+ echo Installation has completed.
+ echo Please continue by browsing to http://`hostname`:${HTTP_PORT}