You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.0 KiB

5 years ago
#!/bin/bash -e
RELEASE=$1
5 years ago
UMBREL_ROOT=$2
5 years ago
UMBREL_USER=$3
5 years ago
echo
5 years ago
echo "======================================="
echo "============= OTA UPDATE =============="
echo "======================================="
echo "=========== Stage: Install ============"
echo "======================================="
echo
cat <<EOF > $UMBREL_ROOT/statuses/update-status.json
5 years ago
{"state": "installing", "progress": 33, "description": "Configuring settings"}
EOF
# Checkout to the new release
cd /tmp/umbrel-$RELEASE
echo "Removing unwanted stuff"
# Remove unwanted stuff
rm -rf bitcoin
rm -rf db
5 years ago
rm -rf lnd
5 years ago
rm -rf secrets
5 years ago
rm -rf signals
rm -rf statuses
rm -rf tor
5 years ago
# Update RPC Password in docker-compose.yml
echo "Updating RPC Password in docker-compose.yml"
5 years ago
RPCPASS=`cat $UMBREL_ROOT/secrets/rpcpass.txt`
5 years ago
sed -i "s/RPCPASS/${RPCPASS}/g;" docker-compose.yml
echo "Setting regtest"
sed -i 's/mainnet/regtest/g; ' docker-compose.yml
sed -i "s/RPCPORT/18443/g;" docker-compose.yml
# Pull new images
echo "Pulling new images"
5 years ago
cat <<EOF > $UMBREL_ROOT/statuses/update-status.json
5 years ago
{"state": "installing", "progress": 40, "description": "Downloading new Docker images"}
EOF
docker-compose --file /tmp/umbrel-$RELEASE/docker-compose.yml pull
# Stop existing containers
echo "Stopping existing containers"
5 years ago
cat <<EOF > $UMBREL_ROOT/statuses/update-status.json
5 years ago
{"state": "installing", "progress": 70, "description": "Removing old containers"}
EOF
5 years ago
su - $UMBREL_USER -c "cd $UMBREL_ROOT; docker-compose down"
5 years ago
# Overlay home dir structure with new dir tree
5 years ago
echo "Overlaying $UMBREL_ROOT/ with new directory tree"
5 years ago
rsync -av /tmp/umbrel-$RELEASE/ \
--exclude='.*' \
5 years ago
$UMBREL_ROOT/
5 years ago
5 years ago
# Fix permissions
5 years ago
echo "Fixing permissions"
5 years ago
chown -R $UMBREL_USER:$UMBREL_USER $UMBREL_ROOT/
5 years ago
# Start updated containers
echo "Starting new containers"
5 years ago
cat <<EOF > $UMBREL_ROOT/statuses/update-status.json
5 years ago
{"state": "installing", "progress": 80, "description": "Starting new containers"}
EOF
5 years ago
su - $UMBREL_USER -c "cd $UMBREL_ROOT; docker-compose up --detach --remove-orphans"