mirror of
https://github.com/Retropex/apolloapi-v2.git
synced 2025-05-14 20:20:49 +02:00
84 lines
2.9 KiB
Bash
Executable File
84 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m'
|
|
TMPFILE='/tmp/update_progress'
|
|
APOLLO_DIR=/opt/apolloapi
|
|
|
|
### SYSTEM commands ###
|
|
# Write down this line the system commands needed
|
|
|
|
### Update Miner/Node Binaries ###
|
|
|
|
echo -e "${YELLOW} ---> Updating System binaries${NC}"
|
|
|
|
arch=$(uname -m)
|
|
|
|
cp $APOLLO_DIR/backend/apollo-miner/bin/$arch/apollo-miner $APOLLO_DIR/backend/apollo-miner/futurebit-miner
|
|
cp $APOLLO_DIR/backend/apollo-miner/bin/$arch/apollo-miner-v2 $APOLLO_DIR/backend/apollo-miner/futurebit-miner-v2
|
|
cp $APOLLO_DIR/backend/apollo-miner/bin/$arch/apollo-helper $APOLLO_DIR/backend/apollo-miner/
|
|
|
|
### Bitcoind ###
|
|
#########################
|
|
cp $APOLLO_DIR/backend/node/bin/$arch/bitcoind $APOLLO_DIR/backend/node/bitcoind
|
|
cp $APOLLO_DIR/backend/default-configs/bitcoin.conf $APOLLO_DIR/backend/node/
|
|
|
|
### ckpool ###
|
|
#########################
|
|
cp $APOLLO_DIR/backend/ckpool/bin/$arch/ckpool $APOLLO_DIR/backend/ckpool/
|
|
cp $APOLLO_DIR/backend/default-configs/ckpool.conf $APOLLO_DIR/backend/ckpool/
|
|
|
|
### Write back the Bitcoin RPC password on conf file
|
|
PASS=`sqlite3 $APOLLO_DIR/futurebit.sqlite "SELECT node_rpc_password FROM settings ORDER BY id DESC LIMIT 1;"`
|
|
|
|
if [ -z "$PASS" ]
|
|
then
|
|
echo "Bitcoin password is empty will be generated by the app"
|
|
else
|
|
sed -i s/rpcpassword=/rpcpassword=${PASS}/ $APOLLO_DIR/backend/node/bitcoin.conf
|
|
fi
|
|
|
|
### Set Bitcoin max connections to 64 by default if set to 32
|
|
MAXCONNECTIONS=`sqlite3 $APOLLO_DIR/futurebit.sqlite "SELECT node_max_connections FROM settings ORDER BY id DESC LIMIT 1;"`
|
|
|
|
# Function to set Bitcoin max connections to 64
|
|
set_max_connections() {
|
|
echo "Bitcoin max connections set to 64"
|
|
sed -i 's/maxconnections=32/maxconnections=64/' "$APOLLO_DIR/backend/node/bitcoin.conf"
|
|
sqlite3 "$APOLLO_DIR/futurebit.sqlite" "UPDATE settings SET node_max_connections = 64 WHERE ID = (SELECT MAX(ID) FROM settings);"
|
|
}
|
|
|
|
# Check if MAXCONNECTIONS is empty or set to 32, and apply changes if needed
|
|
if [ -z "$MAXCONNECTIONS" ]; then
|
|
echo "Bitcoin max connections is empty; setting to 64"
|
|
set_max_connections
|
|
elif [ "$MAXCONNECTIONS" -eq 32 ]; then
|
|
echo "Bitcoin max connections is set to 32; updating to 64"
|
|
set_max_connections
|
|
fi
|
|
|
|
# Don't touch below this line
|
|
echo "90" > $TMPFILE
|
|
|
|
### SYSTEMD ###
|
|
echo -e "${YELLOW} ---> Updating systemd files${NC}"
|
|
|
|
cp $APOLLO_DIR/backend/systemd/apollo-api.service /etc/systemd/system/
|
|
cp $APOLLO_DIR/backend/systemd/apollo-ui-v2.service /etc/systemd/system/
|
|
cp $APOLLO_DIR/backend/systemd/apollo-miner.service /etc/systemd/system/
|
|
cp $APOLLO_DIR/backend/systemd/node.service /etc/systemd/system/
|
|
cp $APOLLO_DIR/backend/systemd/ckpool.service /etc/systemd/system/
|
|
cp $APOLLO_DIR/backend/systemd/rc-local.service /etc/systemd/system/
|
|
|
|
echo -e "${YELLOW} ---> Reloading systemd${NC}"
|
|
systemctl daemon-reload
|
|
|
|
echo -e "${YELLOW} ---> Rebooting${NC}"
|
|
|
|
echo "100" > $TMPFILE
|
|
|
|
rm $TMPFILE
|
|
|
|
reboot
|