Skip to content

Instantly share code, notes, and snippets.

@aesedepece
Created March 27, 2020 12:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aesedepece/493e2c1a772a6834b84c27cf0e649910 to your computer and use it in GitHub Desktop.
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)
#!/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! ]"
@aesedepece
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment