Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel
authorArt Cancro <ajc@citadel.org>
Thu, 7 Jan 2021 19:41:58 +0000 (14:41 -0500)
committerArt Cancro <ajc@citadel.org>
Thu, 7 Jan 2021 19:41:58 +0000 (14:41 -0500)
appimage/.gitignore [new file with mode: 0644]
appimage/build_appimage.sh [new file with mode: 0755]
appimage/citadel.AppDir/.DirIcon [new symlink]
appimage/citadel.AppDir/AppRun [new file with mode: 0755]
appimage/citadel.AppDir/citadel.desktop [new file with mode: 0644]
appimage/citadel.AppDir/citadel.png [new file with mode: 0644]
appimage/ctdlvisor.c [new file with mode: 0644]

diff --git a/appimage/.gitignore b/appimage/.gitignore
new file mode 100644 (file)
index 0000000..8a7f351
--- /dev/null
@@ -0,0 +1,2 @@
+citadel.AppDir/usr
+Citadel-x86_64.AppImage
diff --git a/appimage/build_appimage.sh b/appimage/build_appimage.sh
new file mode 100755 (executable)
index 0000000..4391afc
--- /dev/null
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+rm -fr /usr/local/citadel /usr/local/webcit
+
+# Build libcitadel
+pushd ../libcitadel || exit 1
+./bootstrap || exit 1
+./configure || exit 1
+make || exit 1
+make install || exit 1
+popd
+
+# Build the Citadel server
+pushd ../citadel || exit 1
+./bootstrap || exit 1
+./configure --prefix=/usr/local/citadel || exit 1
+make || exit 1
+make install || exit 1
+popd
+
+# Build WebCit
+pushd ../webcit || exit 1
+./bootstrap || exit 1
+./configure --prefix=/usr/local/webcit || exit 1
+make || exit 1
+make install || exit 1
+popd
+
+# Build the appimage supervisor
+cc ctdlvisor.c -o ctdlvisor || exit 1
+
+# Clear out our build directories
+rm -frv citadel.AppDir/usr
+mkdir -p citadel.AppDir/usr/bin
+mkdir -p citadel.AppDir/usr/lib
+
+# Copy over all the libraries we used
+for bin in /usr/local/citadel/citserver /usr/local/webcit/webcit
+do
+       for x in `ldd $bin | awk ' { print $3 } ' | grep -v -e '^$' | grep -v 'libc.so' | grep -v 'libpthread.so' | grep -v 'libresolv.so'`
+       do
+               cp -v -L $x citadel.AppDir/usr/lib/
+       done
+done
+ldconfig -v citadel.AppDir/usr/lib
+
+# Copy over our application trees
+for x in citadel webcit
+do
+       mkdir -p citadel.AppDir/usr/local/$x
+       rsync -va /usr/local/$x/ ./citadel.AppDir/usr/local/$x/
+done
+
+cp ctdlvisor citadel.AppDir/usr/bin/
+ARCH=x86_64 appimagetool citadel.AppDir/
+rm -fr /usr/local/citadel /usr/local/webcit
diff --git a/appimage/citadel.AppDir/.DirIcon b/appimage/citadel.AppDir/.DirIcon
new file mode 120000 (symlink)
index 0000000..98ba0b2
--- /dev/null
@@ -0,0 +1 @@
+citadel.png
\ No newline at end of file
diff --git a/appimage/citadel.AppDir/AppRun b/appimage/citadel.AppDir/AppRun
new file mode 100755 (executable)
index 0000000..bb068bf
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH=$APPDIR/usr/lib
+export PATH=$APPDIR/usr/bin
+exec ctdlvisor
diff --git a/appimage/citadel.AppDir/citadel.desktop b/appimage/citadel.AppDir/citadel.desktop
new file mode 100644 (file)
index 0000000..4560c31
--- /dev/null
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Version=1.0
+Type=Application
+Categories=Network
+Terminal=true
+Exec=AppRun
+Name=Citadel
+Icon=citadel
diff --git a/appimage/citadel.AppDir/citadel.png b/appimage/citadel.AppDir/citadel.png
new file mode 100644 (file)
index 0000000..dbabbb0
Binary files /dev/null and b/appimage/citadel.AppDir/citadel.png differ
diff --git a/appimage/ctdlvisor.c b/appimage/ctdlvisor.c
new file mode 100644 (file)
index 0000000..63230af
--- /dev/null
@@ -0,0 +1,108 @@
+//
+// This is a supervisor program that handles start/stop/restart of
+// the various Citadel System components, when we are running on
+// an AppImage instance.
+//
+// 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.
+
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/wait.h>
+#include <errno.h>
+
+
+pid_t start_citadel() {
+       char bin[1024];
+       sprintf(bin, "%s/usr/local/citadel/citserver", getenv("APPDIR"));
+       pid_t pid = fork();
+       if (pid == 0) {
+               printf("Executing %s\n", bin);
+               execlp(bin, "citserver", "-x9", "-h/usr/local/citadel", NULL);
+               perror("execlp");
+               exit(errno);
+       }
+       else {
+               return(pid);
+       }
+}
+
+
+pid_t start_webcit() {
+       char bin[1024];
+       sprintf(bin, "%s/usr/local/webcit/webcit", getenv("APPDIR"));
+       pid_t pid = fork();
+       if (pid == 0) {
+               printf("Executing %s\n", bin);
+               execlp(bin, "webcit", "-x9", "-p80", "uds", "/usr/local/citadel", NULL);
+               perror("execlp");
+               exit(errno);
+       }
+       else {
+               return(pid);
+       }
+}
+
+
+pid_t start_webcits() {
+       char bin[1024];
+       sprintf(bin, "%s/usr/local/webcit/webcit", getenv("APPDIR"));
+       pid_t pid = fork();
+       if (pid == 0) {
+               printf("Executing %s\n", bin);
+               execlp(bin, "webcit", "-x9", "-s", "-p443", "uds", "/usr/local/citadel", NULL);
+               perror("execlp");
+               exit(errno);
+       }
+       else {
+               return(pid);
+       }
+}
+
+
+main() {
+       int status;
+       pid_t who_exited;
+
+       pid_t citserver_pid = start_citadel();
+       pid_t webcit_pid = start_webcit();
+       pid_t webcits_pid = start_webcits();
+
+       do {
+               printf("LD_LIBRARY_PATH = %s\n", getenv("LD_LIBRARY_PATH"));
+               printf("PATH = %s\n", getenv("PATH"));
+               printf("APPDIR = %s\n", getenv("APPDIR"));
+
+               printf("waiting...\n");
+               who_exited = waitpid(-1, &status, 0);
+               printf("pid=%d exited, status=%d\n", who_exited, status);
+
+               if (who_exited == citserver_pid) {
+                       if (WEXITSTATUS(status) == 0) {
+                               printf("ctdlvisor: citserver exited normally - ending AppImage session\n");
+                               exit(0);
+                       }
+                       citserver_pid = start_citadel();
+               }
+
+               if (who_exited == webcit_pid)           webcit_pid = start_webcit();
+               if (who_exited == webcits_pid)          webcits_pid = start_webcits();
+
+               sleep(1);                               // slow down any accidental loops
+
+       } while (who_exited >= 0);
+
+       printf("ctdlvisor: exiting.\n");
+       exit(0);
+}