2020-01-20 01:03:09 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2020-06-17 10:14:56 +01:00
|
|
|
source /home/joinmarket/joinin.conf
|
2021-03-04 23:52:03 +00:00
|
|
|
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
|
|
|
|
2022-03-06 13:41:40 +00:00
|
|
|
if [ $script == "yg-privacyenhanced" ]; then
|
2021-05-13 14:42:30 +01:00
|
|
|
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
|
2020-06-15 15:36:38 +01:00
|
|
|
tor=""
|
2020-04-15 14:23:29 +01:00
|
|
|
fi
|
|
|
|
|
|
2021-03-04 23:52:03 +00:00
|
|
|
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
|
2021-03-04 23:52:03 +00:00
|
|
|
walletFileName="${wallet//$walletPath/ }"
|
|
|
|
|
echo
|
|
|
|
|
echo "# Running the command with systemd:"
|
|
|
|
|
echo " $tor python $script.py $walletFileName"
|
2020-06-15 15:36:38 +01:00
|
|
|
|
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
|
|
|
|
2021-05-23 16:31:44 +01: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
|
|
|
|
|
|
2021-03-04 23:52:03 +00:00
|
|
|
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
|
|
|
|
2021-03-04 23:52:03 +00:00
|
|
|
echo
|
|
|
|
|
echo "# Shredding the password once used..."
|
|
|
|
|
echo
|
2020-06-13 22:30:53 +01:00
|
|
|
|
|
|
|
|
sleep 5
|
2020-06-13 21:51:48 +01:00
|
|
|
# delete password once used
|
2021-03-04 23:52:03 +00:00
|
|
|
shred -uvz /dev/shm/.pw
|