#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" load_env_file() { local env_file="$1" if [[ -f "$env_file" ]]; then set -a # shellcheck disable=SC1090 source "$env_file" set +a fi } load_env_file "$ROOT_DIR/.env.local" if [[ -f "$ROOT_DIR/backend/.env" ]]; then load_env_file "$ROOT_DIR/backend/.env" if [[ -n "${client_id:-}" ]]; then export AIHR_ORG_SYNC_CLIENT_ID="$client_id" fi if [[ -n "${client_secret:-}" ]]; then export AIHR_ORG_SYNC_CLIENT_SECRET="$client_secret" fi fi cd "$ROOT_DIR/backend" mkdir -p "$ROOT_DIR/.data/import" JAR="ruoyi-admin/target/ruoyi-admin.jar" NEEDS_BUILD=false BACKEND_PORT="${PORT:-8080}" if [[ ! -f "$JAR" ]]; then NEEDS_BUILD=true elif find ruoyi-admin ruoyi-common ruoyi-modules -type f \( -name '*.java' -o -name '*.xml' -o -name '*.yml' -o -name 'pom.xml' \) -newer "$JAR" -print -quit | grep -q .; then NEEDS_BUILD=true fi if [[ "$NEEDS_BUILD" == true ]]; then mvn -pl ruoyi-admin -am -DskipTests clean package fi exec java -jar "$JAR" \ "--server.port=$BACKEND_PORT" \ "--captcha.enable=${AIHR_DEV_CAPTCHA_ENABLED:-false}" \ "--spring.datasource.dynamic.datasource.master.url=jdbc:mysql://localhost:13306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true" \ "--spring.data.redis.port=16379" \ "--spring.boot.admin.client.enabled=false" \ "--snail-job.enabled=false" \ "--aihr.import.root=$ROOT_DIR/.data/import"