From a42973c3cb9ea3e2dd5b16329d38fe87235c6769 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Sat, 4 Sep 2021 16:09:01 -0500 Subject: [PATCH] More server setup stuff I dunno I'm sorry --- cinera/setup.sh | 4 +- cinera/update_annotations.sh | 2 +- cinera/user_update_cinera.sh | 2 +- server/adminmailer.sh | 2 +- server/serversetup.sh | 96 +++++++++++++++++++++++++++--------- src/migration/migration.go | 7 +-- 6 files changed, 81 insertions(+), 32 deletions(-) diff --git a/cinera/setup.sh b/cinera/setup.sh index 8921379..577330f 100755 --- a/cinera/setup.sh +++ b/cinera/setup.sh @@ -16,6 +16,8 @@ chgrp $ANNOTATIONS_USER_GROUP $CINERA_SCRIPT_PATH chgrp $ANNOTATIONS_USER_GROUP $CINERA_SCRIPT_PATH/data ./update_cinera.sh -./update_annotations.sh + +CMD="cd $CINERA_SCRIPT_PATH; ./update_annotations.sh" +su - $ANNOTATIONS_USER -c "$CMD" mkdir -p data diff --git a/cinera/update_annotations.sh b/cinera/update_annotations.sh index 118fd98..e22fb50 100755 --- a/cinera/update_annotations.sh +++ b/cinera/update_annotations.sh @@ -7,7 +7,7 @@ fi . cinera.conf if [ ! -d $CINERA_HMML_PATH ]; then - git clone git@gitssh.handmade.network:Annotation-Pushers/cinera_handmade.network.git $CINERA_HMML_PATH + git clone --config core.sshCommand="ssh -i ~/.ssh/gitlab-hmml" git@gitssh.handmade.network:Annotation-Pushers/cinera_handmade.network.git $CINERA_HMML_PATH fi if [ ! -d $CINERA_HMML_PATH ]; then diff --git a/cinera/user_update_cinera.sh b/cinera/user_update_cinera.sh index a933dfc..0eb6f80 100755 --- a/cinera/user_update_cinera.sh +++ b/cinera/user_update_cinera.sh @@ -7,7 +7,7 @@ fi . cinera.conf if [ ! -d $CINERA_REPO_PATH ]; then - git clone git@gitssh.handmade.network:Annotation-Pushers/Annotation-System.git $CINERA_REPO_PATH + git clone --config core.sshCommand="ssh -i ~/.ssh/gitlab-annotation-system" git@gitssh.handmade.network:Annotation-Pushers/Annotation-System.git $CINERA_REPO_PATH fi if [ ! -d $CINERA_REPO_PATH ]; then diff --git a/server/adminmailer.sh b/server/adminmailer.sh index dd6bdd1..4264073 100755 --- a/server/adminmailer.sh +++ b/server/adminmailer.sh @@ -4,6 +4,6 @@ if [ $SERVICE_RESULT == "success" ]; then exit fi -/home/hmn/hmn/adminmailer/adminmailer "[$1] Status changed" </dev/null; echo "50 4 * * * /home/hmn/hmn/server/backup.sh") | crontab - + # See https://stackoverflow.com/a/9625233/1177139 + (crontab -l 2>/dev/null; echo "50 4 * * * /home/hmn/hmn/server/backup.sh") | crontab - - savecheckpoint 105 + # TODO: This seems to fail the first time you run it? But then works fine afterward, thanks + # to checkpoints. Probably should fix this someday. + + savecheckpoint 105 fi # Build the site for the first time (despite bad config) @@ -312,10 +359,10 @@ ${BLUE_BOLD}Admin mailer${RESET}: /home/hmn/hmn/adminmailer/config.go source ~/.bashrc - Fill in the config file and build the mailer: + Fill in the config file and build the mailer: - cd /home/hmn/hmn/adminmailer - go build . + cd /home/hmn/hmn/adminmailer + go build -o /usr/bin/adminmailer . ${BLUE_BOLD}===== Next steps =====${RESET} @@ -336,6 +383,11 @@ Restore static files: make restore-static-files +Set up Cinera: + + cd /home/hmn/hmn/cinera + ./setup.sh + Start up Caddy: systemctl start caddy diff --git a/src/migration/migration.go b/src/migration/migration.go index a4b74e7..4a34b5b 100644 --- a/src/migration/migration.go +++ b/src/migration/migration.go @@ -367,12 +367,7 @@ func SeedFromFile(seedFile string, afterMigration types.MigrationVersion) { fmt.Println("Running command:", cmd) if output, err := cmd.CombinedOutput(); err != nil { fmt.Print(string(output)) - exitError, isExit := err.(*exec.ExitError) - if isExit { - panic(fmt.Errorf("failed to execute seed: %w\n%s", err, string(exitError.Stderr))) - } else { - panic(fmt.Errorf("failed to execute seed: %w", err)) - } + panic(fmt.Errorf("failed to execute seed: %w", err)) } fmt.Println("Done! You may want to migrate forward from here.")