diff --git a/backend/ckpool/ckpool_start.sh b/backend/ckpool/ckpool_start.sh index cd58748..a6fb0bd 100755 --- a/backend/ckpool/ckpool_start.sh +++ b/backend/ckpool/ckpool_start.sh @@ -1,4 +1,7 @@ #!/bin/bash +#clear old log files +rm /opt/apolloapi/backend/ckpool/logs/ckpool.log + screen -dmS ckpool /opt/apolloapi/backend/ckpool/ckpool -B -c /opt/apolloapi/backend/ckpool/ckpool.conf diff --git a/backend/image_install b/backend/image_install index 6e9f2b8..2c1b7ca 100644 --- a/backend/image_install +++ b/backend/image_install @@ -147,6 +147,9 @@ echo -e "${GREEN} ---> Project UI dependencies installed using yarn${NC}" yarn build echo -e "${GREEN} ---> Project built using yarn${NC}" +### DOCS ### +######################### +cp $APOLLO_DIR/docs/FutureBit-Apollo-II-Guide.pdf /home/futurebit/Desktop ### FIREWALL ### ######################### diff --git a/backend/image_update b/backend/image_update new file mode 100755 index 0000000..0dffb47 --- /dev/null +++ b/backend/image_update @@ -0,0 +1,112 @@ +#!/bin/bash + +YELLOW='\033[1;33m' +RED='\033[0;31m' +NC='\033[0m' + +#This script assumes image_install has already been run previously + +if [ "$EUID" -ne 0 ] + then echo -e "${RED}Update script must be run by root or with sudo${NC}" + exit +fi + + +systemctl stop ckpool apollo-miner node apollo-api apollo-ui-v2 + +#### SYSTEM PACKAGES #### +######################### +echo -e "${YELLOW} ---> Installing and upgrading required system packages${NC}" + +# Install required system packages +apt-get update +apt-get -y upgrade + + +APOLLO_DIR=/opt/apolloapi + +git config --global --add safe.directory $APOLLO_DIR +git config --global --add safe.directory $APOLLO_DIR/apolloui-v2 + +chown -R futurebit $APOLLO_DIR + +. /usr/local/nvm/nvm.sh + +nvm use 21 + +### API ### +echo -e "${YELLOW} ---> Updating API modules${NC}" + +cd $APOLLO_DIR + +rm futurebit.sqlite + +git reset --hard +git pull + +yarn + +### UI ### +echo -e "${YELLOW} ---> Updating UI modules${NC}" + +cd $APOLLO_DIR/apolloui-v2 + +git reset --hard +git pull + +yarn + +echo -e "${YELLOW} ---> Building UI (could take few minutes)${NC}" + +yarn build + +chown -R futurebit $APOLLO_DIR + + +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/ + +### 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/ + +#SWAP +cp $APOLLO_DIR/backend/systemd/swap.service /etc/systemd/system/ + +#RC LOCAL +cp $APOLLO_DIR/backend/rc.local /etc/ +chmod +x /etc/rc.local +cp $APOLLO_DIR/backend/systemd/rc-local.service /etc/systemd/system/ + +echo -e "${YELLOW} ---> Reloading systemd${NC}" +systemctl daemon-reload + +# Enable the services +systemctl enable apollo-api.service +systemctl enable apollo-ui-v2.service +systemctl enable swap.service +systemctl enable rc-local.service +systemctl enable apollo-miner.service +systemctl enable node.service + +echo -e "${GREEN} ---> Image update complete${NC}" diff --git a/backend/update_system b/backend/update_system index e823a8a..f227f18 100755 --- a/backend/update_system +++ b/backend/update_system @@ -29,6 +29,16 @@ cp $APOLLO_DIR/backend/default-configs/bitcoin.conf $APOLLO_DIR/backend/node/ 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 + # Don't touch below this line echo "90" > $TMPFILE diff --git a/docs/FutureBit-Apollo-II-Guide.pdf b/docs/FutureBit-Apollo-II-Guide.pdf new file mode 100644 index 0000000..9fbc498 Binary files /dev/null and b/docs/FutureBit-Apollo-II-Guide.pdf differ diff --git a/src/init.js b/src/init.js index 237b0a8..fcd751b 100644 --- a/src/init.js +++ b/src/init.js @@ -31,9 +31,9 @@ const runMigrations = async () => { try { console.log('Run migrations'); const resp = await knex.migrate.latest(); - await runGenerateBitcoinPassword(); - await createBitcoinConfigFile(); await createCkpoolConfigFile(); + await createBitcoinConfigFile(); + await runGenerateBitcoinPassword(); } catch (err) { console.log(err); } diff --git a/src/utils.js b/src/utils.js index 77749ff..0a8044c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -62,6 +62,8 @@ module.exports.auth = { `sudo sed -i 's#"pass": ""#"pass": "${password}"#g' ${configCkpoolFilePath}` ); + console.log(password, configFilePath); + exec('sudo systemctl restart node'); exec('sudo systemctl restart ckpool'); } catch (err) {