Skip to content

Commit

Permalink
start.joininbox.sh to start on every login (replaces startup.sh)
Browse files Browse the repository at this point in the history
  • Loading branch information
openoms committed Sep 21, 2020
1 parent 447a032 commit 5368e3a
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 22 deletions.
5 changes: 1 addition & 4 deletions build_joininbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,15 @@ if [ "${baseImage}" = "raspbian" ] || [ "${baseImage}" = "dietpi" ] ; then
# https://stackoverflow.com/questions/38188762/generate-all-locales-in-a-docker-image
echo ""
echo "*** FIXING LOCALES FOR BUILD ***"

sudo sed -i "s/^# en_US.UTF-8 UTF-8.*/en_US.UTF-8 UTF-8/g" /etc/locale.gen
sudo sed -i "s/^# en_US ISO-8859-1.*/en_US ISO-8859-1/g" /etc/locale.gen
sudo locale-gen
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

# https://github.com/rootzoll/raspiblitz/issues/684
sudo sed -i "s/^ SendEnv LANG LC.*/# SendEnv LANG LC_*/g" /etc/ssh/ssh_config

# remove unneccesary files
# remove unnecessary files
sudo rm -rf /home/pi/MagPi
fi

Expand Down
18 changes: 8 additions & 10 deletions scripts/install.hiddenservice.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,16 @@ if [ ${#toPort2} -gt 0 ]; then
fi
fi

checkDirEntry=$(cat /home/joinmarket/joinin.conf | grep -c "HiddenServiceDir")
if [ "${checkDirEntry}" -eq 0 ]; then
echo "HiddenServiceDir=" >> /home/joinmarket/joinin.conf
checkDirEntry=$(grep -c "HiddenServiceDir" < /home/joinmarket/joinin.conf)
if [ "$checkDirEntry" -eq 0 ]; then
if [ -d "/mnt/hdd/tor" ] ; then
HiddenServiceDir="/mnt/hdd/tor"
else
HiddenServiceDir="/var/lib/tor"
fi
echo "HiddenServiceDir=$HiddenServiceDir" >> /home/joinmarket/joinin.conf
fi

if [ -d "/mnt/hdd/tor" ] ; then
HiddenServiceDir="/mnt/hdd/tor"
else
HiddenServiceDir="/var/lib/tor"
fi
sudo sed -i "s#HiddenServiceDir=.*#HiddenServiceDir=$HiddenServiceDir#g" /home/joinmarket/joinin.conf

if [ "${runBehindTor}" = "on" ]; then
#check if the service is already present
isHiddenService=$(sudo cat /etc/tor/torrc 2>/dev/null | grep -c $service)
Expand Down
7 changes: 1 addition & 6 deletions scripts/menu.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#!/bin/bash

if [ "$(dialog | grep -c "ComeOn Dialog!")" -eq 0 ]; then
sudo apt install dialog
fi
if [ -f /home/joinmarket/joinin.conf ]; then
touch /home/joinmarket/joinin.conf
fi
/home/joinmarket/start.joininbox.sh

# add default value to joinin config if needed
if ! grep -Eq "^RPCoverTor=" /home/joinmarket/joinin.conf; then
Expand Down
4 changes: 2 additions & 2 deletions scripts/set.password.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ newPassword=$1
if [ ${#newPassword} -eq 0 ]; then
# ask user for new password A (first time)
dialog --backtitle "JoinInBox - Password Change"\
--title "JoinInBox - Password Change"\
--title "JoininBox - Password Change"\
--insecure --passwordbox "
Set a new password for the users:
'joinmarket' and 'root'
Expand All @@ -38,7 +38,7 @@ Set a new password for the users:
shred $_temp

# ask user for new password A (second time)
dialog --backtitle "JoinInBox - Password Change"\
dialog --backtitle "JoininBox - Password Change"\
--insecure --passwordbox "Re-enter the password:\n(This is the new password to login via SSH)" 9 56 2>$_temp

# get user input
Expand Down
74 changes: 74 additions & 0 deletions scripts/start.joininbox.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

echo "Starting JoininBox ..."

if [ "$(dialog | grep -c "ComeOn Dialog!")" -eq 0 ]; then
sudo apt install dialog
fi
if [ -f /home/joinmarket/joinin.conf ]; then
touch /home/joinmarket/joinin.conf
fi

# get settings on first run
runningEnv=$(grep -c "runningEnv" < /home/joinmarket/joinin.conf)
if [ "$runningEnv" -eq 0 ]; then
if [ -f "/mnt/hdd/raspiblitz.conf" ] ; then
runningEnv="raspiblitz"
setupStep=100
else
runningEnv="standalone"
setupStep=0
fi
echo "runningEnv=$runningEnv" >> /home/joinmarket/joinin.conf
echo "setupStep=$setupStep" >> /home/joinmarket/joinin.conf
echo "Running in the environment: $runningEnv"

# make sure Tor path is known
checkDirEntry=$(grep -c "HiddenServiceDir" < /home/joinmarket/joinin.conf)
if [ "$checkDirEntry" -eq 0 ]; then
if [ -d "/mnt/hdd/tor" ] ; then
HiddenServiceDir="/mnt/hdd/tor"
else
HiddenServiceDir="/var/lib/tor"
fi
echo "HiddenServiceDir=$HiddenServiceDir" >> /home/joinmarket/joinin.conf
fi
fi

source /home/joinmarket/joinin.conf

if [ "$runningEnv" = "standalone" ]; then
if [ "$setupStep" = "0" ]; then
# set ssh passwords on the first run
/home/joinmarket/set.password.sh || exit 1
sudo sed -i "s#setupStep=.*#setupStep=100#g" /home/joinmarket/joinin.conf
fi
elif [ "$runningEnv" = "raspiblitz" ]; then
# check for the joinmarket.cfg
if [ ! -f "/home/joinmarket/.joinmarket/joinmarket.cfg" ]; then
echo " # Generating the joinmarket.cfg"
echo ""
. /home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate &&\
cd /home/joinmarket/joinmarket-clientserver/scripts/
python wallet-tool.py generate --datadir=/home/joinmarket/.joinmarket
sudo chmod 600 /home/joinmarket/.joinmarket/joinmarket.cfg || exit 1
echo ""
echo "# Editing the joinmarket.cfg"
sed -i "s/^rpc_user =.*/rpc_user = raspibolt/g" /home/joinmarket/.joinmarket/joinmarket.cfg
PASSWORD_B=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf | grep rpcpassword | cut -c 13-)
sed -i "s/^rpc_password =.*/rpc_password = $PASSWORD_B/g" /home/joinmarket/.joinmarket/joinmarket.cfg
echo "# Filled the bitcoin RPC password (PASSWORD_B)"
sed -i "s/^rpc_wallet_file =.*/rpc_wallet_file = wallet.dat/g" /home/joinmarket/.joinmarket/joinmarket.cfg
echo "# Using the bitcoind wallet: wallet.dat"
#communicate with IRC servers via Tor
sed -i "s/^host = irc.darkscience.net/#host = irc.darkscience.net/g" /home/joinmarket/.joinmarket/joinmarket.cfg
sed -i "s/^#host = darksci3bfoka7tw.onion/host = darksci3bfoka7tw.onion/g" /home/joinmarket/.joinmarket/joinmarket.cfg
sed -i "s/^host = irc.hackint.org/#host = irc.hackint.org/g" /home/joinmarket/.joinmarket/joinmarket.cfg
sed -i "s/^#host = ncwkrwxpq2ikcngxq3dy2xctuheniggtqeibvgofixpzvrwpa77tozqd.onion/host = ncwkrwxpq2ikcngxq3dy2xctuheniggtqeibvgofixpzvrwpa77tozqd.onion/g" /home/joinmarket/.joinmarket/joinmarket.cfg
sed -i "s/^socks5 = false/#socks5 = false/g" /home/joinmarket/.joinmarket/joinmarket.cfg
sed -i "s/^#socks5 = true/socks5 = true/g" /home/joinmarket/.joinmarket/joinmarket.cfg
sed -i "s/^#port = 6667/port = 6667/g" /home/joinmarket/.joinmarket/joinmarket.cfg
sed -i "s/^#usessl = false/usessl = false/g" /home/joinmarket/.joinmarket/joinmarket.cfg
echo "# Edited the joinmarket.cfg to communicate over Tor only."
fi
fi

0 comments on commit 5368e3a

Please sign in to comment.