Browse Source

chore: add update.sh script

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/7612/head
Pranav C 8 months ago
parent
commit
7b692f1502
  1. 37
      docker-compose/setup-script/noco.sh

37
docker-compose/setup-script/noco.sh

@ -233,7 +233,7 @@ services:
labels: labels:
- "com.centurylinklabs.watchtower.enable=true" - "com.centurylinklabs.watchtower.enable=true"
db: db:
image: postgres:latest image: postgres:16.1
env_file: docker.env env_file: docker.env
volumes: volumes:
- ./postgres:/var/lib/postgresql/data - ./postgres:/var/lib/postgresql/data
@ -250,7 +250,7 @@ services:
- ./nginx:/etc/nginx/conf.d - ./nginx:/etc/nginx/conf.d
EOF EOF
if [ "$SSL_ENABLED" = 'y' ]; then if [ "$SSL_ENABLED" = 'y' ] || [ "$SSL_ENABLED" = 'Y' ]; then
cat <<EOF >> docker-compose.yml cat <<EOF >> docker-compose.yml
- webroot:/var/www/certbot - webroot:/var/www/certbot
- ./letsencrypt:/etc/letsencrypt - ./letsencrypt:/etc/letsencrypt
@ -266,7 +266,7 @@ cat <<EOF >> docker-compose.yml
restart: unless-stopped restart: unless-stopped
EOF EOF
if [ "$SSL_ENABLED" = 'y' ]; then if [ "$SSL_ENABLED" = 'y' ] || [ "$SSL_ENABLED" = 'Y' ]; then
cat <<EOF >> docker-compose.yml cat <<EOF >> docker-compose.yml
certbot: certbot:
image: certbot/certbot image: certbot/certbot
@ -292,7 +292,7 @@ cat <<EOF >> docker-compose.yml
EOF EOF
fi fi
if [ "$SSL_ENABLED" = 'y' ]; then if [ "$SSL_ENABLED" = 'y' ] || [ "$SSL_ENABLED" = 'Y' ]; then
cat <<EOF >> docker-compose.yml cat <<EOF >> docker-compose.yml
volumes: volumes:
letsencrypt-lib: letsencrypt-lib:
@ -317,7 +317,7 @@ server {
listen 80; listen 80;
EOF EOF
if [ "$SSL_ENABLED" = 'y' ]; then if [ "$SSL_ENABLED" = 'y' ] || [ "$SSL_ENABLED" = 'Y' ]; then
cat >> ./nginx/default.conf <<EOF cat >> ./nginx/default.conf <<EOF
server_name $DOMAIN_NAME; server_name $DOMAIN_NAME;
EOF EOF
@ -333,7 +333,7 @@ cat >> ./nginx/default.conf <<EOF
} }
EOF EOF
if [ "$SSL_ENABLED" = 'y' ]; then if [ "$SSL_ENABLED" = 'y' ] || [ "$SSL_ENABLED" = 'Y' ]; then
cat >> ./nginx/default.conf <<EOF cat >> ./nginx/default.conf <<EOF
location /.well-known/acme-challenge/ { location /.well-known/acme-challenge/ {
root /var/www/certbot; root /var/www/certbot;
@ -344,7 +344,7 @@ cat >> ./nginx/default.conf <<EOF
} }
EOF EOF
if [ "$SSL_ENABLED" = 'y' ]; then if [ "$SSL_ENABLED" = 'y' ] || [ "$SSL_ENABLED" = 'Y' ]; then
mkdir -p ./nginx-post-config mkdir -p ./nginx-post-config
@ -386,28 +386,37 @@ server {
EOF EOF
fi fi
# Generate the update.sh file for upgrading images
cat > ./update.sh <<EOF
docker-compose pull
docker-compose up -d --force-recreate
docker image prune -a -f
EOF
message_arr+=("Update script: update.sh")
# Start the docker-compose setup # Start the docker-compose setup
docker-compose up -d sudo docker-compose up -d
echo 'Waiting for Nginx to start...'; echo 'Waiting for Nginx to start...';
sleep 5 sleep 5
if [ "$SSL_ENABLED" = 'y' ]; then if [ "$SSL_ENABLED" = 'y' ] || [ "$SSL_ENABLED" = 'Y' ]; then
echo 'Starting Letsencrypt certificate request...'; echo 'Starting Letsencrypt certificate request...';
# Initial Let's Encrypt certificate request # Initial Let's Encrypt certificate request
docker-compose exec certbot certbot certonly --webroot --webroot-path=/var/www/certbot -d $DOMAIN_NAME --email contact@$DOMAIN_NAME --agree-tos --no-eff-email && echo "Certificate request successful" || echo "Certificate request failed" sudo docker-compose exec certbot certbot certonly --webroot --webroot-path=/var/www/certbot -d $DOMAIN_NAME --email contact@$DOMAIN_NAME --agree-tos --no-eff-email && echo "Certificate request successful" || echo "Certificate request failed"
# Update the nginx config to use the new certificates # Update the nginx config to use the new certificates
rm -rf ./nginx/default.conf sudo rm -rf ./nginx/default.conf
mv ./nginx-post-config/default.conf ./nginx/ sudo mv ./nginx-post-config/default.conf ./nginx/
rm -r ./nginx-post-config sudo rm -r ./nginx-post-config
echo "Restarting nginx to apply the new certificates" echo "Restarting nginx to apply the new certificates"
# Reload nginx to apply the new certificates # Reload nginx to apply the new certificates
docker-compose exec nginx nginx -s reload sudo docker-compose exec nginx nginx -s reload
message_arr+=("NocoDB is now available at https://$DOMAIN_NAME") message_arr+=("NocoDB is now available at https://$DOMAIN_NAME")

Loading…
Cancel
Save