handle signals
[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 -e ^path_fulltree $electrum_config |awk -F\= '{print $2}' | tail -n 1`
18
19 if ! [ "$path" ]; then
20     echo "Variable path_fulltree not set in $electrum_config"
21     exit
22     # we're actually forcing fulltree with this clause, which is ok if displaying v0.9 should use fulltree 
23 fi
24
25 rmdir $path --ignore-fail-on-non-empty
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         mkdir -p $path
33         wget -O - "http://foundry.electrum.org/leveldb-dump/electrum-fulltree-100-latest.tar.gz" | tar --extract --gunzip --strip-components 1 --directory $path --file -
34     fi
35 fi
36
37 echo "Starting server as daemon"
38 nohup /usr/bin/python -u server.py &> /var/log/electrum.log &