Files
ente_setup/setup_ente_web.sh

79 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# This script assumes you have already configured the .env.local file in the photos app directory
# set the local repo location
LOCAL_REPO="/home/mason/src/ente"
cd $LOCAL_REPO/web
# make sure that all the previous build steps have been completed
# the following steps are required to build the photos app
#git submodule update --init --recursive
#yarn install
#yarn build:photos # puts the built files in the web/apps/photos/out directory
echo "$LOCAL_REPO/web/apps/photos/out"
# make sure the photos app is built
if [ ! -d "$LOCAL_REPO/web/apps/photos/out" ]; then
echo "The photos app has not been built. Please build the app and rerun the script."
# print the steps to build the photos app
echo "To build the photos app, run the following commands:"
echo "cd $LOCAL_REPO/web"
echo "git submodule update --init --recursive"
echo "yarn install"
echo "yarn build:photos"
exit 1
fi
# make sure the destination directory exists
sudo mkdir -p /var/www/ente
sudo cp -r $LOCAL_REPO/web/apps/photos/out /var/www/ente/photos
# configure nginx to serve the photos app on ente.sa.vin
sudo tee /etc/nginx/sites-available/ente.sa.vin.conf > /dev/null <<EOL
server {
listen 80;
server_name ente.sa.vin;
location / {
root /var/www/ente/photos;
index index.html;
try_files \$uri /index.html;
}
}
EOL
# create a symbolic link to enable the site
sudo ln -s /etc/nginx/sites-available/ente.sa.vin.conf /etc/nginx/sites-enabled/
# Also configure nginx to serve the same photos app on entep.sa.vin
sudo tee /etc/nginx/sites-available/entep.sa.vin.conf > /dev/null <<EOL
server {
listen 80;
server_name entep.sa.vin;
location / {
root /var/www/ente/photos;
index index.html;
try_files \$uri /index.html;
}
}
EOL
sudo ln -s /etc/nginx/sites-available/entep.sa.vin.conf /etc/nginx/sites-enabled/
# reload nginx to apply changes
sudo systemctl reload nginx
# use certbot to add SSL certificate for the photos app
sudo certbot --nginx -d ente.sa.vin -d entep.sa.vin
echo "Ente web app has been set up successfully. Access the app at https://ente.sa.vin or https://entep.sa.vin"