支持自动识别目录
This commit is contained in:
34
update.sh
34
update.sh
@@ -6,10 +6,10 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Config
|
# Config
|
||||||
APP_DIR="/opt/promdata-panel"
|
|
||||||
SERVICE_NAME="promdatapanel"
|
SERVICE_NAME="promdatapanel"
|
||||||
|
DEFAULT_APP_DIR="/opt/promdata-panel"
|
||||||
|
|
||||||
# 1. Colors for logs
|
# 1. Colors & Banner
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
BLUE='\033[0;34m'
|
BLUE='\033[0;34m'
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
@@ -17,15 +17,33 @@ NC='\033[0m' # No Color
|
|||||||
|
|
||||||
echo -e "${BLUE}=== Starting PromdataPanel Update ===${NC}"
|
echo -e "${BLUE}=== Starting PromdataPanel Update ===${NC}"
|
||||||
|
|
||||||
# Detect if we're in the app directory
|
# 2. Detect APP_DIR automatically from systemd service
|
||||||
if [ ! -d ".git" ]; then
|
if systemctl list-unit-files | grep -q "^$SERVICE_NAME.service"; then
|
||||||
if [ -d "$APP_DIR/.git" ]; then
|
echo "Detecting application directory from systemd service..."
|
||||||
cd "$APP_DIR"
|
# Get WorkingDirectory from systemd (using env to handle it safely)
|
||||||
|
SERVICE_DIR=$(systemctl show -p WorkingDirectory "$SERVICE_NAME" | cut -d= -f2-)
|
||||||
|
if [ -n "$SERVICE_DIR" ] && [ -d "$SERVICE_DIR" ]; then
|
||||||
|
APP_DIR="$SERVICE_DIR"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fallback 1: Current directory if it contains package.json
|
||||||
|
if [ -z "$APP_DIR" ]; then
|
||||||
|
if [ -f "package.json" ]; then
|
||||||
|
APP_DIR=$(pwd)
|
||||||
else
|
else
|
||||||
echo -e "${RED}Error: Not in a git repository or $APP_DIR. Please run this from the app root.${NC}"
|
APP_DIR="$DEFAULT_APP_DIR"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${BLUE}Application directory: $APP_DIR${NC}"
|
||||||
|
|
||||||
|
if [ ! -d "$APP_DIR" ]; then
|
||||||
|
echo -e "${RED}Error: Could not find application directory at $APP_DIR. Check if you installed it correctly.${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
cd "$APP_DIR"
|
||||||
|
|
||||||
# 2. Update logic
|
# 2. Update logic
|
||||||
if [ -d ".git" ]; then
|
if [ -d ".git" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user