Refactor user init

This commit is contained in:
Taylor Helsper 2023-08-27 15:32:31 -05:00
parent 9919dc061f
commit 11456128a6
6 changed files with 42 additions and 29 deletions

View File

@ -12,7 +12,7 @@ EnvironmentFile=/mnt/hdd/mynode/settings/.btcrpc_environment
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStartPre=/usr/bin/wait_on_bitcoin.sh
ExecStartPre=/usr/bin/wait_on_docker_image_install.sh
ExecStartPre=/usr/bin/service_scripts/pre_mempool.sh
ExecStartPre=+/usr/bin/service_scripts/pre_mempool.sh
ExecStart=/usr/local/bin/docker-compose up
ExecStartPost=/usr/bin/service_scripts/post_mempool.sh
@ -22,8 +22,8 @@ ExecStop=/usr/local/bin/docker-compose down
#ExecStart=/usr/bin/docker run --rm --name mempoolspace -p 4080:80 -e BITCOIN_NODE_HOST=172.17.0.1 -e BITCOIN_NODE_USER=mynode -e BITCOIN_NODE_PASS=${BTC_RPC_PASSWORD} -e MEMPOOL_REFRESH_RATE_MS=10000 mempoolspace
#ExecStop=/usr/bin/docker stop -t 2 mempoolspace
User=root
Group=root
User=mempool
Group=mempool
Type=simple
TimeoutSec=180
Restart=always

View File

@ -0,0 +1,28 @@
#!/bin/bash
# Create any necessary users
useradd -m -s /bin/bash pivpn || true
useradd -m -s /bin/bash joinmarket || true
useradd -m -s /bin/bash mempool || true
# Setup bitcoin user folders
mkdir -p /home/bitcoin/.mynode/
chown -R bitcoin:bitcoin /home/bitcoin/.mynode/
# Add users to groups
bitcoin_users="admin joinmarket mempool"
for bitcoin_user in $bitcoin_users; do
adduser $bitcoin_user bitcoin
done
docker_users="admin mempool"
for docker_user in $docker_users; do
adduser $docker_user docker
done
sudo_users="admin"
for sudo_user in $sudo_users; do
adduser $sudo_user sudo
done
# User updates and settings
grep "joinmarket" /etc/sudoers || (echo 'joinmarket ALL=(ALL) NOPASSWD:ALL' | EDITOR='tee -a' visudo)
passwd -l root

View File

@ -36,18 +36,8 @@ if ! skip_base_upgrades ; then
# Update SD card
mkdir -p /etc/torrc.d
# Create any necessary users
useradd -m -s /bin/bash joinmarket || true
# Setup bitcoin user folders
mkdir -p /home/bitcoin/.mynode/
chown -R bitcoin:bitcoin /home/bitcoin/.mynode/
# User updates and settings
adduser admin bitcoin
adduser joinmarket bitcoin
grep "joinmarket" /etc/sudoers || (echo 'joinmarket ALL=(ALL) NOPASSWD:ALL' | EDITOR='tee -a' visudo)
passwd -l root
# Initialize Users
/usr/bin/mynode_initialize_users.sh
# Migrate from version file to version+install combo
/usr/bin/mynode_migrate_version_files.sh

View File

@ -256,14 +256,8 @@ rm -rf $MYNODE_DIR/.mynode_bitcoin_synced
cp -f /home/bitcoin/.mynode/.product_key* /mnt/hdd/mynode/settings/ || true
cp -f /mnt/hdd/mynode/settings/.product_key* home/bitcoin/.mynode/ || true
# Make any users we need to
useradd -m -s /bin/bash pivpn || true
useradd -m -s /bin/bash joinmarket || true
# User updates and settings
adduser admin bitcoin
adduser joinmarket bitcoin
grep "joinmarket" /etc/sudoers || (echo 'joinmarket ALL=(ALL) NOPASSWD:ALL' | EDITOR='tee -a' visudo)
# Initialize Users
/usr/bin/mynode_initialize_users.sh
# Regen SSH keys (check if force regen or keys are missing / empty)
while [ ! -f /home/bitcoin/.mynode/.gensshkeys ] ||

View File

@ -17,4 +17,6 @@ if [ $IS_RASPI -eq 1 ] && [ $IS_RASPI4_ARM64 -eq 0 ]; then
sed -i "s|MARIA_DB_IMAGE=.*|MARIA_DB_IMAGE=hypriot/rpi-mysql:latest|g" /mnt/hdd/mynode/mempool/.env
else
sed -i "s|MARIA_DB_IMAGE=.*|MARIA_DB_IMAGE=mariadb:10.9.3|g" /mnt/hdd/mynode/mempool/.env
fi
fi
chown -R mempool:mempool /mnt/hdd/mynode/mempool

View File

@ -138,12 +138,11 @@ source /tmp/upgrade/out/rootfs_*/usr/share/mynode/mynode_app_versions.sh
# Update SD card
mkdir -p /etc/torrc.d
# Create any necessary users
# Set admin password to bolt
useradd -p $(openssl passwd -1 bolt) -m -s /bin/bash admin || true
useradd -m -s /bin/bash bitcoin || true
useradd -m -s /bin/bash joinmarket || true
passwd -l root
adduser admin sudo
# Initialize Users
/bin/bash $TMP_INSTALL_PATH/usr/bin/mynode_initialize_users.sh
# Setup bitcoin user folders
mkdir -p /home/bitcoin/.mynode/