Created
March 27, 2020 12:18
-
-
Save aesedepece/493e2c1a772a6834b84c27cf0e649910 to your computer and use it in GitHub Desktop.
Quick and dirty script for wiping the local chain and resynchronizing a Witnet node running on Docker (see comments)
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 | |
# If your Docker container is named differently, change it here | |
CONTAINER="witnet_node" | |
# If your Witnet storage path is not the default, change it here | |
STORAGE_PATH="/home/$USER/.witnet" | |
echo "[ Trying to wipe local chain and resync ]"; | |
echo "1. Making sure the node is running..." | |
docker start $CONTAINER; | |
sleep 5; | |
echo "2. Exporting master key..." && | |
docker exec $CONTAINER ./witnet node masterKeyExport --write 2> /dev/null && | |
echo "3. Renaming master key..." && | |
docker exec $CONTAINER sh -c "for f in /.witnet/*.txt; do mv \${f} /.witnet/master.key; done" && | |
echo "4. Stopping container..." && | |
docker stop $CONTAINER && | |
echo "5. Deleting local chain files" && | |
(find ~/.witnet /.witnet -type f -not -name '*.key' -delete 2>/dev/null || true) && | |
echo "6. Removing old container..." && | |
docker container rm $CONTAINER && | |
sleep 5 && | |
echo "7. Creating new container..." && | |
docker run -d \ | |
--volume $STORAGE_PATH:/.witnet \ | |
--name $CONTAINER \ | |
witnet/witnet-rust latest node server \ | |
--master-key-import /.witnet/master.key && | |
echo "[ SUCCESS! ]" || | |
echo "[ FAILURE! ]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you are using a custom container name or storage path, please modify it in the variables you will find at the top of the script.