fixes
[electrum-server.git] / start
1 #!/bin/bash
2
3 PID=`/usr/bin/python server.py getpid`
4 if [[ $PID != *[!0-9]* ]]; then
5     echo "Server already running (pid $PID)"
6     exit
7 fi
8
9
10 electrum_config="/etc/electrum.conf"
11
12 if [ ! -f $electrum_config ]; then
13     echo "$electrum_config does not exist"
14     exit
15 fi
16
17 path=`grep path_fulltree $electrum_config |awk -F\= '{print $2}'`
18
19 #needs more hardening against double definiton of variable, dismiss commented ones
20
21 if ! [ "$path" ]; then
22     echo "Variable path_fulltree not set in $electrum_config"
23     exit
24     # we're actually forcing fulltree with this clause, which is ok if displaying v0.9 should use fulltree 
25 fi
26
27 if [ ! -d $path ]; then
28     echo "Database not found in $path."
29     read -p "Do you want to download it from the Electrum foundry to $path ? " -n 1 -r
30     echo
31     if [[ $REPLY =~ ^[Yy]$ ]]; then
32         wget -O - "http://foundry.electrum.org/leveldb-dump/electrum-fulltree-100-latest.tar.gz" | tar -C $path --strip-components 1 -xvfz -
33     fi
34 fi
35
36 echo "Starting server as daemon"
37 nohup /usr/bin/python -u server.py &> /var/log/electrum.log &