-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
131 lines (115 loc) · 3.8 KB
/
install.sh
File metadata and controls
131 lines (115 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
#
# Remote installer for dbus-virtual-dcsystem on Venus OS
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/TechBlueprints/dbus-virtual-dcsystem/main/install.sh | bash
#
set -e
REPO_URL="https://github.com/TechBlueprints/dbus-virtual-dcsystem.git"
INSTALL_DIR="/data/apps/dbus-virtual-dcsystem"
SERVICE_NAME="dbus-virtual-dcsystem"
echo "========================================"
echo "Virtual DC System Service Installer"
echo "========================================"
echo ""
# Check if running on Venus OS
if [ ! -d "/data/apps" ]; then
echo "Error: /data/apps not found. This script must run on Venus OS."
exit 1
fi
# Step 1: Ensure git is installed
echo "Step 1: Checking for git..."
if ! command -v git >/dev/null 2>&1; then
echo "Git not found. Installing git..."
if ! opkg install git; then
echo "Error: Failed to install git."
exit 1
fi
echo "Git installed successfully"
else
echo "Git already installed"
fi
echo ""
# Step 2: Clone or update repository
echo "Step 2: Setting up repository..."
cd /data/apps
NEEDS_RESTART=false
if [ -d "$INSTALL_DIR" ]; then
echo "Directory exists: $INSTALL_DIR"
cd "$INSTALL_DIR"
git config --global --add safe.directory "$INSTALL_DIR" 2>/dev/null || true
if [ -d .git ]; then
CURRENT_REMOTE=$(git remote get-url origin 2>/dev/null || echo "")
if [ "$CURRENT_REMOTE" != "$REPO_URL" ]; then
echo "Updating remote URL to $REPO_URL..."
git remote set-url origin "$REPO_URL" 2>/dev/null || git remote add origin "$REPO_URL"
fi
echo "Fetching latest changes..."
git fetch origin
LOCAL=$(git rev-parse HEAD 2>/dev/null || echo "none")
REMOTE=$(git rev-parse origin/main 2>/dev/null || echo "none")
if [ "$LOCAL" != "$REMOTE" ]; then
echo "Updates available. Resetting to latest..."
git checkout main 2>/dev/null || git checkout -b main origin/main
git reset --hard origin/main
NEEDS_RESTART=true
echo "Repository updated to latest"
else
echo "Already up to date"
fi
else
echo "Not a git repository. Converting..."
git init
git remote add origin "$REPO_URL"
git fetch origin
git checkout -b main origin/main 2>/dev/null || git checkout main
git reset --hard origin/main
git branch --set-upstream-to=origin/main main 2>/dev/null || true
NEEDS_RESTART=true
echo "Converted to git repository and updated to latest"
fi
else
echo "Directory does not exist. Cloning repository..."
git clone "$REPO_URL" "$INSTALL_DIR"
cd "$INSTALL_DIR"
git config --global --add safe.directory "$INSTALL_DIR" 2>/dev/null || true
echo "Repository cloned"
fi
echo ""
# Step 3: Run enable script
echo "Step 3: Enabling service..."
bash "$INSTALL_DIR/enable.sh"
echo ""
# Step 4: Start or restart service
echo "Step 4: Starting service..."
if svstat "/service/$SERVICE_NAME" 2>/dev/null | grep -q "up"; then
if [ "$NEEDS_RESTART" = true ]; then
echo "Restarting service to apply updates..."
svc -t "/service/$SERVICE_NAME"
sleep 2
echo "Service restarted"
else
echo "Service already running, no updates needed"
fi
else
svc -u "/service/$SERVICE_NAME"
sleep 2
echo "Service started"
fi
echo ""
echo "========================================"
echo "Installation Complete!"
echo "========================================"
echo ""
echo "Service status:"
svstat "/service/$SERVICE_NAME"
echo ""
echo "View logs:"
echo " tail -f /var/log/$SERVICE_NAME/current"
echo ""
echo "Service management:"
echo " svc -u /service/$SERVICE_NAME # Start"
echo " svc -d /service/$SERVICE_NAME # Stop"
echo " svc -t /service/$SERVICE_NAME # Restart"
echo ""