Last active
February 18, 2021 23:53
-
-
Save ynx0/0227145d9659d81685374b38dec1f0fb to your computer and use it in GitHub Desktop.
helper script for running recovery on an urbit ship. assumes pier is in current directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DRY_RUN=false | |
HARD_DELETE=true | |
#DEL="trash" # use this if you have trash-cli enabled and don't want to risk the script accidently deleting your precious jam files | |
DEL="rm" | |
SHIP_NAME=${1:-"sampel-palnet"} # change this or pass it in as a cmdline input | |
NUM_EVENTS=${2:-1000000} # change this or pass it in as a cmdline input | |
LATEST_EVENT="$(ls ./$SHIP_NAME/.urb/roc/ | cut -d'.' -f1 | sort -nr | head -n1)" | |
echo "Checkpoint: $LATEST_EVENT" | |
echo "Recovering $NUM_EVENTS events on ship $SHIP_NAME." | |
# process a certain number of events | |
if [ "$DRY_RUN" = true ]; then | |
echo ./urbit -r "$LATEST_EVENT" -n "$(($LATEST_EVENT + $NUM_EVENTS))" "$SHIP_NAME" | |
else | |
./urbit -r "$LATEST_EVENT" -n "$(($LATEST_EVENT + $NUM_EVENTS))" "$SHIP_NAME" | |
fi | |
stty sane # this makes the tty sane lmao | |
# delete oldest serialized state | |
JAMCOUNT=$(ls ./"$SHIP_NAME"/.urb/roc/ | wc -l) | |
if [ $JAMCOUNT -gt 3 ]; then | |
echo "deleting some jams" | |
ls ./"$SHIP_NAME"/.urb/roc/ | sort -n | head -n$((JAMCOUNT - 2)) | xargs -I {} "$DEL" ./"$SHIP_NAME"/.urb/roc/{} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NO WARRANTY! PLEASE DON'T YELL AT ME IF IT BREAKS YOUR SHIP! HOPEFULLY THIS SCARES YOU ENOUGH TO READ THE SCRIPT FIRST!!!!!