joininbox/scripts/start.service.sh

70 lines
1.3 KiB
Bash
Raw Permalink 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
source /home/joinmarket/_functions.sh
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
if [ $script == "yg-privacyenhanced" ]; then
stopYG $wallet
else
echo
echo "# Making sure $script is not running"
sudo systemctl stop $script
sudo systemctl disable $script
2020-06-13 19:25:26 +01:00
fi
2020-04-15 14:23:29 +01:00
2022-04-06 19:54:00 +01:00
if [ "${RPCoverTor}" = "on" ];then
2021-10-03 00:37:34 +01:00
tor="torsocks"
2020-04-15 14:23:29 +01:00
else
tor=""
2020-04-15 14:23:29 +01:00
fi
startScript="cat /dev/shm/.pw | $tor python $script.py $wallet \
2020-06-21 01:03:29 +01:00
--wallet-password-stdin"
2020-06-22 14:11:58 +01:00
# display
walletFileName="${wallet//$walletPath/ }"
echo
echo "# Running the command with systemd:"
echo " $tor python $script.py $walletFileName"
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
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
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
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
echo
echo "# Starting the systemd service: $script"
echo
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
echo
echo "# Shredding the password once used..."
echo
sleep 5
# delete password once used
shred -uvz /dev/shm/.pw