startup: error conditions for missing files, wget on the fly; sample config fulltree...
[electrum-server.git] / start
1 #!/bin/bash
2
3 electrum_config="/etc/electrum.conf"
4
5 if [ ! -f $electrum_config ]; then
6     echo "/etc/electrum.conf does not exist"
7     exit
8 fi
9
10 path=`grep path_fulltree $electrum_config |awk -F\= '{print $2}'`
11
12 #needs more hardening against double definiton of variable, dismiss commented ones
13
14 if ! [ "$path" ]; then
15     echo "Variable path_fulltree not set in /etc/electrum.conf"
16     exit
17 fi
18
19 if [ ! -d $path ]; then
20     echo "Database not found in $path."
21     read -p "Do you want to download it from the Electrum foundry to $path ? " -n 1 -r
22     echo
23     if [[ $REPLY =~ ^[Yy]$ ]]; then
24         wget -O - "http://foundry.electrum.org/leveldb-dump/electrum-fulltree-100-latest.tar" | tar -C $path -xvf -
25     fi
26 fi
27
28 echo "starting server as daemon"
29 nohup /usr/bin/python -u server.py &> /var/log/electrum.log &