joininbox/scripts/start.service.sh

68 lines
1.4 KiB
Bash
Raw Normal View History

2020-01-20 01:03:09 +00:00
#!/bin/bash
2020-06-17 10:14:56 +01:00
source /home/joinmarket/joinin.conf
2020-01-20 01:03:09 +00:00
2020-06-13 19:25:26 +01:00
script="$1"
wallet="$2"
2020-01-21 23:25:32 +00:00
2020-06-13 22:22:15 +01:00
echo ""
echo "Making sure $script not running"
2020-06-13 19:25:26 +01:00
sudo systemctl stop $script
sudo systemctl disable $script
2020-01-21 23:25:32 +00:00
2020-06-13 19:25:26 +01:00
if [ $script == "yg-privacyenhanced" ]; then
# shut down the process gracefully
pkill -sigint -f "python yg-privacyenhanced.py $wallet --wallet-password-stdin"
# make sure the lock file is deleted
rm -f ~/.joinmarket/wallets/.$wallet.lock
# for old version <v0.6.3
2020-08-19 08:42:12 +01:00
rm -f ~/.joinmarket/wallets/$wallet.lock 2>/dev/null
2020-06-13 19:25:26 +01:00
fi
2020-04-15 14:23:29 +01:00
2020-06-21 00:42:29 +01:00
if [ ${RPCoverTor} = "on" ];then
tor="torify"
2020-04-15 14:23:29 +01:00
else
tor=""
2020-04-15 14:23:29 +01:00
fi
2020-06-21 01:03:29 +01:00
startScript="cat /home/joinmarket/.pw | $tor python $script.py $wallet \
--wallet-password-stdin"
2020-06-22 14:11:58 +01:00
# display
2020-06-22 20:51:26 +01:00
echo "
Running the command with systemd:
$tor python $script.py $(echo $wallet | sed "s#$walletPath##g")"
2020-01-20 01:03:09 +00:00
echo "
[Unit]
2020-06-13 19:25:26 +01:00
Description=$script
2020-01-20 01:03:09 +00:00
[Service]
2020-03-18 11:01:32 +00:00
WorkingDirectory=/home/joinmarket/joinmarket-clientserver/scripts/
2020-06-21 01:03:29 +01:00
ExecStart=/bin/sh -c \
'. /home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate && $startScript'
2020-03-18 11:01:32 +00:00
User=joinmarket
Group=joinmarket
2020-01-20 01:03:09 +00:00
Type=simple
KillMode=process
2020-06-17 15:11:18 +01:00
TimeoutSec=infinity
2020-01-21 23:25:32 +00:00
Restart=no
2020-01-20 01:03:09 +00:00
[Install]
WantedBy=multi-user.target
2020-06-13 19:25:26 +01:00
" | sudo tee /etc/systemd/system/$script.service 1>/dev/null
2020-06-22 20:51:26 +01:00
echo "
Starting the systemd service: $script
"
2020-06-13 22:22:15 +01:00
2020-06-13 19:25:26 +01:00
sudo systemctl enable $script
sudo systemctl start $script
2020-06-13 13:31:25 +01:00
2020-06-22 20:51:26 +01:00
echo "
Shredding the password once used...
"
sleep 5
# delete password once used
shred -uvz /home/joinmarket/.pw