#!/bin/bash # Exit immediately if a command exits with a non-zero status set -e # --- CONFIGURATION --- DB_NAME="JOUW_DATABASE_NAAM" EMULATOR_SERVICE="YOUR_SERVICE_NAME" SQL_DIR="/var/www/emulator/Emulator/sql" # --------------------- echo "=== Starting EPIC WEB CONTROL Update ===" # ---------------------------------------- # 1. Update and Build Emulator # ---------------------------------------- echo "--> Updating Emulator..." cd /var/www/emulator/Emulator/ git pull # --- Automatic SQL Import --- echo "--> Checking for new SQL files..." if [ -d "$SQL_DIR" ]; then find "$SQL_DIR" -name "*.sql" -mmin -10 | while read -r sql_file; do echo "--> Importing new SQL file: $(basename "$sql_file")" mysql "$DB_NAME" < "$sql_file" done else echo "--> SQL directory not found, skipping SQL import." fi echo "--> Building Emulator with Maven..." mvn package # Automatically detect the newly built .jar file JAR_FILE=$(basename $(ls -t target/Habbo-*-jar-with-dependencies.jar | head -n 1)) echo "--> Found jar file: $JAR_FILE" echo "--> Updating emulator launch file..." cd target/ cat << EOF > emulator #!/bin/bash java -Xmx2G -jar $JAR_FILE EOF chmod +x emulator # ---------------------------------------- # 2. Update Nitro_Render_V3 # ---------------------------------------- echo "--> Updating Nitro_Render_V3..." cd /var/www/Nitro_Render_V3/ # Check if package.json will change after git pull if git diff --name-only HEAD..@{u} | grep -q 'package.json'; then NEED_YARN_RENDER=true else NEED_YARN_RENDER=false fi git pull if [ "$NEED_YARN_RENDER" = true ]; then echo "--> package.json changed! Cleaning node_modules from Nitro_Render_V3..." rm -rf node_modules echo "--> Running yarn install for Nitro_Render_V3..." yarn install else echo "--> No changes in package.json for Nitro_Render_V3. Skipping yarn install." fi # ---------------------------------------- # 3. Update and Build Nitro-V3 # ---------------------------------------- echo "--> Updating Nitro-V3..." cd /var/www/Nitro-V3 # Check if package.json will change after git pull if git diff --name-only HEAD..@{u} | grep -q 'package.json'; then NEED_YARN_V3=true else NEED_YARN_V3=false fi git pull if [ "$NEED_YARN_V3" = true ]; then echo "--> package.json changed! Cleaning node_modules from Nitro-V3..." rm -rf node_modules echo "--> Running yarn install for Nitro-V3..." yarn install else echo "--> No changes in package.json for Nitro-V3. Skipping yarn install." fi echo "--> Building Nitro-V3 with Yarn..." yarn build # ---------------------------------------- # 4. Restart the Service # ---------------------------------------- echo "--> Restarting $EMULATOR_SERVICE service..." systemctl restart $EMULATOR_SERVICE echo "--> Checking service status..." systemctl status $EMULATOR_SERVICE --no-pager -n 5 echo "=== Update successfully completed! ==="