-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·146 lines (122 loc) · 4.18 KB
/
install.sh
File metadata and controls
executable file
·146 lines (122 loc) · 4.18 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
#
# Remote installer for dbus-aggregate-smartshunts on Venus OS
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/TechBlueprints/dbus-aggregate-smartshunts/main/install.sh | bash
#
set -e
REPO_URL="https://github.com/TechBlueprints/dbus-aggregate-smartshunts.git"
INSTALL_DIR="/data/apps/dbus-aggregate-smartshunts"
SERVICE_NAME="dbus-aggregate-smartshunts"
echo "========================================"
echo "SmartShunt Aggregator 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"
# Check if it's already a git repository
if [ -d .git ]; then
echo "Already a git repository. Checking for updates..."
# Fetch latest changes
git fetch origin
# Check if there are differences
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse origin/main)
if [ "$LOCAL" != "$REMOTE" ]; then
echo "Updates available. Pulling latest changes..."
git pull
NEEDS_RESTART=true
echo "✓ Repository updated"
else
echo "✓ Already up to date"
fi
else
echo "Not a git repository. Converting to git repository..."
# Initialize as git repo
git init
# Add to safe directories (ownership consideration)
git config --global --add safe.directory "$INSTALL_DIR"
# Add remote
git remote add origin "$REPO_URL"
# Fetch and reset to main
git fetch origin
git checkout -b main
git reset --hard origin/main
git branch --set-upstream-to=origin/main main
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"
# Add to safe directories
git config --global --add safe.directory "$INSTALL_DIR"
NEEDS_RESTART=false # New install, not a restart
echo "✓ Repository cloned"
fi
echo ""
# Step 3: Install or restart service
echo "Step 3: Installing/updating service..."
# Check if service is already running
if [ -L "/service/$SERVICE_NAME" ] && svstat "/service/$SERVICE_NAME" 2>/dev/null | grep -q "up"; then
if [ "$NEEDS_RESTART" = true ]; then
echo "Service is already installed and running."
echo "Updates detected. Restarting service..."
svc -t "/service/$SERVICE_NAME"
sleep 2
# Verify it restarted
if svstat "/service/$SERVICE_NAME" 2>/dev/null | grep -q "up"; then
echo "✓ Service restarted successfully"
else
echo "Warning: Service may not have restarted properly. Check logs:"
echo " tail -f /var/log/$SERVICE_NAME/current"
fi
else
echo "Service is already installed and running."
echo "✓ No updates needed"
fi
else
echo "Service not installed or not running. Running installation..."
bash "$INSTALL_DIR/install-service.sh"
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 ""