Upgrade Thunderhub; Update Passwords for Bcrypt

This commit is contained in:
Taylor Helsper 2020-07-17 01:02:59 -05:00
parent 3a98857b37
commit d2ef9b1152
5 changed files with 38 additions and 8 deletions

View File

@ -1,18 +1,34 @@
#!/bin/bash #!/bin/bash
PASSWORD=$1 PASSWORD=$1
HASH=$(echo -n "$PASSWORD" | sha256sum | awk '{print $1}')
HASH_SHA256=$(echo -n "$PASSWORD" | sha256sum | awk '{print $1}')
HASH_BCRYPT=$(python3.7 -c "import bcrypt; print(bcrypt.hashpw(b\"$PASSWORD\", bcrypt.gensalt()).decode(\"ascii\"))")
# If pass did not change, exit success
if [ -f /home/bitcoin/.mynode/.hashedpw ]; then
OLD_HASH_SHA256=$(cat /home/bitcoin/.mynode/.hashedpw)
if [ "$OLD_HASH_SHA256" = "$HASH_SHA256" ]; then
exit 0;
fi
fi
# Change Linux Password # Change Linux Password
echo "admin:$PASSWORD" | chpasswd echo "admin:$PASSWORD" | chpasswd
# Save hashed password # Save hashed password
echo "$HASH" > /home/bitcoin/.mynode/.hashedpw echo "$HASH_SHA256" > /home/bitcoin/.mynode/.hashedpw
echo "$HASH_BCRYPT" > /home/bitcoin/.mynode/.hashedpw_bcrypt
# Change RTL password # Change RTL password
sed -i "s/\"multiPassHashed\":.*/\"multiPassHashed\": \"$HASH\",/g" /mnt/hdd/mynode/rtl/RTL-Config.json if [ -f /mnt/hdd/mynode/rtl/RTL-Config.json ]; then
systemctl restart rtl & sed -i "s/\"multiPassHashed\":.*/\"multiPassHashed\": \"$HASH_SHA256\",/g" /mnt/hdd/mynode/rtl/RTL-Config.json
systemctl restart rtl &
fi
# Change Thunderhub password # Change Thunderhub password
#sed -i "s/???/???/g" /mnt/hdd/mynode/rtl/RTL-Config.json if [ -f /mnt/hdd/mynode/thunderhub/thub_config.yaml ]; then
#systemctl restart thunderhub & sed -i "s/masterPassword:.*/masterPassword: 'thunderhub-$HASH_BCRYPT'/g" /mnt/hdd/mynode/thunderhub/thub_config.yaml
systemctl restart thunderhub &
fi

View File

@ -103,6 +103,7 @@ pip3 install gnureadline --no-cache-dir
pip3 install lndmanage==0.10.0 --no-cache-dir # Install LND Manage (keep up to date with LND) pip3 install lndmanage==0.10.0 --no-cache-dir # Install LND Manage (keep up to date with LND)
pip3 install docker-compose --no-cache-dir pip3 install docker-compose --no-cache-dir
pip3 install pipenv --no-cache-dir pip3 install pipenv --no-cache-dir
pip3 install bcrypt --no-cache-dir
# Install Docker # Install Docker
@ -515,7 +516,7 @@ fi
# Upgrade Thunderhub # Upgrade Thunderhub
THUNDERHUB_UPGRADE_URL=https://github.com/apotdevin/thunderhub/archive/v0.8.8.tar.gz THUNDERHUB_UPGRADE_URL=https://github.com/apotdevin/thunderhub/archive/v0.8.13.tar.gz
THUNDERHUB_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.thunderhub_url THUNDERHUB_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.thunderhub_url
CURRENT="" CURRENT=""
if [ -f $THUNDERHUB_UPGRADE_URL_FILE ]; then if [ -f $THUNDERHUB_UPGRADE_URL_FILE ]; then

View File

@ -282,6 +282,14 @@ if [ ! -L /home/bitcoin/.specter ]; then
sudo -u bitcoin ln -s /mnt/hdd/mynode/specter /home/bitcoin/.specter sudo -u bitcoin ln -s /mnt/hdd/mynode/specter /home/bitcoin/.specter
fi fi
# Setup Thunderhub
if [ -f /mnt/hdd/mynode/thunderhub/thub_config.yaml ]; then
if [ -f /home/bitcoin/.mynode/.hashedpw_bcrypt ]; then
HASH_BCRYPT=$(cat /home/bitcoin/.mynode/.hashedpw_bcrypt)
sed -i "s/masterPassword:.*/masterPassword: 'thunderhub-$HASH_BCRYPT'/g" /mnt/hdd/mynode/thunderhub/thub_config.yaml
fi
fi
# Setup udev # Setup udev
chown root:root /etc/udev/rules.d/* || true chown root:root /etc/udev/rules.d/* || true
udevadm trigger udevadm trigger

View File

@ -1,4 +1,4 @@
masterPassword: 'bolt' # Default password unless defined in account masterPassword: 'thunderhub-$2b$12$IMmGa2C29byHS7TkaAzMcuptaAQgthisisgarbage' # Invalid password unless defined in account
accounts: accounts:
- name: 'localhost' - name: 'localhost'
serverUrl: '127.0.0.1:10009' serverUrl: '127.0.0.1:10009'

View File

@ -40,8 +40,13 @@ def login(password):
increase_recent_invalid_login_attempts() increase_recent_invalid_login_attempts()
return False return False
else: else:
# Setup settion info
session["logged_in"] = True session["logged_in"] = True
session.permanent = True session.permanent = True
# Call change password to ensure hash files are up to date
subprocess.call(['/usr/bin/mynode_chpasswd.sh', password])
return True return True
def logout(): def logout():