#!/bin/bash # Configuration SERVER_USER="root" SERVER_IP="155.254.30.254" SERVER_DIR="~/node-ejs-renderer" SERVER_DIR_HOME="~" LOCAL_DIR="/Users/emkay/Projects/node-ejs-renderer" NGINX_CONFIG="node-ejs-renderer" # Name of the Nginx config file DOMAIN_OR_IP="the.mk" # Your domain or IP address EMAIL="mahesh.kommareddi@the.mk" # Your email for Let's Encrypt # Commands to run on the remote server REMOTE_COMMANDS=$(cat </dev/null; echo "0 0,12 * * * root certbot renew --quiet") | crontab - # Change to the project directory cd $SERVER_DIR # Install project dependencies npm install # Start the application with pm2 pm2 start server.js pm2 save pm2 startup EOF ) # Copy project files to the remote server rsync -avz --exclude 'node_modules' --exclude '.git' $LOCAL_DIR $SERVER_USER@$SERVER_IP:$SERVER_DIR_HOME # Run the commands on the remote server ssh $SERVER_USER@$SERVER_IP "$REMOTE_COMMANDS" echo "Deployment complete!"