startup: error conditions for missing files, wget on the fly; sample config fulltree...
authorEagle[TM] <eagletm@mpex.net>
Tue, 18 Feb 2014 09:37:34 +0000 (10:37 +0100)
committerEagle[TM] <eagletm@mpex.net>
Tue, 18 Feb 2014 09:37:34 +0000 (10:37 +0100)
electrum.conf.sample
start

index d0a6468..0960d5b 100644 (file)
@@ -20,7 +20,9 @@ banner = Welcome to Electrum!
 backend = leveldb
 
 [leveldb]
-path = /path/to/your/database
+#path = /path/to/your/database
+#fulltree is the new UTXO tree, required for Electrum 2.0 clients
+path_fulltree = /path/to/your/database
 # for each address, history will be pruned if it is longer than this limit
 pruning_limit = 100
 
diff --git a/start b/start
index e00bdd9..c76393c 100755 (executable)
--- a/start
+++ b/start
@@ -1,17 +1,27 @@
 #!/bin/bash
 
-path=`grep path_fulltree /etc/electrum.conf |awk -F\= '{print $2}'`
+electrum_config="/etc/electrum.conf"
+
+if [ ! -f $electrum_config ]; then
+    echo "/etc/electrum.conf does not exist"
+    exit
+fi
+
+path=`grep path_fulltree $electrum_config |awk -F\= '{print $2}'`
+
+#needs more hardening against double definiton of variable, dismiss commented ones
+
+if ! [ "$path" ]; then
+    echo "Variable path_fulltree not set in /etc/electrum.conf"
+    exit
+fi
 
 if [ ! -d $path ]; then
     echo "Database not found in $path."
-    read -p "Do you want to download it from the Electrum foundry? " -n 1 -r
+    read -p "Do you want to download it from the Electrum foundry to $path ? " -n 1 -r
     echo
     if [[ $REPLY =~ ^[Yy]$ ]]; then
-       rm -rf fulltree fulltree.tar
-       wget http://foundry.electrum.org/leveldb-dump/electrum-fulltree-100-latest.tar -O fulltree.tar
-       tar -xvf fulltree.tar
-       mv fulltree $path
-       rm -rf fulltree fulltree.tar
+       wget -O - "http://foundry.electrum.org/leveldb-dump/electrum-fulltree-100-latest.tar" | tar -C $path -xvf -
     fi
 fi