X-Git-Url: https://git.novaco.in/?p=electrum-server.git;a=blobdiff_plain;f=start;h=bd1db6243128097a01af7c6c044d762757d3aa8b;hp=c76393c0a61e05553d618e16481f97c6403bbdea;hb=9e68150ef4404205b79f84ec20d5e6fd82eae290;hpb=cfccf5962610ef6efa198e64ad7039fa39bf2e31 diff --git a/start b/start index c76393c..bd1db62 100755 --- a/start +++ b/start @@ -1,9 +1,16 @@ #!/bin/bash +PID=`/usr/bin/python server.py getpid` +if [[ $PID != *[!0-9]* ]]; then + echo "Server already running (pid $PID)" + exit +fi + + electrum_config="/etc/electrum.conf" if [ ! -f $electrum_config ]; then - echo "/etc/electrum.conf does not exist" + echo "$electrum_config does not exist" exit fi @@ -12,18 +19,22 @@ 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" + echo "Variable path_fulltree not set in $electrum_config" exit + # we're actually forcing fulltree with this clause, which is ok if displaying v0.9 should use fulltree fi +rmdir $path --ignore-fail-on-non-empty + if [ ! -d $path ]; then echo "Database not found in $path." read -p "Do you want to download it from the Electrum foundry to $path ? " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then - wget -O - "http://foundry.electrum.org/leveldb-dump/electrum-fulltree-100-latest.tar" | tar -C $path -xvf - + mkdir $path + wget -O - "http://foundry.electrum.org/leveldb-dump/electrum-fulltree-100-latest.tar.gz" | tar --extract --gunzip --strip-components 1 --directory $path --file - fi fi -echo "starting server as daemon" +echo "Starting server as daemon" nohup /usr/bin/python -u server.py &> /var/log/electrum.log &