diff --git a/home.admin/_commands.sh b/home.admin/_commands.sh index a27033d05..beaab7050 100755 --- a/home.admin/_commands.sh +++ b/home.admin/_commands.sh @@ -114,7 +114,7 @@ function status() { # command: balance # switch to the bos user for Balance of Satoshis function balance() { - if [ $(cat /mnt/hdd/raspiblitz.conf 2>/dev/null | grep -c "bos=on") -eq 1 ]; then + if [ $(grep -c "bos=on" < /mnt/hdd/raspiblitz.conf) -eq 1 ]; then sudo su - bos else echo "Balance of Satoshis is not installed - to install run:" @@ -125,7 +125,7 @@ function balance() { # command: jmarket # switch to the joinmarket user for the JoininBox menu function jmarket() { - if [ $(cat /mnt/hdd/raspiblitz.conf 2>/dev/null | grep -c "joinmarket=on") -eq 1 ]; then + if [ $(grep -c "joinmarket=on" < /mnt/hdd/raspiblitz.conf) -eq 1 ]; then sudo su - joinmarket else echo "JoinMarket is not installed - to install run:" @@ -133,6 +133,17 @@ function jmarket() { fi } +# command: loop +# switch to the loop user for the Lightning Loop Service +function loop() { + if [ $(grep -c "loop=on" < /mnt/hdd/raspiblitz.conf) -eq 1 ]; then + sudo su - loop + else + echo "Lightning Loop is not installed - to install run:" + echo "/home/admin/config.scripts/bonus.loop.sh on" + fi +} + # command: gettx # retrieve transaction from mempool or blockchain and print as JSON # $ gettx "f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16" diff --git a/home.admin/config.scripts/bonus.loop.sh b/home.admin/config.scripts/bonus.loop.sh index 783c8c348..223dc3add 100755 --- a/home.admin/config.scripts/bonus.loop.sh +++ b/home.admin/config.scripts/bonus.loop.sh @@ -18,7 +18,8 @@ fi if [ "$1" = "menu" ]; then dialog --title " Info Loop Service " --msgbox "\n\ Usage and examples: https://github.com/lightninglabs/loop#loop-out-swaps\n -Use the command 'loop' on the terminal to see the options. +Use the shortcut 'loop' in the terminal to switch to the dedicated user.\n +Type 'loop' again to see the available options. " 10 56 exit 0 fi @@ -43,10 +44,13 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then # create dedicated user sudo adduser --disabled-password --gecos "" loop + # set PATH for the user + sudo bash -c "echo 'PATH=\$PATH:/home/loop/go/bin/' >> /home/loop/.profile" + # make sure symlink to central app-data directory exists ***" sudo rm -rf /home/loop/.lnd # not a symlink.. delete it silently # create symlink - sudo ln -s "/mnt/hdd/app-data/lnd/" "/home/loop/.lnd" + sudo ln -s /mnt/hdd/app-data/lnd/ /home/loop/.lnd # sync all macaroons and unix groups for access /home/admin/config.scripts/lnd.credentials.sh sync @@ -69,11 +73,10 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then cd /home/loop sudo -u loop git clone https://github.com/lightninglabs/loop.git cd /home/loop/loop - # https://github.com/lightninglabs/loop/releases - sudo -u loop git reset --hard v0.8.0-beta + sudo -u loop git reset --hard v0.8.1-beta cd /home/loop/loop/cmd - go install ./... + sudo -u loop /usr/local/go/bin/go install ./... || exit 1 # make systemd service if [ "${runBehindTor}" = "on" ]; then @@ -92,7 +95,7 @@ After=lnd.service [Service] WorkingDirectory=/home/loop/loop -ExecStart=/usr/local/gocode/bin/loopd --network=${chain}net ${proxy} +ExecStart=/home/loop/go/bin/loopd --network=${chain}net ${proxy} User=loop Group=loop Type=simple @@ -114,7 +117,7 @@ WantedBy=multi-user.target # setting value in raspi blitz config sudo sed -i "s/^loop=.*/loop=on/g" /mnt/hdd/raspiblitz.conf - isInstalled=$(loop | grep -c loop) + isInstalled=$(sudo -u loop /home/loop/go/bin/loop | grep -c loop) if [ ${isInstalled} -gt 0 ] ; then echo "Find info on how to use on https://github.com/lightninglabs/loop#loop-out-swaps" else @@ -138,11 +141,8 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then sudo systemctl stop loopd sudo systemctl disable loopd sudo rm /etc/systemd/system/loopd.service - # delete user + # delete user and it's home directory sudo userdel -rf loop - # delete Go packages - sudo rm /usr/local/gocode/bin/loop - sudo rm /usr/local/gocode/bin/loopd echo "OK, the Loop Service is removed." else echo "Loop is not installed."