From 632788cf4bb5603722bd398feb91084e0856c7a4 Mon Sep 17 00:00:00 2001 From: sbwml Date: Sun, 22 Jun 2025 19:15:05 +0800 Subject: [PATCH] install.sh: fix package manager compatibility Signed-off-by: sbwml --- README.md | 7 ++++++- install.sh | 22 ++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 67a7797..895fa37 100644 --- a/README.md +++ b/README.md @@ -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 @@ -------------- -![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) diff --git a/install.sh b/install.sh index 67f7de2..fa2c586 100755 --- a/install.sh +++ b/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!"