working on ctdlmigrate in the appimage
authorArt Cancro <ajc@citadel.org>
Wed, 21 Apr 2021 16:44:07 +0000 (12:44 -0400)
committerArt Cancro <ajc@citadel.org>
Wed, 21 Apr 2021 16:44:07 +0000 (12:44 -0400)
appimage/README.txt
appimage/build_appimage.sh
appimage/citadel.AppDir/AppRun
appimage/ctdlvisor.c

index 5443d2a9896ba2e2d44146ffd9b184bed591cb01..6aff8531e6f4fa7ac74f5ede16df844b8eb46c5b 100644 (file)
@@ -15,9 +15,8 @@ this is that we can supply ready-to-run binaries that will run on any Linux/Linu
 without modification or dependencies.  If you are an end user, stop here, go download the
 binary package, and use it.  Enjoy it and have fun.
 
 without modification or dependencies.  If you are an end user, stop here, go download the
 binary package, and use it.  Enjoy it and have fun.
 
-Still with us?  Then you must be a new member of the Citadel team and you're packaging
-the software for a new architecture or something.  So here's what you have to do to build
-the binary:
+Still with us?  Then you must be a new member of the build team.  So here's what you have
+to do to build the binary:
 
 1. Download the Citadel source tree (if you're reading this, you've already done that).
 2. Install all system dependencies.  The same ones needed for Easy Install are fine.
 
 1. Download the Citadel source tree (if you're reading this, you've already done that).
 2. Install all system dependencies.  The same ones needed for Easy Install are fine.
index 28d24eccb7c55509a4949e6598dea77f81eece6c..ed363a5e0cb48214951a6c4c01484318c32b5b68 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
 #!/bin/bash
 
+rm -vf citadel-*appimage
+
 export CITADEL_BUILD_DIR=/tmp/citadel-build-$$
 export WEBCIT_BUILD_DIR=/tmp/webcit-build-$$
 rm -fr $CITADEL_BUILD_DIR $WEBCIT_BUILD_DIR
 export CITADEL_BUILD_DIR=/tmp/citadel-build-$$
 export WEBCIT_BUILD_DIR=/tmp/webcit-build-$$
 rm -fr $CITADEL_BUILD_DIR $WEBCIT_BUILD_DIR
@@ -37,7 +39,7 @@ mkdir -p citadel.AppDir/usr/bin
 mkdir -p citadel.AppDir/usr/lib
 
 # Copy over all the libraries we used
 mkdir -p citadel.AppDir/usr/lib
 
 # Copy over all the libraries we used
-for bin in $CITADEL_BUILD_DIR/citserver $WEBCIT_BUILD_DIR/webcit
+for bin in $CITADEL_BUILD_DIR/citserver $WEBCIT_BUILD_DIR/webcit $CITADEL_BUILD_DIR/ctdlmigrate
 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
 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
index ff2fe0e61980284f2d32fb5952538c58ac71a395..e498fe4288fad8c21cdc01e2e737185e95723122 100755 (executable)
@@ -23,7 +23,7 @@ ulimit -c unlimited
 
 usage() {
        echo ${APPIMAGE}: usage: ${APPIMAGE} '[-h data_directory] [-p http_port] [-s https_port] command'
 
 usage() {
        echo ${APPIMAGE}: usage: ${APPIMAGE} '[-h data_directory] [-p http_port] [-s https_port] command'
-       echo 'command must be one of: run, test, install, database_cleanup'
+       echo 'command must be one of: run, test, install, database_cleanup, migrate'
        exit 2
 }
 
        exit 2
 }
 
@@ -199,6 +199,12 @@ case ${1} in
                export PATH=$APPDIR/usr/bin:$PATH
                exec $APPDIR/usr/local/citadel/database_cleanup.sh -h $CTDL_DIR
                ;;
                export PATH=$APPDIR/usr/bin:$PATH
                exec $APPDIR/usr/local/citadel/database_cleanup.sh -h $CTDL_DIR
                ;;
