-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
54 lines (42 loc) · 1.69 KB
/
install.sh
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
#!/bin/sh
# install.sh - Script to download and install the latest keenetic-pbr release for OpenWRT
# Function to check for internet connection
check_internet() {
curl -s "localhost:79/rci/show/internet/status" | grep -E 'gateway-accessible|dns-accessible|internet|captive-accessible' | grep -q false
}
# Function to get the latest release package URL for the correct architecture
get_latest_package_url() {
ARCH=$(opkg print-architecture | grep -v 'all' | awk 'NR==1{print $2}')
RELEASE_URL="https://api.github.com/repos/maksimkurb/keenetic-pbr/releases/latest"
PACKAGE_URL=$(curl -sH "Accept: application/vnd.github.v3+json" "$RELEASE_URL" | jq -r '.assets[] | select(.name | contains("'"$ARCH"'")) | .browser_download_url')
echo "$PACKAGE_URL"
}
# Main script starts here
echo "Checking for internet connection..."
if check_internet; then
echo "[ERROR] No internet connection detected. Please check your connection and try again."
exit 1
fi
echo "Internet connection available. Proceeding..."
# Get the download URL for the latest release
PACKAGE_URL=$(get_latest_package_url)
if [ -z "$PACKAGE_URL" ]; then
echo "[ERROR] Could not find a compatible package for your architecture."
exit 1
fi
PACKAGE_NAME=$(basename "$PACKAGE_URL")
# Download the package
echo "Downloading package: $PACKAGE_NAME"
curl -L -o "/tmp/$PACKAGE_NAME" "$PACKAGE_URL"
# Install the downloaded package
echo "Installing package..."
opkg update
opkg install "/tmp/$PACKAGE_NAME"
if [ $? -eq 0 ]; then
echo "Package installed successfully."
else
echo "[ERROR] Failed to install package. Please check the log for details."
fi
# Clean up
rm -f "/tmp/$PACKAGE_NAME"
echo "Installation script completed."