From 3dff54a90d9fc036755929661d165c8009e58d65 Mon Sep 17 00:00:00 2001 From: iamromulan <50184035+iamromulan@users.noreply.github.com> Date: Mon, 11 Mar 2024 23:12:02 -0400 Subject: [PATCH] Add check for existing opkg --- installentware.sh | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/installentware.sh b/installentware.sh index bab2079..c21665d 100644 --- a/installentware.sh +++ b/installentware.sh @@ -11,6 +11,7 @@ unset LD_PRELOAD ARCH=armv7sf-k3.2 LOADER=ld-linux.so.3 GLIBC=2.27 +PRE_OPKG_PATH=$(which opkg) # Remount filesystem as read-write mount -o remount,rw / @@ -20,6 +21,7 @@ uninstall_entware() { # Stop services systemctl stop rc.unslung.service + /opt/etc/init.d/rc.unslung stop rm /lib/systemd/system/multi-user.target.wants/rc.unslung.service rm /lib/systemd/system/rc.unslung.service @@ -67,8 +69,7 @@ if [ -d /opt ]; then exit 0 ;; *) - echo "Invalid option. Exiting." - exit 1 + echo "Invalid option. Please select 1, 2, or 3." ;; esac fi @@ -112,12 +113,33 @@ EOF ln -s /lib/systemd/system/start-opt-mount.service /lib/systemd/system/multi-user.target.wants/start-opt-mount.service } -echo -e '\033[32mInfo: Checking for /opt...\033[0m' -if [ -d /opt ]; then - echo -e '\033[31mWarning: /opt exists!\033[0m' +if [ -n "$PRE_OPKG_PATH" ]; then + while true; do + echo "opkg already exists at: $PRE_OPKG_PATH" + echo "Do you want to rename it to opkg_old?" + echo "1. Yes (Highly Recommended)" + echo "2. No (The opkg command may not work)" + read -p "Select an option (1 or 2): " user_choice + + case $user_choice in + 1) + mv "$PRE_OPKG_PATH" "${PRE_OPKG_PATH}_old" + echo "Factory/Already existing opkg has been renamed to opkg_old." + break + ;; + 2) + echo "Proceeding without renaming opkg." + break + ;; + *) + echo "Invalid option. Please select 1 or 2." + ;; + esac + done else - create_opt_mount + echo "Info: no existing opkg binary detected, proceeding with installation" fi + # no need to create many folders. entware-opt package creates most for folder in bin etc lib/opkg tmp var/lock do