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.
#!/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
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
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
}
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
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);
}
+ /* 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"));
ctdlvisor_exit(errno);
}
- signal(SIGTERM, 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);
}