|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | 3 | clean_exit() { |
4 | | - if [ -n "$DEPLOY_DIR" ]; then |
| 4 | + if [ -d "$DEPLOY_DIR" ]; then |
5 | 5 | cleanup "$DEPLOY_DIR" |
6 | 6 | fi |
7 | 7 | exit 1 |
@@ -233,6 +233,11 @@ deploy_olsystem() { |
233 | 233 | done |
234 | 234 | echo -e "No changes found in the $REPO repo on the servers.\n" |
235 | 235 |
|
| 236 | + cd $DEPLOY_DIR |
| 237 | + if [ -d "$DEPLOY_DIR/$REPO_NEW" ]; then |
| 238 | + cleanup "$DEPLOY_DIR/$REPO_NEW" |
| 239 | + fi |
| 240 | + |
236 | 241 | # Get the latest code |
237 | 242 | echo -ne "Cloning $REPO repo ... " |
238 | 243 | git clone --depth=1 "$CLONE_URL" $REPO_NEW 2> /dev/null |
@@ -350,6 +355,12 @@ deploy_openlibrary() { |
350 | 355 | echo "[Now] Deploying openlibrary" |
351 | 356 |
|
352 | 357 | cd $DEPLOY_DIR |
| 358 | + if [ -d "$DEPLOY_DIR/openlibrary" ]; then |
| 359 | + cleanup "$DEPLOY_DIR/openlibrary" |
| 360 | + fi |
| 361 | + if [ -d "$DEPLOY_DIR/openlibrary_new" ]; then |
| 362 | + cleanup "$DEPLOY_DIR/openlibrary_new" |
| 363 | + fi |
353 | 364 | echo -ne "Cloning openlibrary repo ... " |
354 | 365 | git clone --depth=1 "https://github.com/internetarchive/openlibrary.git" openlibrary 2> /dev/null |
355 | 366 | GIT_SHA=$(git -C openlibrary rev-parse HEAD | cut -c -7) |
@@ -413,8 +424,6 @@ deploy_openlibrary() { |
413 | 424 | echo "Finished production deployment at $(date)" |
414 | 425 | echo "To reboot the servers, please run scripts/deployments/restart_all_servers.sh" |
415 | 426 |
|
416 | | - cleanup "${DEPLOY_DIR}/openlibrary" |
417 | | - |
418 | 427 | echo "[Info] Skipping booklending utils; see \`deploy.sh utils\`" |
419 | 428 | echo "[Next] Run review aka are_servers_in_sync.sh (~50s as of 2024-12-09):" |
420 | 429 | echo "time ./scripts/deployment/deploy.sh review" |
@@ -655,8 +664,6 @@ deploy_wizard() { |
655 | 664 | echo "" |
656 | 665 | echo "The Open Library weekly deploy is now complete. See changes here: https://github.com/internetarchive/openlibrary/releases/tag/$LATEST_TAG_NAME. Please let us know @here if anything seems broken or delightful!" |
657 | 666 | fi |
658 | | - |
659 | | - cleanup "$DEPLOY_DIR" |
660 | 667 | } |
661 | 668 |
|
662 | 669 | # See deployment documentation at https://github.com/internetarchive/olsystem/wiki/Deployments |
|
692 | 699 | echo "e.g: time SERVER_SUFFIX='.us.archive.org' ./scripts/deployment/deploy.sh [command]" |
693 | 700 | exit 1 |
694 | 701 | fi |
| 702 | + |
| 703 | +# In all cases, cleanup upon success |
| 704 | +if [ -d "$DEPLOY_DIR" ]; then |
| 705 | + cleanup "$DEPLOY_DIR" |
| 706 | +fi |
0 commit comments