#!/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 ### Install packages ### echo -e "${YELLOW} ---> Installing system packages${NC}" apt-get update DEBIAN_FRONTEND=noninteractive apt-get install -y tor sqlite3 ### Configuring Tor ### echo -e "${YELLOW} ---> Configuring Tor${NC}" cp $APOLLO_DIR/backend/torrc /etc/tor/torrc usermod -a -G debian-tor futurebit systemctl restart tor.service ### 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/node/bin/$arch/bitcoind $APOLLO_DIR/backend/node/bitcoind cp $APOLLO_DIR/backend/node/bin/bitcoin.conf $APOLLO_DIR/backend/node/bitcoin.conf ### 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=futurebit/rpcpassword=${PASS}/ $APOLLO_DIR/backend/node/bitcoin.conf fi # Don't touch below this line echo "90" > $TMPFILE ### SYSTEMD ### echo -e "${YELLOW} ---> Updating systemd files${NC}" cp $APOLLO_DIR/backend/systemd/apollo-ui.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/swap.service /etc/systemd/system/ cp $APOLLO_DIR/backend/systemd/start_swap.sh $APOLLO_DIR/backend/start_swap.sh echo -e "${YELLOW} ---> Reloading systemd${NC}" systemctl daemon-reload echo -e "${YELLOW} ---> Restarting APP${NC}" systemctl enable swap systemctl start swap systemctl restart node systemctl restart apollo-miner #Restart UI after old version of UI finishes update progress ( sleep 1 ; systemctl restart apollo-ui ) echo "100" > $TMPFILE