+       migrate)
+               export APPDIR CTDL_DIR HTTP_PORT HTTPS_PORT
+               export LD_LIBRARY_PATH=$APPDIR/usr/lib
+               export PATH=$APPDIR/usr/bin
+               exec ctdlvisor -m -h $CTDL_DIR
+               ;;
        *)
                echo Unexpected command: ${1} 
                usage
        *)
                echo Unexpected command: ${1} 
                usage
index c9be7e13989fa19700af9fed98d242b0fe7690c5..7e2c25b29765e351d0e7831596b8919653f0c455 100644 (file)
@@ -200,12 +200,34 @@ void main_loop(void) {
 
 
 int main(int argc, char **argv) {
 
 
 int main(int argc, char **argv) {
+       int a;
+       int migrate_mode = 0;
 
        if (getenv("APPDIR") == NULL) {
                fprintf(stderr, "ctdlvisor: APPDIR is not set.  This program must be run from within an AppImage.\n");
                ctdlvisor_exit(1);
        }
 
 
        if (getenv("APPDIR") == NULL) {
                fprintf(stderr, "ctdlvisor: APPDIR is not set.  This program must be run from within an AppImage.\n");
                ctdlvisor_exit(1);
        }
 
+       /* parse command-line arguments */
+       while ((a=getopt(argc, argv, "cm")) != EOF) switch(a) {
+
+               // test this binary for compatibility and exit
+               case 'c':
+                       fprintf(stderr, "%s: binary compatibility confirmed\n", argv[0]);
+                       exit(0);
+                       break;
+
+               // run ctdlmigrate only
+               case 'm':
+                       migrate_mode = 1;
+                       break;
+
+               // any other parameter makes it crash and burn
+               default:
+                       fprintf(stderr, "usage\n");
+                       exit(1);
+       }
+
        fprintf(stderr, "ctdlvisor: Welcome to the Citadel System, brought to you using AppImage.\n");
        fprintf(stderr, "ctdlvisor: LD_LIBRARY_PATH = %s\n", getenv("LD_LIBRARY_PATH"));
        fprintf(stderr, "ctdlvisor:            PATH = %s\n", getenv("PATH"));
        fprintf(stderr, "ctdlvisor: Welcome to the Citadel System, brought to you using AppImage.\n");
        fprintf(stderr, "ctdlvisor: LD_LIBRARY_PATH = %s\n", getenv("LD_LIBRARY_PATH"));
        fprintf(stderr, "ctdlvisor:            PATH = %s\n", getenv("PATH"));
@@ -219,15 +241,31 @@ int main(int argc, char **argv) {
                ctdlvisor_exit(errno);
        }
 
                ctdlvisor_exit(errno);
        }
 
-       signal(SIGTERM, signal_handler);
        signal(SIGHUP, signal_handler);
        signal(SIGHUP, signal_handler);
-       signal(SIGINT, signal_handler);
-       signal(SIGQUIT, signal_handler);
 
 
-       citserver_pid = start_citadel();
-       webcit_pid = start_webcit();
-       webcits_pid = start_webcits();
+       // "migrate mode" means we just start the server and then run ctdlmigrate interactively.
+       if (migrate_mode) {
+               citserver_pid = start_citadel();
+               fprintf(stderr, "ctdlvisor: waiting a moment for citserver to initialize...\n");
+               sleep(5);
+               char bin[1024];
+               sprintf(bin, "%s/usr/local/citadel/ctdlmigrate", getenv("APPDIR"));
+               system(bin);
+               kill(citserver_pid, SIGTERM);
+       }
+
+       // Otherwise, it's just a normal happy day in Citadel land.
+       else {
+               signal(SIGTERM, signal_handler);
+               signal(SIGINT, signal_handler);
+               signal(SIGQUIT, signal_handler);
+       
+               citserver_pid = start_citadel();
+               webcit_pid = start_webcit();
+               webcits_pid = start_webcits();
+       
+               main_loop();
+       }
 
 
-       main_loop();
        ctdlvisor_exit(0);
 }
        ctdlvisor_exit(0);
 }