install.sh: fix package manager compatibility

Signed-off-by: sbwml <admin@cooluc.com>
This commit is contained in:
sbwml 2025-06-22 19:15:05 +08:00
parent 022aab507a
commit 632788cf4b
2 changed files with 24 additions and 5 deletions

View File

@ -47,8 +47,13 @@
- Install `curl` package - Install `curl` package
```shell ```shell
# for opkg package manager (openwrt 21.02 ~ 24.10)
opkg update opkg update
opkg install curl opkg install curl
# for apk package manager
apk update
apk add curl
``` ```
- Execute install script (Multi-architecture support) - Execute install script (Multi-architecture support)
@ -63,4 +68,4 @@
-------------- --------------
![luci-app-openlist](https://github.com/user-attachments/assets/80593704-1e02-4bcf-8290-a0c7c37012f4) ![luci-app-openlist](https://github.com/user-attachments/assets/50d8ee3a-e589-4285-922a-40c82f96b9f5)

View File

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