install.sh: fix package manager compatibility
Signed-off-by: sbwml <admin@cooluc.com>
This commit is contained in:
parent
022aab507a
commit
632788cf4b
@ -47,8 +47,13 @@
|
||||
|
||||
- Install `curl` package
|
||||
```shell
|
||||
# for opkg package manager (openwrt 21.02 ~ 24.10)
|
||||
opkg update
|
||||
opkg install curl
|
||||
|
||||
# for apk package manager
|
||||
apk update
|
||||
apk add curl
|
||||
```
|
||||
|
||||
- Execute install script (Multi-architecture support)
|
||||
@ -63,4 +68,4 @@
|
||||
|
||||
--------------
|
||||
|
||||

|
||||

|
||||
|
22
install.sh
22
install.sh
@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# Define color codes and output functions
|
||||
@ -37,9 +38,11 @@ DISTRIB_ARCH="${DISTRIB_ARCH:-unknown}"
|
||||
# Detect package manager and set SDK version
|
||||
if [ -x "/usr/bin/apk" ]; then
|
||||
PKG_MANAGER="apk"
|
||||
PKG_OPT="add --allow-untrusted"
|
||||
SDK="SNAPSHOT"
|
||||
elif command -v opkg >/dev/null 2>&1; then
|
||||
PKG_MANAGER="opkg"
|
||||
PKG_OPT="install --force-downgrade"
|
||||
SDK="openwrt-24.10"
|
||||
else
|
||||
msg_red "No supported package manager found."
|
||||
@ -129,15 +132,26 @@ if ! curl --connect-timeout 5 -m 300 -kLo "$TEMP_DIR/$PKG_FILE" "$PKG_URL"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Stop openlist service
|
||||
if [ -x "/etc/init.d/openlist" ]; then
|
||||
/etc/init.d/openlist stop || true
|
||||
fi
|
||||
|
||||
# Extract and install packages
|
||||
msg_green "Installing Packages ..."
|
||||
tar -zxf "$TEMP_DIR/$PKG_FILE" -C "$TEMP_DIR/"
|
||||
for pkg in "$TEMP_DIR"/packages_ci/openlist*.ipk \
|
||||
"$TEMP_DIR"/packages_ci/luci-app-openlist*.ipk \
|
||||
"$TEMP_DIR"/packages_ci/luci-i18n-openlist-zh-cn*.ipk; do
|
||||
[ -f "$pkg" ] && $PKG_MANAGER install "$pkg"
|
||||
for pkg in "$TEMP_DIR"/packages_ci/openlist*.* \
|
||||
"$TEMP_DIR"/packages_ci/luci-app-openlist*.* \
|
||||
"$TEMP_DIR"/packages_ci/luci-i18n-openlist-zh-cn*.*; do
|
||||
[ -f "$pkg" ] && $PKG_MANAGER $PKG_OPT $pkg
|
||||
done
|
||||
|
||||
# Clean up temporary files and finish
|
||||
rm -rf /tmp/luci-*
|
||||
|
||||
# Start openlist service
|
||||
if [ -x "/etc/init.d/openlist" ]; then
|
||||
/etc/init.d/openlist start || true
|
||||
fi
|
||||
|
||||
msg_green "Done!"
|
||||
|
Loading…
x
Reference in New Issue
Block a user