mirror of
https://github.com/Retropex/apolloapi-v2.git
synced 2025-05-14 20:20:49 +02:00
115 lines
2.8 KiB
Bash
Executable File
115 lines
2.8 KiB
Bash
Executable File
#!/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
|
|
|
|
yarn cache clean
|
|
|
|
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}"
|