diff --git a/ipk-source/sdxpinn-mount-fix/CONTROL/control b/ipk-source/sdxpinn-mount-fix/CONTROL/control index 47ace68..d1eeae7 100755 --- a/ipk-source/sdxpinn-mount-fix/CONTROL/control +++ b/ipk-source/sdxpinn-mount-fix/CONTROL/control @@ -1,5 +1,5 @@ Package: sdxpinn-mount-fix -Version: 1.2.0 +Version: 1.3.1 Architecture: aarch64_cortex-a53 Maintainer: Cameron Thompson iamromulan@github.com Source: github.com/iamromulan diff --git a/ipk-source/sdxpinn-mount-fix/CONTROL/postinst b/ipk-source/sdxpinn-mount-fix/CONTROL/postinst index 126ea3c..671f06e 100755 --- a/ipk-source/sdxpinn-mount-fix/CONTROL/postinst +++ b/ipk-source/sdxpinn-mount-fix/CONTROL/postinst @@ -1,85 +1,18 @@ #!/bin/ash -# Define the main package name and list file location -PKG_NAME="sdxpinn-mount-fix" -LIST_FILE="/usr/lib/opkg/info/${PKG_NAME}.list" -DETECTED_PACKAGES_FILE="/tmp/detected_packages.tmp" -INIT_SCRIPT="/etc/init.d/add_opkg_status_bundled" - -# Function to handle bundled packages post-install -handle_bundled_postinst() { - local bundled_package_name="$1" - - # Use the target package name for default_postinst instead of $0 - if [ "${IPKG_NO_SCRIPT}" = "1" ]; then - return 0 - fi - - # Source the necessary functions only once - if [ -s "${IPKG_INSTROOT}/lib/functions.sh" ]; then - . "${IPKG_INSTROOT}/lib/functions.sh" - else - echo "Error: ${IPKG_INSTROOT}/lib/functions.sh not found." - return 1 - fi - - echo "Executing default_postinst for bundled package: $bundled_package_name" - default_postinst "$bundled_package_name" $@ - return $? -} - -# Replace distfeeds.conf with non-working sources commented out -if [ -f /tmp/distfeeds.conf ]; then - # Backup and replace distfeeds.conf - [ -f /etc/opkg/distfeeds.conf ] && cp /etc/opkg/distfeeds.conf /etc/opkg/distfeeds.conf.bak - mv /tmp/distfeeds.conf /etc/opkg/distfeeds.conf - echo "Replaced /etc/opkg/distfeeds.conf with the custom version." -else - echo "Error: /tmp/distfeeds.conf not found. Cannot replace /etc/opkg/distfeeds.conf." - exit 1 -fi - -echo "Combo package cleanup in progress..." - -# Remove entries in the .list file that refer to opkg control files and specific files -if [ -f "$LIST_FILE" ]; then - # Remove opkg control file entries and specific bundled paths - sed -i '/^\/usr\/lib\/opkg\/info\//d' "$LIST_FILE" - sed -i '/^\/usr\/lib\/libinotifytools.so.0.4.1$/d' "$LIST_FILE" - sed -i '/^\/usr\/bin\/inotifywait$/d' "$LIST_FILE" - sed -i '/^\/usr\/lib\/libinotifytools.so$/d' "$LIST_FILE" - sed -i '/^\/etc\/init.d\/add_opkg_status_bundled$/d' "$LIST_FILE" - sed -i '/^\/tmp\/distfeeds.conf$/d' "$LIST_FILE" - sed -i '/^\/usr\/lib\/libinotifytools.so.0$/d' "$LIST_FILE" - - echo "Removed unnecessary file entries from $LIST_FILE." -else - echo "Warning: ${LIST_FILE} not found." -fi - -# Make the init scripts and binaries executable -chmod +x /etc/init.d/mount-fix /etc/init.d/init-overlay-watchdog /etc/init.d/add_opkg_status_bundled /usr/sbin/init-overlay-watchdog.sh - # Enable and start the services echo "Starting services..." - service mount-fix enable + if grep -qs '/usrdata' /proc/mounts; then - echo "/usrdata is mounted. Synchronizing mount-fix files to /usrdata..." - cp /etc/init.d/mount-fix /usrdata/etc/init.d/mount-fix + echo "/usrdata is mounted. Enabling at /usrdata..." cp -P /etc/rc.d/S03mount-fix /usrdata/etc/rc.d/S03mount-fix + rm /usrdata/overlay-work/etc-upper/rc.d/S03mount-fix + cp -P /etc/rc.d/S03mount-fix /usrdata/overlay-work/etc-upper/rc.d/S03mount-fix fi + service mount-fix start - -sleep 1 - -service init-overlay-watchdog enable -if grep -qs '/usrdata' /proc/mounts; then - echo "/usrdata is mounted. Synchronizing init-overlay-watchdog files to /usrdata..." - cp /etc/init.d/init-overlay-watchdog /usrdata/etc/init.d/init-overlay-watchdog - cp -P /etc/rc.d/S04init-overlay-watchdog /usrdata/etc/rc.d/S04init-overlay-watchdog -fi -service init-overlay-watchdog start +service mount-fix enable echo -e "\e[32m sdxpinn-mount-fix installed! Here is the new file structure! \e[0m" echo -e "\e[32m ============================================================ \e[0m" @@ -87,37 +20,5 @@ mount && df -h echo -e "\e[32m ============================================================ \e[0m" echo -e "\e[32m sdxpinn-mount-fix installed! New file structure above! \e[0m" -# Handle bundled packages based on detection results -BUNDLED_PACKAGES="libinotifytools inotifywait" - -# Check if the detected packages file exists and read its content -if [ -f "$DETECTED_PACKAGES_FILE" ]; then - SKIP_PACKAGES=$(cat "$DETECTED_PACKAGES_FILE") - echo "Skipping the following pre-installed bundled packages: $SKIP_PACKAGES" -else - SKIP_PACKAGES="" -fi - -# Update the bundled packages in the add_opkg_status_bundled script dynamically -for bundled_package_name in $BUNDLED_PACKAGES; do - if echo "$SKIP_PACKAGES" | grep -q "$bundled_package_name"; then - echo "Skipping bundled package: $bundled_package_name" - # Delete the corresponding lines from add_opkg_status_bundled if the package is already installed - sed -i "/Package: $bundled_package_name/,+5d" "$INIT_SCRIPT" - else - handle_bundled_postinst "$bundled_package_name" - fi -done - -# If the resulting BUNDLED_PACKAGES_INFO in add_opkg_status_bundled is empty, remove it -if ! grep -q "Package:" "$INIT_SCRIPT"; then - echo "All bundled packages are pre-installed or removed. Removing $INIT_SCRIPT." - rm -f "$INIT_SCRIPT" -else - # Enable and start the updated add_opkg_status_bundled script - echo "Updated $INIT_SCRIPT with remaining bundled package info." - service add_opkg_status_bundled start -fi - exit 0 diff --git a/ipk-source/sdxpinn-mount-fix/CONTROL/preinst b/ipk-source/sdxpinn-mount-fix/CONTROL/preinst index b1d16be..0a61b6b 100755 --- a/ipk-source/sdxpinn-mount-fix/CONTROL/preinst +++ b/ipk-source/sdxpinn-mount-fix/CONTROL/preinst @@ -1,63 +1,124 @@ #!/bin/ash +LOG_FILE="/tmp/pre-mount-fixinst.log" +# Initialize log +rm -f "$LOG_FILE" >/dev/null 2>&1 +touch "$LOG_FILE" +# Redirect all output (stdout and stderr) to the log file +exec >>"$LOG_FILE" 2>&1 + +mount_factory() { + # Redirect all output (stdout and stderr) to the log file + exec >>"$LOG_FILE" 2>&1 + + # Check if /real_rootfs exists + if [ ! -d "/real_rootfs" ]; then + echo "Error: /real_rootfs does not exist. Cannot proceed with stop." >> "$LOG_FILE" + return 1 + fi + + # Determine firmware version based on mounts + if [ -d "/usrdata" ] && [ -d "/systemrw" ]; then + echo "New firmware scenario detected (with /usrdata and /systemrw)." >> "$LOG_FILE" + stop_handle_new_firmware + else + echo "Old firmware scenario detected (without /usrdata and /systemrw)." >> "$LOG_FILE" + stop_handle_old_firmware + fi +} + +stop_handle_new_firmware() { + # Redirect all output (stdout and stderr) to the log file + exec >>"$LOG_FILE" 2>&1 + /bin/echo "Stopping and reverting overlay and pivot_root" + service init-overlay-watchdog stop + service init-overlay-watchdog disable + # Remount the original root filesystem as read-write + /bin/mount -o remount,rw /real_rootfs + + # Move the mounted filesystems back to the original locations + /bin/mount --move /sys /real_rootfs/sys + /bin/mount --move /proc /real_rootfs/proc + /bin/mount --move /tmp /real_rootfs/tmp + /bin/mount --move /dev /real_rootfs/dev + /bin/mount --move /firmware /real_rootfs/firmware + /bin/mount --move /usrdata /real_rootfs/usrdata + /bin/mount --move /data /real_rootfs/data + /bin/mount --move /cache /real_rootfs/cache + /bin/mount --move /systemrw /real_rootfs/systemrw + /bin/mount --move /persist /real_rootfs/persist + + # Pivot root back to the original root + /sbin/pivot_root /real_rootfs /real_rootfs/rootfs + + /bin/echo "Reverted pivot_root" + + # Unmount /rootfs overlay + /bin/umount -lf /rootfs >/dev/null 2>&1 + service init-overlay-watchdog disable + + # Mount layer 2 /etc back + /bin/mount --bind /usrdata/etc /etc + service init-overlay-watchdog disable + + # Mount layer 3 /etc back + /bin/mount -t overlay overlay -o lowerdir=/etc,upperdir=/usrdata/overlay-work/etc-upper,workdir=/usrdata/overlay-work/.etc-work /etc + service init-overlay-watchdog disable + df -h + echo -e "\e[31m / is read-write right now. Be careful\e[0m" + echo -e "\e[31m Reboot or run mount -o remount,ro / \e[0m" +} + +stop_handle_old_firmware() { + # Redirect all output (stdout and stderr) to the log file + exec >>"$LOG_FILE" 2>&1 + /bin/echo "Stopping and reverting overlay and pivot_root" + + # Remount the original root filesystem as read-write + /bin/mount -o remount,rw /real_rootfs + + # Move the mounted filesystems back to the original locations + /bin/mount --move /sys /real_rootfs/sys + /bin/mount --move /proc /real_rootfs/proc + /bin/mount --move /tmp /real_rootfs/tmp + /bin/mount --move /dev /real_rootfs/dev + /bin/mount --move /firmware /real_rootfs/firmware + /bin/mount --move /persist /real_rootfs/persist + /bin/mount --move /cache /real_rootfs/cache + /bin/mount --move /data /real_rootfs/data + + # Pivot root back to the original root + /sbin/pivot_root /real_rootfs /real_rootfs/rootfs + + /bin/echo "Reverted pivot_root" + + # Unmount /rootfs overlay + /bin/umount -lf /rootfs >/dev/null 2>&1 + + # Mount the location of etc-upper back + mount -t ubifs /dev/ubi0_3 /overlay + + # Mount the old overlay filesystem back for etc + /bin/mount -t overlay overlay -o lowerdir=/etc,upperdir=/overlay/etc-upper,workdir=/overlay/.etc-work /etc + + echo -e "\e[31m / is read-write right now. Be careful\e[0m" + echo -e "\e[31m Reboot or run mount -o remount,ro / \e[0m" +} + + if grep -qs '/real_rootfs' /proc/mounts; then - echo "This package is meant to be installed once after a clean flash." - echo "You should not upgrade or reinstall it. Flash first then run the toolkit otherwise." - exit 1 + echo "Upgrade scenario detected." + mount_factory + service mount-fix disable + rm /usrdata/etc/rc.d/S03mount-fix + echo "Filesystem structure returned to Quectel Stock" + echo "Backup exists at /usrdata/rootfs or /data/rootfs" fi # Remount original rootfs as read-write echo "Mounting / as read-write" mount -o remount,rw / -# Define the location of detected packages file -DETECTED_PACKAGES_FILE="/tmp/detected_packages.tmp" -LIST_FILE_DELETED=false - -# Clear temp file before begining -rm -f "$DETECTED_PACKAGES_FILE" -# Function to check if a specific bundled package is already installed and delete its list file -detect_and_remove_list_files() { - local package_name="$1" - local list_file="/usr/lib/opkg/info/${package_name}.list" - - # Check if the bundled package is installed by checking its .list file - if [ -f "$list_file" ]; then - echo "$package_name is already installed. Deleting its $list_file to avoid future conflicts." - rm -f "$list_file" - echo "$package_name" >> "$DETECTED_PACKAGES_FILE" - LIST_FILE_DELETED=true - else - echo "$package_name is not currently installed." - echo "$package_name is included in this package and will be installed." - fi -} - -# Check for installed packages and handle accordingly -detect_and_remove_list_files "libinotifytools" -detect_and_remove_list_files "inotifywait" - -# Report if any packages were detected and list them -if [ -f "$DETECTED_PACKAGES_FILE" ]; then - echo "Detected the following installed packages, which were handled to avoid clashes:" - cat "$DETECTED_PACKAGES_FILE" -else - echo "No pre-existing bundled packages detected." -fi - -# If any list files were deleted, show a warning message at the end of the script -if [ "$LIST_FILE_DELETED" = true ]; then - echo -e "\e[31m================================================\e[0m" - echo -e "\e[31mPre-bundled packages detected\e[0m" - echo -e "\e[32mAssociation between said packages and respective files has been removed\e[0m" - echo -e "\e[31m================================================\e[0m" - echo -e "\e[31mopkg will fail now\e[0m" - echo -e "\e[32mYou need to try installing this package again\e[0m" - echo -e "\e[32mThen it will work\e[0m" - echo -e "\e[31m================================================\e[0m" - echo -e "\e[32m================================================\e[0m" -fi - # Check if /etc is mounted if grep -qs '/etc' /proc/mounts; then echo "Unmounting /etc..." diff --git a/ipk-source/sdxpinn-mount-fix/CONTROL/prerm b/ipk-source/sdxpinn-mount-fix/CONTROL/prerm deleted file mode 100755 index 34d30d9..0000000 --- a/ipk-source/sdxpinn-mount-fix/CONTROL/prerm +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/ash - -service init-overlay-watchdog stop -service mount-fix stop -sleep 1 -service mount-fix disable -service init-overlay-watchdog disable -echo "Filesystem structure returned to Quectel Stock" -echo "Backup exists at /data/rootfs" -exit 0 \ No newline at end of file diff --git a/ipk-source/sdxpinn-mount-fix/root/etc/init.d/add_opkg_status_bundled b/ipk-source/sdxpinn-mount-fix/root/etc/init.d/add_opkg_status_bundled deleted file mode 100755 index 67f40d4..0000000 --- a/ipk-source/sdxpinn-mount-fix/root/etc/init.d/add_opkg_status_bundled +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/ash /etc/rc.common -USE_PROCD=1 -START=99 -STOP=15 - -# Define variables for bundled packages and status file -STATUS_FILE="/usr/lib/opkg/status" - -# Bundled package information to be added -BUNDLED_PACKAGES_INFO=" -Package: libinotifytools -Version: 3.20.11.0-1 -Depends: libc -Status: install user installed -Architecture: aarch64_cortex-a53 -Installed-Time: $(date +%s) - -Package: inotifywait -Version: 3.20.11.0-1 -Depends: libc, libinotifytools -Status: install user installed -Architecture: aarch64_cortex-a53 -Installed-Time: $(date +%s) -" - -start_service() { - echo "Starting add_opkg_status_bundled service in the background..." - - # Run the service in the background using procd - procd_open_instance - procd_set_param command /bin/sh -c "( - echo 'Waiting for 4 seconds...' - sleep 4 - - # Append the package information to the status file - echo 'Adding bundled package entries to $STATUS_FILE...' - echo \"$BUNDLED_PACKAGES_INFO\" >> \"$STATUS_FILE\" - - # Sync filesystem to ensure changes are saved - sync - - # Verify if the entries were added correctly - if grep -q 'Package: libinotifytools' \"$STATUS_FILE\" && grep -q 'Package: inotifywait' \"$STATUS_FILE\"; then - echo 'Successfully added bundled package entries to $STATUS_FILE' - else - echo 'Error: Failed to add bundled package entries to $STATUS_FILE' - fi - - # Self-remove the init script after execution - echo 'Cleaning up: Removing /etc/init.d/add_opkg_status_bundled' - rm -f /etc/init.d/add_opkg_status_bundled - echo 'add_opkg_status_bundled service completed and removed.' - ) &" - procd_close_instance -} - -stop_service() { - echo "Stopping add_opkg_status_bundled service (if running)..." -} - diff --git a/ipk-source/sdxpinn-mount-fix/root/etc/init.d/init-overlay-watchdog b/ipk-source/sdxpinn-mount-fix/root/etc/init.d/init-overlay-watchdog deleted file mode 100755 index 74c4c04..0000000 --- a/ipk-source/sdxpinn-mount-fix/root/etc/init.d/init-overlay-watchdog +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/ash /etc/rc.common - -START=04 -USE_PROCD=1 - -start_service() { - procd_open_instance - procd_set_param command /usr/sbin/init-overlay-watchdog.sh - procd_set_param respawn 3600 5 5 - procd_set_param stdout 1 - procd_set_param stderr 1 - procd_set_param pidfile /var/run/init-overlay-watchdog.pid - procd_set_param tracking - procd_close_instance -} - -stop_service() { - echo "Stopping init-overlay-watchdog service" - # `procd` will handle stopping the service and its processes -} diff --git a/ipk-source/sdxpinn-mount-fix/root/etc/init.d/mount-fix b/ipk-source/sdxpinn-mount-fix/root/etc/init.d/mount-fix index 140cfe7..7d36d34 100755 --- a/ipk-source/sdxpinn-mount-fix/root/etc/init.d/mount-fix +++ b/ipk-source/sdxpinn-mount-fix/root/etc/init.d/mount-fix @@ -98,8 +98,12 @@ handle_old_firmware() { /bin/mount --move /real_rootfs/cache /cache /bin/mount --move /real_rootfs/data /data - # Synchronize between /etc/rc.d and /real_rootfs/etc/rc.d - synchronize_rc_d "/etc/rc.d" "/real_rootfs/etc/rc.d" + # Synchronize rc.d + synchronize_rc_d "/real_rootfs/etc/rc.d" "/etc/rc.d" + + # Bind the orignal rc.d back and make writable + /bin/mount -o bind,rw /real_rootfs/etc/rc.d /etc/rc.d + /bin/mount -o remount,rw /etc/rc.d # Final logs and remount the original root as read-only /bin/echo "...and we're back! The original root now lives at /real_rootfs" @@ -192,12 +196,15 @@ handle_new_firmware() { /bin/mount --move /real_rootfs/systemrw /systemrw /bin/mount --move /real_rootfs/persist /persist + # Synchronize between rc.d layer 1 to Final + synchronize_rc_d "/real_rootfs/etc/rc.d" "/etc/rc.d" - # Synchronize between /etc/rc.d and /real_rootfs/etc/rc.d - synchronize_rc_d "/etc/rc.d" "/real_rootfs/etc/rc.d" - - # Synchronize between /etc/rc.d and /usrdata/etc/rc.d - synchronize_rc_d "/etc/rc.d" "/usrdata/etc/rc.d" + # Synchronize between rc.d layer 2 to Final + synchronize_rc_d "/usrdata/etc/rc.d" "/etc/rc.d" + + # Bind the orignal rc.d back and make writable + /bin/mount -o bind,rw /real_rootfs/etc/rc.d /etc/rc.d + /bin/mount -o remount,rw /etc/rc.d # Final logs and remount the original root as read-only /bin/echo "...and we're back! The original root now lives at /real_rootfs" @@ -211,7 +218,6 @@ handle_new_firmware() { synchronize_rc_d() { local source_dir="$1" local target_dir="$2" - /bin/echo "Synchronizing $source_dir with $target_dir" for link in "$source_dir"/*; do if [ -L "$link" ]; then @@ -222,13 +228,12 @@ synchronize_rc_d() { fi fi done - for link in "$target_dir"/*; do if [ -L "$link" ]; then link_name=$(basename "$link") if [ ! -e "$source_dir/$link_name" ]; then - /bin/echo "Removing $link_name from $target_dir" - rm "$target_dir/$link_name" + /bin/echo "Copying $link_name to $source_dir" + cp -a "$link" "$source_dir/$link_name" fi fi done @@ -286,7 +291,7 @@ stop_handle_new_firmware() { /bin/umount -lf /rootfs >/dev/null 2>&1 # Mount layer 2 /etc back - /bin/mount -t ubifs -o rw,relatime,bulk_read,assert=read-only,ubi=2,vol=0 /dev/ubi2_0 /etc + /bin/mount --bind /usrdata/etc /etc # Mount layer 3 /etc back /bin/mount -t overlay overlay -o lowerdir=/etc,upperdir=/usrdata/overlay-work/etc-upper,workdir=/usrdata/overlay-work/.etc-work /etc diff --git a/ipk-source/sdxpinn-mount-fix/root/tmp/distfeeds.conf b/ipk-source/sdxpinn-mount-fix/root/tmp/distfeeds.conf deleted file mode 100644 index f44a8cb..0000000 --- a/ipk-source/sdxpinn-mount-fix/root/tmp/distfeeds.conf +++ /dev/null @@ -1,46 +0,0 @@ -# src/gz openwrt_core https://downloads.openwrt.org/releases/22.03.5/targets/sdx75/generic/packages -src/gz openwrt_base https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/base -src/gz openwrt_luci https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/luci -src/gz openwrt_packages https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/packages -# src/gz openwrt_qtiagm https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtiagm -# src/gz openwrt_qtiargs https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtiargs -# src/gz openwrt_qtiaudio https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtiaudio -# src/gz openwrt_qtiaudioprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtiaudioprop -# src/gz openwrt_qtibsp https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtibsp -# src/gz openwrt_qtibspprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtibspprop -# src/gz openwrt_qtibt https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtibt -# src/gz openwrt_qtibtprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtibtprop -# src/gz openwrt_qticore https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qticore -# src/gz openwrt_qticoreinternal https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qticoreinternal -# src/gz openwrt_qticoreprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qticoreprop -# src/gz openwrt_qtictainternal https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtictainternal -# src/gz openwrt_qtidata https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtidata -# src/gz openwrt_qtidatainternal https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtidatainternal -# src/gz openwrt_qtidataprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtidataprop -# src/gz openwrt_qtiipq https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtiipq -# src/gz openwrt_qtiipqezmesh https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtiipqezmesh -# src/gz openwrt_qtiipqprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtiipqprop -# src/gz openwrt_qtilocation https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtilocation -# src/gz openwrt_qtilocationinternal https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtilocationinternal -# src/gz openwrt_qtilocationprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtilocationprop -# src/gz openwrt_qtimsdcprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtimsdcprop -# src/gz openwrt_qtinternal https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtinternal -# src/gz openwrt_qtipal https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtipal -# src/gz openwrt_qtiperfprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtiperfprop -# src/gz openwrt_qtippatprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtippatprop -# src/gz openwrt_qtiquectel https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtiquectel -# src/gz openwrt_qtiquectelprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtiquectelprop -# src/gz openwrt_qtirilprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtirilprop -# src/gz openwrt_qtisecurity https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtisecurity -# src/gz openwrt_qtisecurityinternal https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtisecurityinternal -# src/gz openwrt_qtisecurityprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtisecurityprop -# src/gz openwrt_qtisensorsinternal https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtisensorsinternal -# src/gz openwrt_qtisensorsprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtisensorsprop -# src/gz openwrt_qtissdk https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtissdk -# src/gz openwrt_qtissmgr https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtissmgr -# src/gz openwrt_qtissmgrprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtissmgrprop -# src/gz openwrt_qtiwlan https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtiwlan -# src/gz openwrt_qtiwlanprop https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/qtiwlanprop -src/gz openwrt_routing https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/routing -# Added by iamromulan: -src/gz openwrt_telephony https://downloads.openwrt.org/releases/22.03.5/packages/aarch64_cortex-a53/telephony/ diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/bin/inotifywait b/ipk-source/sdxpinn-mount-fix/root/usr/bin/inotifywait deleted file mode 100755 index f679cca..0000000 Binary files a/ipk-source/sdxpinn-mount-fix/root/usr/bin/inotifywait and /dev/null differ diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/bin/rc_sync b/ipk-source/sdxpinn-mount-fix/root/usr/bin/rc_sync deleted file mode 100755 index f9a5c50..0000000 --- a/ipk-source/sdxpinn-mount-fix/root/usr/bin/rc_sync +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/ash -# Paths to monitor and synchronize -WATCH_DIR="/etc/rc.d" -TARGET_DIR1="/real_rootfs/etc/rc.d" -TARGET_DIR2="/usrdata/etc/rc.d" - -# Function to check if a path is a mountpoint -is_mountpoint() { - grep -q " $1 " /proc/mounts - return $? -} - -# Function to synchronize init scripts -synchronize_init_scripts() { - # Ensure /real_rootfs is writable for updates - mount -o remount,rw /real_rootfs - - # Synchronize with TARGET_DIR1 - echo "Synchronizing $WATCH_DIR with $TARGET_DIR1..." - for link in "$WATCH_DIR"/*; do - if [ -L "$link" ]; then - link_name=$(basename "$link") - if [ ! -e "$TARGET_DIR1/$link_name" ] || [ "$link" -nt "$TARGET_DIR1/$link_name" ]; then - cp -af "$link" "$TARGET_DIR1/$link_name" - fi - fi - done - - for link in "$TARGET_DIR1"/*; do - if [ -L "$link" ]; then - link_name=$(basename "$link") - if [ ! -e "$WATCH_DIR/$link_name" ]; then - rm -f "$TARGET_DIR1/$link_name" - fi - fi - done - - # Synchronize with TARGET_DIR2 only if /usrdata is a mountpoint - if is_mountpoint "/usrdata"; then - echo "Synchronizing $WATCH_DIR with $TARGET_DIR2..." - for link in "$WATCH_DIR"/*; do - if [ -L "$link" ]; then - link_name=$(basename "$link") - if [ ! -e "$TARGET_DIR2/$link_name" ] || [ "$link" -nt "$TARGET_DIR2/$link_name" ]; then - cp -af "$link" "$TARGET_DIR2/$link_name" - fi - fi - done - - for link in "$TARGET_DIR2"/*; do - if [ -L "$link" ]; then - link_name=$(basename "$link") - if [ ! -e "$WATCH_DIR/$link_name" ]; then - rm -f "$TARGET_DIR2/$link_name" - fi - fi - done - fi - - # Restore /real_rootfs to read-only - mount -o remount,ro /real_rootfs -} - -# Run synchronization -synchronize_init_scripts -exit 0 diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/lib/libinotifytools.so b/ipk-source/sdxpinn-mount-fix/root/usr/lib/libinotifytools.so deleted file mode 100644 index e1c9156..0000000 Binary files a/ipk-source/sdxpinn-mount-fix/root/usr/lib/libinotifytools.so and /dev/null differ diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/lib/libinotifytools.so.0 b/ipk-source/sdxpinn-mount-fix/root/usr/lib/libinotifytools.so.0 deleted file mode 100644 index e1c9156..0000000 Binary files a/ipk-source/sdxpinn-mount-fix/root/usr/lib/libinotifytools.so.0 and /dev/null differ diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/lib/libinotifytools.so.0.4.1 b/ipk-source/sdxpinn-mount-fix/root/usr/lib/libinotifytools.so.0.4.1 deleted file mode 100644 index e1c9156..0000000 Binary files a/ipk-source/sdxpinn-mount-fix/root/usr/lib/libinotifytools.so.0.4.1 and /dev/null differ diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/inotifywait.control b/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/inotifywait.control deleted file mode 100644 index 9502eb8..0000000 --- a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/inotifywait.control +++ /dev/null @@ -1,20 +0,0 @@ -Package: inotifywait -Version: 3.20.11.0-1 -Depends: libc, libinotifytools -Source: feeds/packages/utils/inotify-tools -SourceName: inotifywait -License: GPLv2 -LicenseFiles: COPYING -Section: utils -SourceDateEpoch: 1605477462 -Maintainer: Daniel Golle -Architecture: aarch64_cortex-a53 -Installed-Size: 9023 -Description: inotify-tools is a C library and a set of command-line programs for - Linux providing a simple interface to inotify. These programs can be - used to monitor and act upon filesystem events. A more detailed - description of the programs is further down the page. The programs are - written in C and have no dependencies other than a Linux kernel - supporting inotify. - - This package provides the inotifywait tool. diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/inotifywait.list b/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/inotifywait.list deleted file mode 100644 index 54b8cf5..0000000 --- a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/inotifywait.list +++ /dev/null @@ -1 +0,0 @@ -/usr/bin/inotifywait diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/inotifywait.postinst b/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/inotifywait.postinst deleted file mode 100755 index 3bba77c..0000000 --- a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/inotifywait.postinst +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -[ "${IPKG_NO_SCRIPT}" = "1" ] && exit 0 -[ -s ${IPKG_INSTROOT}/lib/functions.sh ] || exit 0 -. ${IPKG_INSTROOT}/lib/functions.sh -default_postinst $0 $@ diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/inotifywait.prerm b/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/inotifywait.prerm deleted file mode 100755 index 12d06ec..0000000 --- a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/inotifywait.prerm +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -[ -s ${IPKG_INSTROOT}/lib/functions.sh ] || exit 0 -. ${IPKG_INSTROOT}/lib/functions.sh -default_prerm $0 $@ diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/libinotifytools.control b/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/libinotifytools.control deleted file mode 100755 index ed2ce92..0000000 --- a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/libinotifytools.control +++ /dev/null @@ -1,20 +0,0 @@ -Package: libinotifytools -Version: 3.20.11.0-1 -Depends: libc -Source: feeds/packages/utils/inotify-tools -SourceName: libinotifytools -License: GPLv2 -LicenseFiles: COPYING -Section: libs -SourceDateEpoch: 1605477462 -Maintainer: Daniel Golle -Architecture: aarch64_cortex-a53 -Installed-Size: 13142 -Description: inotify-tools is a C library and a set of command-line programs for - Linux providing a simple interface to inotify. These programs can be - used to monitor and act upon filesystem events. A more detailed - description of the programs is further down the page. The programs are - written in C and have no dependencies other than a Linux kernel - supporting inotify. - - This package provides the libinotifytools shared library. diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/libinotifytools.list b/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/libinotifytools.list deleted file mode 100755 index 402af38..0000000 --- a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/libinotifytools.list +++ /dev/null @@ -1,3 +0,0 @@ -/usr/lib/libinotifytools.so.0.4.1 -/usr/lib/libinotifytools.so -/usr/lib/libinotifytools.so.0 diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/libinotifytools.postinst b/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/libinotifytools.postinst deleted file mode 100755 index 3bba77c..0000000 --- a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/libinotifytools.postinst +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -[ "${IPKG_NO_SCRIPT}" = "1" ] && exit 0 -[ -s ${IPKG_INSTROOT}/lib/functions.sh ] || exit 0 -. ${IPKG_INSTROOT}/lib/functions.sh -default_postinst $0 $@ diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/libinotifytools.prerm b/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/libinotifytools.prerm deleted file mode 100755 index 12d06ec..0000000 --- a/ipk-source/sdxpinn-mount-fix/root/usr/lib/opkg/info/libinotifytools.prerm +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -[ -s ${IPKG_INSTROOT}/lib/functions.sh ] || exit 0 -. ${IPKG_INSTROOT}/lib/functions.sh -default_prerm $0 $@ diff --git a/ipk-source/sdxpinn-mount-fix/root/usr/sbin/init-overlay-watchdog.sh b/ipk-source/sdxpinn-mount-fix/root/usr/sbin/init-overlay-watchdog.sh deleted file mode 100755 index e1322c9..0000000 --- a/ipk-source/sdxpinn-mount-fix/root/usr/sbin/init-overlay-watchdog.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/ash - -# Paths to monitor and synchronize -WATCH_DIR="/etc/rc.d" -TARGET_DIR1="/real_rootfs/etc/rc.d" -TARGET_DIR2="/usrdata/etc/rc.d" -LOG_FILE="/tmp/init-overlay-watchdog.log" - -# Function to synchronize init scripts -synchronize_init_scripts() { - # Ensure /real_rootfs is writable for updates - mount -o remount,rw /real_rootfs - - # Synchronize with TARGET_DIR1 - echo "Synchronizing $WATCH_DIR with $TARGET_DIR1..." - for link in "$WATCH_DIR"/*; do - if [ -L "$link" ]; then - link_name=$(basename "$link") - if [ ! -e "$TARGET_DIR1/$link_name" ] || [ "$link" -nt "$TARGET_DIR1/$link_name" ]; then - cp -af "$link" "$TARGET_DIR1/$link_name" - fi - fi - done - - for link in "$TARGET_DIR1"/*; do - if [ -L "$link" ]; then - link_name=$(basename "$link") - if [ ! -e "$WATCH_DIR/$link_name" ]; then - rm -f "$TARGET_DIR1/$link_name" - fi - fi - done - - # Synchronize with TARGET_DIR2 if /usrdata exists - if [ -d "/usrdata" ]; then - echo "Synchronizing $WATCH_DIR with $TARGET_DIR2..." - for link in "$WATCH_DIR"/*; do - if [ -L "$link" ]; then - link_name=$(basename "$link") - if [ ! -e "$TARGET_DIR2/$link_name" ] || [ "$link" -nt "$TARGET_DIR2/$link_name" ]; then - cp -af "$link" "$TARGET_DIR2/$link_name" - fi - fi - done - - for link in "$TARGET_DIR2"/*; do - if [ -L "$link" ]; then - link_name=$(basename "$link") - if [ ! -e "$WATCH_DIR/$link_name" ]; then - rm -f "$TARGET_DIR2/$link_name" - fi - fi - done - fi - - # Restore /real_rootfs to read-only - mount -o remount,ro /real_rootfs -} - -# Initialize log -rm -f "$LOG_FILE" >/dev/null 2>&1 -touch "$LOG_FILE" - -# Redirect all output (stdout and stderr) to the log file -exec >>"$LOG_FILE" 2>&1 - -# Initial synchronization -synchronize_init_scripts - -# Monitor WATCH_DIR for changes using inotifywait -while true; do - inotifywait -e create,delete,modify,move "$WATCH_DIR" - synchronize_init_scripts -done - diff --git a/ipk-source/sdxpinn-mount-fix/root/usrdata/etc/init.d/mount-fix b/ipk-source/sdxpinn-mount-fix/root/usrdata/etc/init.d/mount-fix new file mode 100755 index 0000000..7d36d34 --- /dev/null +++ b/ipk-source/sdxpinn-mount-fix/root/usrdata/etc/init.d/mount-fix @@ -0,0 +1,343 @@ +#!/bin/sh /etc/rc.common + +START=03 + +LOG_FILE="/tmp/mount-fix.log" + +start() { + # Initialize log + rm -f "$LOG_FILE" >/dev/null 2>&1 + touch "$LOG_FILE" + + # Redirect all output (stdout and stderr) to the log file + exec >>"$LOG_FILE" 2>&1 + + echo "Begin mount fix process to make a usable userspace." + + # Determine firmware scenario + if mount | grep -q "/usrdata"; then + echo "New firmware scenario detected (with /usrdata)." + handle_new_firmware + elif mount | grep -q "/overlay"; then + echo "Old firmware scenario detected (with /overlay)." + handle_old_firmware + else + echo "Error: Unable to detect firmware scenario. Neither /usrdata nor /overlay mounts found. Exiting." + exit 1 + fi +} + +handle_old_firmware() { + # Redirect all output (stdout and stderr) to the log file + exec >>"$LOG_FILE" 2>&1 + /bin/echo "Begin mount fix process to make a usable userspace" + + # Forcefully unmount /etc + /bin/echo "Unmounting the tiny overlay at /etc" + /bin/umount -lf /etc >/dev/null 2>&1 + + # Remount root filesystem as read-write + /bin/echo "Remounting / as read-write" + /bin/mount -o remount,rw / + + # Check if /overlay/etc-upper/merged.done exists + /bin/echo "First time this is ran the stuff you have been putting in the old overlay needs merged." + /bin/echo "Looking for evidence that this has already happened..." + if [ ! -f /overlay/etc-upper/merged.done ]; then + /bin/echo "/overlay/etc-upper/merged.done not found, merging /overlay/etc-upper/* to /etc/" + cp -rf /overlay/etc-upper/* /etc/ + /bin/touch /overlay/etc-upper/merged.done + else + /bin/echo "/overlay/etc-upper/merged.done found, skipping merge" + fi + + # Unmount /overlay + /bin/echo "Unmounting the no longer needed /overlay" + /bin/umount /overlay + + # Check if /etc/opkg.conf has a line containing "option overlay_root /overlay" and remove it if it exists + /bin/echo "Lets be sure your opkg config isn't using the old overlay" + if grep -q "option overlay_root /overlay" /etc/opkg.conf; then + /bin/echo "Removing 'option overlay_root /overlay' from /etc/opkg.conf" + sed -i '/option overlay_root \/overlay/d' /etc/opkg.conf + else + /bin/echo "'option overlay_root /overlay' not found in /etc/opkg.conf, no changes made" + fi + + # Ensure necessary directories exist for overlay and pivot_root + /bin/echo "Creating new overlay system" + if [ ! -d /data/rootfs ]; then + mkdir -p /data/rootfs + fi + if [ ! -d /data/rootfs-workdir ]; then + mkdir -p /data/rootfs-workdir + fi + if [ ! -d /rootfs ]; then + mkdir -p /rootfs + fi + + # Mount the new overlay filesystem + /bin/mount -t overlay overlay -o lowerdir=/,upperdir=/data/rootfs,workdir=/data/rootfs-workdir /rootfs + + # Create the real_rootfs directory in the new root + if [ ! -d /rootfs/real_rootfs ]; then + mkdir -p /rootfs/real_rootfs + fi + + # Pivot root to the new root + /bin/echo "Pivoting Root / to /rootfs; Be back soon!!" + /sbin/pivot_root /rootfs /rootfs/real_rootfs >/dev/null 2>&1 + + # Move the mounted filesystems to the new locations + /bin/mount --move /real_rootfs/sys /sys + /bin/mount --move /real_rootfs/proc /proc + /bin/mount --move /real_rootfs/tmp /tmp + /bin/mount --move /real_rootfs/dev /dev + /bin/mount --move /real_rootfs/firmware /firmware + /bin/mount --move /real_rootfs/persist /persist + /bin/mount --move /real_rootfs/cache /cache + /bin/mount --move /real_rootfs/data /data + + # Synchronize rc.d + synchronize_rc_d "/real_rootfs/etc/rc.d" "/etc/rc.d" + + # Bind the orignal rc.d back and make writable + /bin/mount -o bind,rw /real_rootfs/etc/rc.d /etc/rc.d + /bin/mount -o remount,rw /etc/rc.d + + # Final logs and remount the original root as read-only + /bin/echo "...and we're back! The original root now lives at /real_rootfs" + /bin/echo "Lets mount it as read-only for now, If you need it just remount it as read-write" + /bin/mount -o remount,ro /real_rootfs >/dev/null 2>&1 + /bin/echo "Overlay and pivot_root setup completed" +} + +handle_new_firmware() { + # Redirect all output (stdout and stderr) to the log file + exec >>"$LOG_FILE" 2>&1 + /bin/echo "Begin mount fix process to make a usable userspace" + + # Forcefully unmount /etc + /bin/echo "Unmounting the 2 mounts over /etc" + /bin/umount -lf /etc >/dev/null 2>&1 + /bin/umount -lf /etc >/dev/null 2>&1 + + # Remount root filesystem as read-write + /bin/echo "Remounting / as read-write" + /bin/mount -o remount,rw / + + # Begin layer merge checks + # Layer 1 to 2 + # Check if /overlay/etc-upper/merged.done exists + /bin/echo "First time this is ran the stuff you have been putting in the old overlay and /usrdata/etc needs merged." + /bin/echo "Looking for evidence that this has already happened..." + if [ ! -f /usrdata/overlay-work/etc-upper/merged.done ]; then + /bin/echo "/usrdata/overlay-work/etc-upper/merged.done not found, merging /usrdata/overlay-work/etc-upper/* to /usrdata/etc/" + cp -rf /usrdata/overlay-work/etc-upper/* /usrdata/etc/ + /bin/touch /usrdata/overlay-work/etc-upper/merged.done + else + /bin/echo "/usrdata/overlay-work/etc-upper/merged.done found, skipping merge" + fi + # Layer 2 to 3 + # Check if /usrdata/etc/merged.done exists + /bin/echo "First time this is ran the stuff you have been putting in /usrdata/etc and /etc needs merged." + /bin/echo "Looking for evidence that this has already happened..." + if [ ! -f /usrdata/etc/merged.done ]; then + /bin/echo "/usrdata/etc/merged.done not found, merging /usrdata/etc/* to /etc/" + cp -rf /usrdata/etc/* /etc/ + /bin/touch /usrdata/etc/merged.done + else + /bin/echo "/usrdata/etc/merged.done found, skipping merge" + fi + + + # Check if /etc/opkg.conf has a line containing "option overlay_root /overlay" and remove it if it exists + /bin/echo "Lets be sure your opkg config isn't using the old overlay" + if grep -q "option overlay_root /overlay" /etc/opkg.conf; then + /bin/echo "Removing 'option overlay_root /overlay' from /etc/opkg.conf" + sed -i '/option overlay_root \/overlay/d' /etc/opkg.conf + else + /bin/echo "'option overlay_root /overlay' not found in /etc/opkg.conf, no changes made" + fi + + # Ensure necessary directories exist for overlay and pivot_root + /bin/echo "Creating new overlay system" + if [ ! -d /usrdata/rootfs ]; then + mkdir -p /usrdata/rootfs + fi + if [ ! -d /usrdata/rootfs-workdir ]; then + mkdir -p /usrdata/rootfs-workdir + fi + if [ ! -d /rootfs ]; then + mkdir -p /rootfs + fi + + # Mount the new overlay filesystem + /bin/mount -t overlay overlay -o lowerdir=/,upperdir=/usrdata/rootfs,workdir=/usrdata/rootfs-workdir /rootfs + + # Create the real_rootfs directory in the new root + if [ ! -d /rootfs/real_rootfs ]; then + mkdir -p /rootfs/real_rootfs + fi + + # Pivot root to the new root + /bin/echo "Pivoting Root / to /rootfs; Be back soon!!" + /sbin/pivot_root /rootfs /rootfs/real_rootfs >/dev/null 2>&1 + + # Move the mounted filesystems to the new locations + /bin/mount --move /real_rootfs/sys /sys + /bin/mount --move /real_rootfs/proc /proc + /bin/mount --move /real_rootfs/tmp /tmp + /bin/mount --move /real_rootfs/dev /dev + /bin/mount --move /real_rootfs/firmware /firmware + /bin/mount --move /real_rootfs/usrdata /usrdata + /bin/mount --move /real_rootfs/data /data + /bin/mount --move /real_rootfs/cache /cache + /bin/mount --move /real_rootfs/systemrw /systemrw + /bin/mount --move /real_rootfs/persist /persist + + # Synchronize between rc.d layer 1 to Final + synchronize_rc_d "/real_rootfs/etc/rc.d" "/etc/rc.d" + + # Synchronize between rc.d layer 2 to Final + synchronize_rc_d "/usrdata/etc/rc.d" "/etc/rc.d" + + # Bind the orignal rc.d back and make writable + /bin/mount -o bind,rw /real_rootfs/etc/rc.d /etc/rc.d + /bin/mount -o remount,rw /etc/rc.d + + # Final logs and remount the original root as read-only + /bin/echo "...and we're back! The original root now lives at /real_rootfs" + /bin/echo "Lets mount it as read-only for now, If you need it just remount it as read-write" + /bin/mount -o remount,ro /real_rootfs >/dev/null 2>&1 + /bin/echo "Overlay and pivot_root setup completed" + +} + + +synchronize_rc_d() { + local source_dir="$1" + local target_dir="$2" + /bin/echo "Synchronizing $source_dir with $target_dir" + for link in "$source_dir"/*; do + if [ -L "$link" ]; then + link_name=$(basename "$link") + if [ ! -e "$target_dir/$link_name" ]; then + /bin/echo "Copying $link_name to $target_dir" + cp -a "$link" "$target_dir/$link_name" + fi + fi + done + for link in "$target_dir"/*; do + if [ -L "$link" ]; then + link_name=$(basename "$link") + if [ ! -e "$source_dir/$link_name" ]; then + /bin/echo "Copying $link_name to $source_dir" + cp -a "$link" "$source_dir/$link_name" + fi + fi + done +} + +stop() { + # Initialize log + rm -f "$LOG_FILE" >/dev/null 2>&1 + touch "$LOG_FILE" + # Redirect all output (stdout and stderr) to the log file + exec >>"$LOG_FILE" 2>&1 + + # Check if /real_rootfs exists + if [ ! -d "/real_rootfs" ]; then + echo "Error: /real_rootfs does not exist. Cannot proceed with stop." >> "$LOG_FILE" + return 1 + fi + + # Determine firmware version based on mounts + if [ -d "/usrdata" ] && [ -d "/systemrw" ]; then + echo "New firmware scenario detected (with /usrdata and /systemrw)." >> "$LOG_FILE" + stop_handle_new_firmware + else + echo "Old firmware scenario detected (without /usrdata and /systemrw)." >> "$LOG_FILE" + stop_handle_old_firmware + fi +} + +stop_handle_new_firmware() { + # Redirect all output (stdout and stderr) to the log file + exec >>"$LOG_FILE" 2>&1 + /bin/echo "Stopping and reverting overlay and pivot_root" + + # Remount the original root filesystem as read-write + /bin/mount -o remount,rw /real_rootfs + + # Move the mounted filesystems back to the original locations + /bin/mount --move /sys /real_rootfs/sys + /bin/mount --move /proc /real_rootfs/proc + /bin/mount --move /tmp /real_rootfs/tmp + /bin/mount --move /dev /real_rootfs/dev + /bin/mount --move /firmware /real_rootfs/firmware + /bin/mount --move /usrdata /real_rootfs/usrdata + /bin/mount --move /data /real_rootfs/data + /bin/mount --move /cache /real_rootfs/cache + /bin/mount --move /systemrw /real_rootfs/systemrw + /bin/mount --move /persist /real_rootfs/persist + + # Pivot root back to the original root + /sbin/pivot_root /real_rootfs /real_rootfs/rootfs + + /bin/echo "Reverted pivot_root" + + # Unmount /rootfs overlay + /bin/umount -lf /rootfs >/dev/null 2>&1 + + # Mount layer 2 /etc back + /bin/mount --bind /usrdata/etc /etc + + # Mount layer 3 /etc back + /bin/mount -t overlay overlay -o lowerdir=/etc,upperdir=/usrdata/overlay-work/etc-upper,workdir=/usrdata/overlay-work/.etc-work /etc + df -h + echo -e "\e[31m / is read-write right now. Be careful\e[0m" + echo -e "\e[31m Reboot or run mount -o remount,ro / \e[0m" +} + +stop_handle_old_firmware() { + # Redirect all output (stdout and stderr) to the log file + exec >>"$LOG_FILE" 2>&1 + /bin/echo "Stopping and reverting overlay and pivot_root" + + # Remount the original root filesystem as read-write + /bin/mount -o remount,rw /real_rootfs + + # Move the mounted filesystems back to the original locations + /bin/mount --move /sys /real_rootfs/sys + /bin/mount --move /proc /real_rootfs/proc + /bin/mount --move /tmp /real_rootfs/tmp + /bin/mount --move /dev /real_rootfs/dev + /bin/mount --move /firmware /real_rootfs/firmware + /bin/mount --move /persist /real_rootfs/persist + /bin/mount --move /cache /real_rootfs/cache + /bin/mount --move /data /real_rootfs/data + + # Pivot root back to the original root + /sbin/pivot_root /real_rootfs /real_rootfs/rootfs + + /bin/echo "Reverted pivot_root" + + # Unmount /rootfs overlay + /bin/umount -lf /rootfs >/dev/null 2>&1 + + # Mount the location of etc-upper back + mount -t ubifs /dev/ubi0_3 /overlay + + # Mount the old overlay filesystem back for etc + /bin/mount -t overlay overlay -o lowerdir=/etc,upperdir=/overlay/etc-upper,workdir=/overlay/.etc-work /etc + + echo -e "\e[31m / is read-write right now. Be careful\e[0m" + echo -e "\e[31m Reboot or run mount -o remount,ro / \e[0m" +} + +restart() { + /bin/echo "This script should only be executed once at boot" + /bin/echo "Use Stop to undo the pivot" + /bin/echo "Use Start to put it back" +} diff --git a/ipk-source/sdxpinn-patch/CONTROL/control b/ipk-source/sdxpinn-patch/CONTROL/control index 7785cca..5540b4d 100755 --- a/ipk-source/sdxpinn-patch/CONTROL/control +++ b/ipk-source/sdxpinn-patch/CONTROL/control @@ -1,6 +1,6 @@ Package: sdxpinn-patch Depends: sdxpinn-mount-fix -Version: 1 +Version: 2.5 Architecture: all Maintainer: Cameron Thompson iamromulan@github.com Source: github.com/iamromulan diff --git a/ipk-source/sdxpinn-patch/CONTROL/preinst b/ipk-source/sdxpinn-patch/CONTROL/preinst index db099e5..1815504 100755 --- a/ipk-source/sdxpinn-patch/CONTROL/preinst +++ b/ipk-source/sdxpinn-patch/CONTROL/preinst @@ -162,6 +162,39 @@ repo_iamromulanSDXPINN_check() { return 0 } +noprerm_mount_fix() { + + if [ -f /real_rootfs/usr/lib/opkg/info/sdxpinn-mount-fix.prerm ]; then + mount -o remount,rw /real_rootfs + sleep 1 + rm /real_rootfs/usr/lib/opkg/info/sdxpinn-mount-fix.prerm + sleep 1 + mount -o remount,ro /real_rootfs + fi + + if [ -f /usr/lib/opkg/info/sdxpinn-mount-fix.prerm ]; then + rm /usr/lib/opkg/info/sdxpinn-mount-fix.prerm + fi +} + +opkg_arch_patch() { +if [ ! -f /etc/opkg/arch.conf ]; then + cat > /etc/opkg/arch.conf << 'EOF' +arch all 1 +arch noarch 1 +arch sdxpinn 2 +arch aarch64_cortex-a53 10 +arch aarch64_generic 20 +EOF +else + for arch in "all 1" "noarch 1" "sdxpinn 2" "aarch64_cortex-a53 10" "aarch64_generic 20"; do + if ! grep -q "^arch $arch$" /etc/opkg/arch.conf; then + echo "arch $arch" >> /etc/opkg/arch.conf + fi + done +fi +} + # Begin Patch Process echo -e "\e[92mBegining sdxpinn-patch process...\e[0m" @@ -170,6 +203,9 @@ clean_distfeeds echo -e "\e[92mEnsuring iamromulan's SDXPINN repo is listed in customfeeds and public key is installed...\e[0m" repo_iamromulanSDXPINN_check echo -e "\e[92miamromulan's SDXPINN repo source and key is installed.\e[0m" - +echo -e "\e[92mEnsuring mount-fix does not have a prerm\e[0m" +noprerm_mount_fix +echo -e "\e[92mEnsuring opkg reconizes needed archs\e[0m" +opkg_arch_patch echo -e "\e[92msdxpinn-patch process complete.\e[0m" exit 0 diff --git a/ipk-source/sdxpinn-patch/root/tmp/sdxpinn.patched b/ipk-source/sdxpinn-patch/root/tmp/sdxpinn.patched index d00491f..0cfbf08 100644 --- a/ipk-source/sdxpinn-patch/root/tmp/sdxpinn.patched +++ b/ipk-source/sdxpinn-patch/root/tmp/sdxpinn.patched @@ -1 +1 @@ -1 +2 diff --git a/ipk-source/sdxpinn-quecmanager-beta/CONTROL/control b/ipk-source/sdxpinn-quecmanager-beta/CONTROL/control index 59f373b..88b5e76 100755 --- a/ipk-source/sdxpinn-quecmanager-beta/CONTROL/control +++ b/ipk-source/sdxpinn-quecmanager-beta/CONTROL/control @@ -4,5 +4,5 @@ Architecture: aarch64_cortex-a53 Maintainer: Russel Yasol dr-dolomite@github.com Cameron Thompson iamromulan@github.com Source: github.com/iamromulan Description: A custom web UI desgined to run alongside luci for Quectel RM55x modems -Depends: sdxpinn-mount-fix, libc, coreutils-timeout, uhttpd, sms-tool (>= 2025.1.19-APmod-iamromulan), jq, ookla-speedtest +Depends: sdxpinn-mount-fix, libc, inotifywait, coreutils-timeout, uhttpd, sms-tool (>= 2025.1.19-APmod-iamromulan), jq, ookla-speedtest Conflicts: sdxpinn-quecmanager diff --git a/opkg-feed/Packages b/opkg-feed/Packages index 085f01f..686db6f 100644 --- a/opkg-feed/Packages +++ b/opkg-feed/Packages @@ -69,28 +69,28 @@ License: GPLv3 Package: sdxpinn-mount-fix -Version: 1.2.0 +Version: 1.3.1 Depends: libc Section: base Architecture: aarch64_cortex-a53 Maintainer: iamromulan -MD5Sum: bfc582c93776c9c0b4848cb791b166ae -Size: 55611 -Filename: sdxpinn-mount-fix_1.2.0_aarch64_cortex-a53.ipk +MD5Sum: 4bb33e6ca7365f722440f1a83ae1bcea +Size: 4672 +Filename: sdxpinn-mount-fix_1.3.1_aarch64_cortex-a53.ipk Source: github/iamromulan Description: Creates a usable mount space and overlay for SDXPINN modems. Dependencies bundled: libinotifytools and inotifywait License: GPLv3 Package: sdxpinn-patch -Version: 1 +Version: 2.5 Depends: sdxpinn-mount-fix Section: base Architecture: all Maintainer: Cameron Thompson iamromulan@github.com -MD5Sum: 325bba5d51b1d0579e6b12f1cb608c08 -Size: 2768 -Filename: sdxpinn-patch_1_all.ipk +MD5Sum: 0ec65238142dad95de1666b01a6f09c6 +Size: 3054 +Filename: sdxpinn-patch_2.5_all.ipk Source: github.com/iamromulan Description: A general first system patch for SDXPINN OpenWRT @@ -112,13 +112,13 @@ License: GPLv3 Package: sdxpinn-quecmanager-beta Version: 1.1.1-2 -Depends: sdxpinn-mount-fix, libc, coreutils-timeout, uhttpd, sms-tool (>= 2025.1.19-APmod-iamromulan), jq, ookla-speedtest +Depends: sdxpinn-mount-fix, libc, inotifywait, coreutils-timeout, uhttpd, sms-tool (>= 2025.1.19-APmod-iamromulan), jq, ookla-speedtest Conflicts: sdxpinn-quecmanager Section: admin Architecture: aarch64_cortex-a53 Maintainer: Russel Yasol Cameron Thompson -MD5Sum: 8ad5b2321bf270680e5d156924926dde -Size: 1047920 +MD5Sum: bcb2775216382f6a479cc10983df8e0d +Size: 1050194 Filename: sdxpinn-quecmanager-beta_1.1.1-2_aarch64_cortex-a53.ipk Source: github/iamromulan Description: BETA: A custom web UI desgined to run alongside luci for Quectel RM55x modems diff --git a/opkg-feed/Packages.gz b/opkg-feed/Packages.gz index ac42e19..ac216d1 100644 Binary files a/opkg-feed/Packages.gz and b/opkg-feed/Packages.gz differ diff --git a/opkg-feed/Packages.log b/opkg-feed/Packages.log index c05600f..bb816f7 100644 --- a/opkg-feed/Packages.log +++ b/opkg-feed/Packages.log @@ -1,17 +1,17 @@ -Starting package analysis - Thu Jan 23 06:35:03 PM EST 2025 +Starting package analysis - Sun Jan 26 05:40:18 PM EST 2025 No update needed for atinout (version 0.9.1, MD5: 444eb87488bad1927b6ed069dedf7393, size: 4323) No update needed for luci-app-atinout-mod (version 1.3.4-20250119, MD5: 1ffee9ec8fe5723b8140bf2c21fea508, size: 4864) No update needed for luci-app-tailscale (version 1.2.3-2, MD5: 53c84c947c42d7518aecb4a6b8a9c5a8, size: 6501) No update needed for ookla-speedtest (version 1.2.0, MD5: b26e1909599f73cab40ea0281c5a6283, size: 1075696) No update needed for sdxpinn-console-menu (version 0.0.2, MD5: de75d2889510e92b57fc8a7ca087ced4, size: 7361) -No update needed for sdxpinn-mount-fix (version 1.2.0, MD5: bfc582c93776c9c0b4848cb791b166ae, size: 55611) -No update needed for sdxpinn-patch (version 1, MD5: 325bba5d51b1d0579e6b12f1cb608c08, size: 2768) +No update needed for sdxpinn-mount-fix (version 1.3.1, MD5: 4bb33e6ca7365f722440f1a83ae1bcea, size: 4672) +Updating package info for sdxpinn-patch... +Updated sdxpinn-patch to version 2.5 with MD5: 0ec65238142dad95de1666b01a6f09c6 and size: 3054 No update needed for sdxpinn-quecmanager (version 1.0.1, MD5: cb96c5ec96c2166f39d989f277ebc0f7, size: 722109) -Updating package info for sdxpinn-quecmanager-beta... -Updated sdxpinn-quecmanager-beta to version 1.1.1-2 with MD5: 8ad5b2321bf270680e5d156924926dde and size: 1047920 +No update needed for sdxpinn-quecmanager-beta (version 1.1.1-2, MD5: bcb2775216382f6a479cc10983df8e0d, size: 1050194) No update needed for sms-tool (version 2025.1.19-APmod-iamromulan, MD5: 83dc8bfd2d4ac8d8952a2a95b2be943f, size: 13687) No update needed for socat-at-bridge (version 1.1.1, MD5: 2fd73d7679b3db54113d93bb5949077a, size: 1969) No update needed for tailscale (version 1.78.1-2, MD5: baa4d97ba49aa42ef104accba2dc2fd8, size: 9882856) No update needed for tailscaled (version 1.78.1-4, MD5: 647b4d3c6e51f700dd96362f92f20b54, size: 17960998) Package file and signature updated successfully. -Package analysis completed - Thu Jan 23 06:35:04 PM EST 2025 +Package analysis completed - Sun Jan 26 05:40:19 PM EST 2025 diff --git a/opkg-feed/Packages.sig b/opkg-feed/Packages.sig index 7ecab8f..239b7dd 100644 --- a/opkg-feed/Packages.sig +++ b/opkg-feed/Packages.sig @@ -1,2 +1,2 @@ untrusted comment: signed by key 6262698f038d1226 -RWRiYmmPA40SJjyz5YWrwXdu33AL+oORTdot3i2asj6vHf4+0yzAPvwbk16MqeXLl+6YnWScNSp+hKkOvKZJiTQtBEnQmd3hjA0= +RWRiYmmPA40SJquqpCo5N77VJ43z/+2x3FLv/XRFvh+Fb5dkLHP8JzpiwUK5G9Q8o7qciMeH8qlQ+t7BTIkQOx/U12svTKKP4Ao= diff --git a/opkg-feed/sdxpinn-mount-fix_1.2.0_aarch64_cortex-a53.ipk b/opkg-feed/sdxpinn-mount-fix_1.2.0_aarch64_cortex-a53.ipk deleted file mode 100644 index 94cf8d8..0000000 Binary files a/opkg-feed/sdxpinn-mount-fix_1.2.0_aarch64_cortex-a53.ipk and /dev/null differ diff --git a/opkg-feed/sdxpinn-mount-fix_1.3.1_aarch64_cortex-a53.ipk b/opkg-feed/sdxpinn-mount-fix_1.3.1_aarch64_cortex-a53.ipk new file mode 100644 index 0000000..475beb3 Binary files /dev/null and b/opkg-feed/sdxpinn-mount-fix_1.3.1_aarch64_cortex-a53.ipk differ diff --git a/opkg-feed/sdxpinn-patch_1_all.ipk b/opkg-feed/sdxpinn-patch_1_all.ipk deleted file mode 100644 index 000abdf..0000000 Binary files a/opkg-feed/sdxpinn-patch_1_all.ipk and /dev/null differ diff --git a/opkg-feed/sdxpinn-patch_2.5_all.ipk b/opkg-feed/sdxpinn-patch_2.5_all.ipk new file mode 100644 index 0000000..a379ced Binary files /dev/null and b/opkg-feed/sdxpinn-patch_2.5_all.ipk differ diff --git a/opkg-feed/sdxpinn-quecmanager-beta_1.1.1-2_aarch64_cortex-a53.ipk b/opkg-feed/sdxpinn-quecmanager-beta_1.1.1-2_aarch64_cortex-a53.ipk index b39c188..d16676a 100644 Binary files a/opkg-feed/sdxpinn-quecmanager-beta_1.1.1-2_aarch64_cortex-a53.ipk and b/opkg-feed/sdxpinn-quecmanager-beta_1.1.1-2_aarch64_cortex-a53.ipk differ diff --git a/rcPCIe_SDXPINN_toolkit.sh b/rcPCIe_SDXPINN_toolkit.sh index c78f6c0..c0ad094 100644 --- a/rcPCIe_SDXPINN_toolkit.sh +++ b/rcPCIe_SDXPINN_toolkit.sh @@ -57,38 +57,24 @@ install_mount_fix() { echo -e "\033[31mI was expecting either /etc or /real_rootfs to be a mount point.\033[0m" exit 1 fi - - # Check if /etc is mounted - if grep -qs '/etc ' /proc/mounts; then - echo "Unmounting /etc..." - umount -lf /etc - fi - - # Check if /real_rootfs is mounted - if grep -qs '/real_rootfs ' /proc/mounts; then - # Echo message in red - echo -e "\033[31mThe environment has already been setup. If you want to undo the changes temporarily run service mount-fix stop.\033[0m" - echo -e "\033[31mWant to uninstal? Then run opkg remove sdxpinn-mount-fix\033[0m" - exit 1 - fi # Install mount-fix cd /tmp - curl -O https://raw.githubusercontent.com/$GITUSER/$GITREPO/$GITTREE/opkg-feed/sdxpinn-mount-fix_1.2.0_aarch64_cortex-a53.ipk - opkg install sdxpinn-mount-fix_1.2.0_aarch64_cortex-a53.ipk + curl -O https://raw.githubusercontent.com/$GITUSER/$GITREPO/$GITTREE/opkg-feed/sdxpinn-mount-fix_1.3.1_aarch64_cortex-a53.ipk + opkg install sdxpinn-mount-fix_1.3.1_aarch64_cortex-a53.ipk } basic_55x_setup() { overlay_check || return - echo "src/gz iamromulan-SDXPINN-repo https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/SDXPINN/opkg-feed" >> /etc/opkg/customfeeds.conf cd /tmp - curl -O https://raw.githubusercontent.com/$GITUSER/$GITREPO/$GITTREE/opkg-feed/iamromulan-SDXPINN-repo.key - opkg-key add /tmp/iamromulan-SDXPINN-repo.key + curl -O https://raw.githubusercontent.com/$GITUSER/$GITREPO/$GITTREE/opkg-feed/sdxpinn-patch_2.5_all.ipk + opkg install sdxpinn-patch_2.5_all.ipk opkg update echo -e "\e[92m" - echo "iamromulan's ipk/opkg repo added!...." - echo -e "\e[0m" + echo "iamromulan's ipk/opkg repo added!" + echo "Installing basic packages..." opkg install atinout luci-app-atinout-mod sdxpinn-console-menu - + echo "Patching default Quectel login binary..." + echo -e "\e[0m" # Get rid of the Quectel Login Binary opkg install shadow-login mv /bin/login /bin/login.old @@ -111,9 +97,7 @@ basic_55x_setup() { service uhttpd enable - sleep 2 service dropbear enable - sleep 2 service uhttpd start service dropbear start @@ -278,18 +262,15 @@ tailscale_menu() { done } -# Function to install, update, or remove Tailscale +# Function to install tailscale install_update_tailscale() { + overlay_check || return echo -e "\e[1;31mInstalling Tailscale 1.78.1...\e[0m" - cd /tmp - curl -O https://raw.githubusercontent.com/$GITUSER/$GITREPO/$GITTREE/opkg-feed/tailscaled_1.78.1-4_aarch64_cortex-a53.ipk - curl -O https://raw.githubusercontent.com/$GITUSER/$GITREPO/$GITTREE/opkg-feed/tailscale_1.78.1-2_aarch64_cortex-a53.ipk - opkg install tailscaled_1.78.1-4_aarch64_cortex-a53.ipk - opkg install tailscale_1.78.1-2_aarch64_cortex-a53.ipk + opkg update + opkg install luci-app-tailscale echo -e "\e[1;32mTailscale version 1.78.1 installed\e[0m" - echo -e "\e[1;32mNEW! The luci-app-tailscale package is avalible in iamromulan's repo!\e[0m" - echo -e "\e[1;32mInstall from Luci Software after installing the repo.\e[0m" + echo -e "\e[1;32mNEW! Tailscale can be configured from Luci\e[0m" } @@ -297,25 +278,21 @@ install_update_tailscale() { configure_tailscale() { while true; do echo "Configure Tailscale" - echo -e "\e[38;5;40m1) Enable Tailscale Web UI at http://192.168.225.1:8088 (Gateway on port 8088)\e[0m" # Green - echo -e "\e[38;5;196m2) Disable Tailscale Web UI\e[0m" # Red - echo -e "\e[38;5;27m3) Connect to Tailnet\e[0m" # Brown - echo -e "\e[38;5;87m4) Connect to Tailnet with SSH ON\e[0m" # Light cyan - echo -e "\e[38;5;105m5) Reconnect to Tailnet with SSH OFF\e[0m" # Light magenta - echo -e "\e[38;5;172m6) Disconnect from Tailnet (reconnects at reboot)\e[0m" # Light yellow - echo -e "\e[1;31m7) Logout from tailscale account\e[0m" - echo -e "\e[38;5;27m8) Return to Tailscale Menu\e[0m" + echo -e "\e[38;5;27m1) Connect to Tailnet\e[0m" # Brown + echo -e "\e[38;5;87m2) Connect to Tailnet with SSH ON\e[0m" # Light cyan + echo -e "\e[38;5;105m3) Reconnect to Tailnet with SSH OFF\e[0m" # Light magenta + echo -e "\e[38;5;172m4) Disconnect from Tailnet (reconnects at reboot)\e[0m" # Light yellow + echo -e "\e[1;31m5) Logout from tailscale account\e[0m" + echo -e "\e[38;5;27m6) Return to Tailscale Menu\e[0m" read -p "Enter your choice: " config_choice case $config_choice in - 1) echo -e "\e[38;5;196mNot for the 551 yet\e[0m" ;; # Red - 2) echo -e "\e[38;5;196mNot for the 551 yet\e[0m" ;; # Red + 1) tailscale up --accept-dns=false --reset ;; + 2) tailscale up --ssh --accept-dns=false --reset ;; 3) tailscale up --accept-dns=false --reset ;; - 4) tailscale up --ssh --accept-dns=false --reset ;; - 5) tailscale up --accept-dns=false --reset ;; - 6) tailscale down ;; - 7) tailscale logout ;; - 8) break ;; + 4) tailscale down ;; + 5) tailscale logout ;; + 6) break ;; *) echo "Invalid option" ;; esac done @@ -394,7 +371,7 @@ while true; do echo -e "\e[92m2) Install sdxpinn-mount-fix/run me after a flash!\e[0m" # Green echo -e "\e[94m3) TTL Setup\e[0m" # Light Blue echo -e "\e[92m4) MTU Setup\e[0m" # Light Green - echo -e "\e[94m5) Install Basic Packages/enable luci/add iamromulan's feed to opkg\e[0m" # Light Blue + echo -e "\e[94m5) Install Basic Packages/enable luci/dropbear and add iamromulan's feed to opkg\e[0m" # Light Blue echo -e "\e[94m6) Set root password\e[0m" # Light Blue echo -e "\e[94m7) Tailscale Management\e[0m" # Light Blue echo -e "\e[92m8) Install Speedtest.net CLI app (speedtest command)\e[0m" # Light Green diff --git a/rcPCIe_SDXPINN_toolkit.sh.progress b/rcPCIe_SDXPINN_toolkit.sh.progress deleted file mode 100644 index 7e8a31a..0000000 --- a/rcPCIe_SDXPINN_toolkit.sh.progress +++ /dev/null @@ -1,445 +0,0 @@ -#!/bin/ash - -#WORK IN PROGRESS - -# Define toolkit paths -GITUSER="iamromulan" -GITREPO="quectel-rgmii-toolkit" -GITTREE="development-SDXPINN" -GITMAINTREE="SDXPINN" -GITDEVTREE="development-SDXPINN" -TMP_DIR="/tmp" -USRDATA_DIR="/data" -SIMPLE_FIREWALL_DIR="/data/simplefirewall" -SIMPLE_FIREWALL_SCRIPT="$SIMPLE_FIREWALL_DIR/simplefirewall.sh" -SIMPLE_FIREWALL_SYSTEMD_DIR="$SIMPLE_FIREWALL_DIR/systemd" - -# Function to remount file system as read-write -remount_rw() { - mount -o remount,rw / -} - -# Function to remount file system as read-only -remount_ro() { - mount -o remount,ro / -} - -send_at_commands_using_atcmd() { - while true; do - echo -e "\e[1;32mEnter AT command (or type 'exit' to return to the main menu): \e[0m" - read at_command - if [ "$at_command" = "exit" ]; then - echo -e "\e[1;32mReturning to the main menu.\e[0m" - break - fi - echo -e "\e[1;32mSending AT command: $at_command\e[0m" - echo -e "\e[1;32mResponse:\e[0m" - # Use atcmd to send the command and display the output - atcmd_output=$(atcmd "'$at_command'") - echo "$atcmd_output" - echo -e "\e[1;32m----------------------------------------\e[0m" - done -} - - -overlay_check() { - if ! grep -qs '/real_rootfs ' /proc/mounts; then - echo -e "\e[31mYou have not installed the sdxpinn-mount-fix!!! Please run option 2!!\e[0m" - return 1 - fi -} - -repo_check() { - # To add later -} - -install_mount_fix() { - # Check if neither /etc nor /real_rootfs is mounted - if ! grep -qs '/etc ' /proc/mounts && ! grep -qs '/real_rootfs ' /proc/mounts; then - # Echo message in red - echo -e "\033[31mSomething is wrong or this is not an SDXPINN modem.\033[0m" - echo -e "\033[31mI was expecting either /etc or /real_rootfs to be a mount point.\033[0m" - exit 1 - fi - - # Check if /etc is mounted - if grep -qs '/etc ' /proc/mounts; then - echo "Unmounting /etc..." - umount -lf /etc - fi - - # Check if /real_rootfs is mounted - if grep -qs '/real_rootfs ' /proc/mounts; then - # Echo message in red - echo -e "\033[31mThe environment has already been setup. If you want to undo the changes temporarily run service mount-fix stop.\033[0m" - echo -e "\033[31mWant to uninstal? Then run opkg remove sdxpinn-mount-fix\033[0m" - exit 1 - fi - # Install mount-fix - cd /tmp - curl -O https://raw.githubusercontent.com/$GITUSER/$GITREPO/$GITTREE/opkg-feed/sdxpinn-mount-fix_1.2.0_aarch64_cortex-a53.ipk - opkg install sdxpinn-mount-fix_1.2.0_aarch64_cortex-a53.ipk -} - -basic_55x_setup() { - overlay_check || return - echo "src/gz iamromulan-SDXPINN-repo https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/SDXPINN/opkg-feed" >> /etc/opkg/customfeeds.conf - cd /tmp - curl -O https://raw.githubusercontent.com/$GITUSER/$GITREPO/$GITTREE/opkg-feed/iamromulan-SDXPINN-repo.key - opkg-key add /tmp/iamromulan-SDXPINN-repo.key - opkg update - echo -e "\e[92m" - echo "iamromulan's ipk/opkg repo added!...." - echo -e "\e[0m" - opkg install atinout luci-app-atinout-mod sdxpinn-console-menu - - # Get rid of the Quectel Login Binary - opkg install shadow-login - mv /bin/login /bin/login.old - cp /usr/bin/login /bin/login - - opkg install luci-app-ttyd - opkg install mc-skins - - # Check and download /etc/init.d/dropbear if missing - [ -f /etc/init.d/dropbear ] || { - curl -o /etc/init.d/dropbear https://raw.githubusercontent.com/$GITUSER/$GITREPO/$GITTREE/missing/dropbear && - chmod +x /etc/init.d/dropbear; - } - - # Check and download /etc/init.d/uhttpd if missing - [ -f /etc/init.d/uhttpd ] || { - curl -o /etc/init.d/uhttpd https://raw.githubusercontent.com/$GITUSER/$GITREPO/$GITTREE/missing/uhttpd && - chmod +x /etc/init.d/uhttpd; - } - - - service uhttpd enable - sleep 2 - service dropbear enable - sleep 2 - service uhttpd start - service dropbear start - - echo "Basic packages installed!" - echo "Visit https://github.com/iamromulan for more!" - echo -e "\e[0m" -} - -ttl_setup() { - local ttl_file="/etc/firewall.user.ttl" - local lan_utils_script="/etc/data/lanUtils.sh" - local combine_function="util_combine_iptable_rules" - local temp_file="/tmp/temp_firewall_user_ttl" - - overlay_check || return - - while true; do - if [ ! -f "$ttl_file" ]; then - echo "Creating $ttl_file..." - touch "$ttl_file" - - echo "Modifying $combine_function in $lan_utils_script..." - - # Backup the original script - cp "$lan_utils_script" "${lan_utils_script}.bak" - - # Add the local ttl_firewall_file line if it's not already present - if ! grep -q "local ttl_firewall_file" "$lan_utils_script"; then - sed -i '/local tcpmss_firewall_filev6/a \ local ttl_firewall_file=/etc/firewall.user.ttl' "$lan_utils_script" - fi - - # Add the condition to include the ttl_firewall_file if it's not already present - if (! grep -q "if \[ -f \"\$ttl_firewall_file\" \]; then" "$lan_utils_script"); then - sed -i '/if \[ -f "\$tcpmss_firewall_filev6" \]; then/i \ if [ -f "\$ttl_firewall_file" ]; then\n cat \$ttl_firewall_file >> \$firewall_file\n fi' "$lan_utils_script" - fi - fi - - if [ ! -s "$ttl_file" ]; then - echo -e "\e[31mTTL is not enabled\e[0m" - else - ipv4_ttl=$(grep 'iptables -t mangle -A POSTROUTING' "$ttl_file" | awk '{for(i=1;i<=NF;i++){if($i=="--ttl-set"){print $(i+1)}}}') - ipv6_ttl=$(grep 'ip6tables -t mangle -A POSTROUTING' "$ttl_file" | awk '{for(i=1;i<=NF;i++){if($i=="--hl-set"){print $(i+1)}}}') - echo -e "\e[32mCurrent IPv4 TTL: $ipv4_ttl\e[0m" - echo -e "\e[32mCurrent IPv6 TTL: $ipv6_ttl\e[0m" - fi - - echo -e "\e[32mWould you like to edit the TTL settings?\e[0m" - echo -e "\e[32mTTL Value will be set without needing a reboot \e[0m" - echo -e "\e[33mType yes or exit:\e[0m" && read -r response - - if [ "$response" = "exit" ]; then - echo "Exiting..." - break - elif [ "$response" = "yes" ]; then - echo -e "\e[32mType 0 to disable TTL\e[0m" - echo -e "\e[33mEnter the TTL value (number only):\e[0m" && read -r ttl_value - if ! [[ "$ttl_value" =~ ^[0-9]+$ ]]; then - echo "Invalid input, please enter a number." - else - # Clear existing TTL rules - echo "Clearing existing TTL rules..." - iptables -t mangle -D POSTROUTING -o rmnet+ -j TTL --ttl-set "$ipv4_ttl" - ip6tables -t mangle -D POSTROUTING -o rmnet+ -j HL --hl-set "$ipv6_ttl" - - if [ "$ttl_value" -eq 0 ]; then - echo "Disabling TTL..." - > "$ttl_file" - else - echo "Setting TTL to $ttl_value..." - echo "iptables -t mangle -A POSTROUTING -o rmnet+ -j TTL --ttl-set $ttl_value" > "$ttl_file" - echo "ip6tables -t mangle -A POSTROUTING -o rmnet+ -j HL --hl-set $ttl_value" >> "$ttl_file" - iptables -t mangle -A POSTROUTING -o rmnet+ -j TTL --ttl-set $ttl_value - ip6tables -t mangle -A POSTROUTING -o rmnet+ -j HL --hl-set $ttl_value - fi - fi - fi - done -} - -mtu_setup() { - local mtu_file="/etc/firewall.user.mtu" - local lan_utils_script="/etc/data/lanUtils.sh" - local combine_function="util_combine_iptable_rules" - - overlay_check || return - - while true; do - # Ensure the MTU configuration file exists - if [ ! -f "$mtu_file" ]; then - echo "Creating $mtu_file..." - touch "$mtu_file" - - echo "Modifying $combine_function in $lan_utils_script..." - - # Backup the original script - cp "$lan_utils_script" "${lan_utils_script}.bak" - - # Add the local mtu_firewall_file line if it's not already present - if ! grep -q "local mtu_firewall_file" "$lan_utils_script"; then - sed -i '/local tcpmss_firewall_filev6/a \ local mtu_firewall_file=/etc/firewall.user.mtu' "$lan_utils_script" - fi - - # Add the condition to include the mtu_firewall_file if it's not already present - if ! grep -q "if \[ -f \"\$mtu_firewall_file\" \]; then" "$lan_utils_script"; then - sed -i '/if \[ -f "\$ttl_firewall_file" \]; then/i \ if [ -f "\$mtu_firewall_file" ]; then\n cat \$mtu_firewall_file >> \$firewall_file\n fi' "$lan_utils_script" - fi - fi - - # Display the current MTU override, if set - if [ ! -s "$mtu_file" ]; then - echo -e "\e[31mMTU override is not set. Default MTU is applied at boot.\e[0m" - else - current_mtu=$(awk '/ip link set/ {print $6; exit}' "$mtu_file") - echo -e "\e[32mCurrent MTU override: $current_mtu\e[0m" - fi - - # Prompt user for actions - echo -e "\e[32mWould you like to edit the MTU override?\e[0m" - echo -e "\e[33mType a new MTU value, exit, or 0 to disable the override:\e[0m" && read -r response - - if [ "$response" = "exit" ]; then - echo "Exiting..." - break - elif [ "$response" = "0" ]; then - echo "Disabling MTU override and clearing the file..." - > "$mtu_file" - elif [[ "$response" =~ ^[0-9]+$ ]]; then - echo "Setting MTU override to $response..." - # Write single commands for each interface to the configuration file - > "$mtu_file" # Clear the file - for iface in $(ls /sys/class/net | grep '^rmnet_data'); do - echo "ip link set $iface mtu $response" >> "$mtu_file" - done - else - echo "Invalid input. Please enter a number, 'exit', or '0'." - fi - done -} - - - - -set_root_passwd() { - passwd -} - -# Function for Tailscale Submenu -tailscale_menu() { - overlay_check - repo_check - while true; do - echo -e "\e[1;32mTailscale Menu\e[0m" - echo -e "\e[1;32m1) Install Tailscale and the Tailscale Luci App\e[0m" - echo -e "\e[1;36m2) Configure Tailscale\e[0m" - echo -e "\e[1;31m3) Return to Main Menu\e[0m" - read -p "Enter your choice: " tailscale_choice - - case $tailscale_choice in - 1) install_update_tailscale ;; - 2) configure_tailscale ;; - 3) break ;; - *) echo "Invalid option" ;; - esac - done -} - -# Function to install, update, or remove Tailscale -install_update_tailscale() { - opkg update - opkg install luci-app-tailscale - - echo -e "\e[1;32mTailscale version 1.78.1 installed\e[0m" - echo -e "\e[1;32mNEW! The luci-app-tailscale package is avalible in iamromulan's repo!\e[0m" - echo -e "\e[1;32mInstall from Luci Software after installing the repo.\e[0m" -} - - -# Function to Configure Tailscale -configure_tailscale() { - while true; do - echo "Configure Tailscale" - echo -e "\e[38;5;27m3) Connect to Tailnet\e[0m" # Brown - echo -e "\e[38;5;87m4) Connect to Tailnet with SSH ON\e[0m" # Light cyan - echo -e "\e[38;5;105m5) Reconnect to Tailnet with SSH OFF\e[0m" # Light magenta - echo -e "\e[38;5;172m6) Disconnect from Tailnet (reconnects at reboot)\e[0m" # Light yellow - echo -e "\e[1;31m7) Logout from tailscale account\e[0m" - echo -e "\e[38;5;27m8) Return to Tailscale Menu\e[0m" - read -p "Enter your choice: " config_choice - - case $config_choice in - 1) echo -e "\e[38;5;196mNot for the 551 yet\e[0m" ;; # Red - 2) echo -e "\e[38;5;196mNot for the 551 yet\e[0m" ;; # Red - 3) tailscale up --accept-dns=false --reset ;; - 4) tailscale up --ssh --accept-dns=false --reset ;; - 5) tailscale up --accept-dns=false --reset ;; - 6) tailscale down ;; - 7) tailscale logout ;; - 8) break ;; - *) echo "Invalid option" ;; - esac - done -} - -# Main menu -while true; do - echo " .%+: " - echo " .*@@@-. " - echo " :@@@@- " - echo " @@@@#. " - echo " -@@@@#. " - echo " :. %@@@@: -# " - echo " .+- #@@@@%.+@- " - echo " .#- . +@@@@# #@- " - echo " -@*@*@% @@@@@::@@= " - echo ".+%@@@@@@@@@%=. =@@@@# #@@- .. " - echo " .@@@@@: :@@@@@ =@@@..%= " - echo " -::@-.+. @@@@@.=@@@- =@- " - echo " .@- .@@@@@:.@@@* @@. " - echo " .%- -@@@@@:=@@@@ @@# " - echo " .#- .%@@@@@@#. +@@@@@.#@@@@ @@@." - echo " .*- .@@@@@@@@@@=. @@@@@@ @@@@@ @@@:" - echo " :. .%@@@@@@@@@@@%. .@@@@@+:@@@@@ @@@-" - echo " -@@@@@@@@@@@@@@@..@@@@@@.-@@@@@ .@@@-" - echo " -@@@@@@@@@@%. .@@@@@@. @@@@@+ =@@@=" - echo " =@@@@@@@@* .@@@@@@. @@@@@@..@@@@-" - echo " #@@@@@@@@-*@@@@@%..@@@@@@+ #@@@@-" - echo " @@@@@@:.-@@@@@@. @@@@@@= %@@@@@." - echo " .@@@@. *@@@@@@- .+@@@@@@-.@@@@@@+ " - echo " %@@. =@@@@@*. +@@@@@@%.-@@@@@@% " - echo " .@@ .@@@@@= :@@@@@@@@..@@@@@@@= " - echo " =@.+@@@@@. -@@@@@@@*.:@@@@@@@*. " - echo " %.*@@@@= .@@@@@@@-.:@@@@@@@+. " - echo " ..@@@@= .@@@@@@: #@@@@@@@: " - echo " .@@@@ +@@@@..%@@@@@+. " - echo " .@@@. @@@@.:@@@@+. " - echo " @@@. @@@. @@@* .@. " - echo " :@@@ %@@..@@#. *@ " - echo " -*: .@@* :@@. @@. -..@@ " - echo " =@@@@@@.*@- :@% @* =@:=@# " - echo " .@@@-+@@@@:%@..%- ...@%:@@: " - echo " .@@. @@-%@: .%@@*@@%. " - echo " :@@ :+ *@ *@@#*@@@. " - echo " =@@@.@@@@ " - echo " .*@@@:=@@@@: " - echo " .@@@@:.@@@@@: " - echo " .@@@@#.-@@@@@. " - echo " #@@@@: =@@@@@- " - echo " .@@@@@..@@@@@@* " - echo " -@@@@@. @@@@@@#. " - echo " -@@@@@ @@@@@@% " - echo " @@@@@. #@@@@@@. " - echo " :@@@@# =@@@@@@% " - echo " @@@@@: @@@@@@@: " - echo " *@@@@ @@@@@@@. " - echo " .@@@@ @@@@@@@ " - echo " #@@@. @@@@@@* " - echo " @@@# @@@@@@@ " - echo " .@@+=@@@@@@. " - echo " *@@@@@@ " - echo " :@@@@@= " - echo " .@@@@@@. " - echo " :@@@@@*. " - echo " .=@@@@@- " - echo " :+##+. " - - echo -e "\e[92m" - echo "Welcome to iamromulan's rcPCIe Toolkit script for Quectel RM55x Series modems!" - echo "Visit https://github.com/iamromulan for more!" - echo -e "\e[0m" - echo -e "\e[91mThis is a test version of the toolkit for the new RM550/551 modems\e[0m" # Light Red - echo "Select an option:" - echo -e "\e[0m" - echo -e "\e[96m1) Send AT Commands\e[0m" # Cyan - echo -e "\e[92m2) Install sdxpinn-mount-fix/run me after a flash!\e[0m" # Green - echo -e "\e[94m3) TTL Setup\e[0m" # Light Blue - echo -e "\e[92m4) MTU Setup\e[0m" # Light Green - echo -e "\e[94m5) Install Basic Packages/enable luci/add iamromulan's feed to opkg\e[0m" # Light Blue - echo -e "\e[94m6) Set root password\e[0m" # Light Blue - echo -e "\e[94m7) Tailscale Management\e[0m" # Light Blue - echo -e "\e[92m8) Install Speedtest.net CLI app (speedtest command)\e[0m" # Light Green - echo -e "\e[93m9) Exit\e[0m" # Yellow (repeated color for exit option) - read -p "Enter your choice: " choice - - case $choice in - 1) send_at_commands_using_atcmd ;; - 2) remount_rw; install_mount_fix ;; - 3) - overlay_check - if [ $? -eq 1 ]; then continue; fi - ttl_setup - ;; - 4) - overlay_check - if [ $? -eq 1 ]; then continue; fi - mtu_setup - ;; - 5) - overlay_check - if [ $? -eq 1 ]; then continue; fi - basic_55x_setup - ;; - - 6) - overlay_check - if [ $? -eq 1 ]; then continue; fi - set_root_passwd - ;; - 7) tailscale_menu ;; - 8) - overlay_check - if [ $? -eq 1 ]; then continue; fi - echo -e "\e[1;32mInstalling Speedtest.net CLI (speedtest command)\e[0m" - cd /tmp - curl -O https://raw.githubusercontent.com/$GITUSER/$GITREPO/$GITTREE/opkg-feed/ookla-speedtest_1.2.0_aarch64_cortex-a53.ipk - opkg install ookla-speedtest_1.2.0_aarch64_cortex-a53.ipk - echo -e "\e[1;32mSpeedtest CLI (speedtest command) installed!!\e[0m" - echo -e "\e[1;32mTry running the command 'speedtest'\e[0m" - echo -e "\e[1;32mNote that it will not work unless you login to the root account first\e[0m" - echo -e "\e[1;32mNormally only an issue in adb, ttyd, and ssh you are forced to login\e[0m" - echo -e "\e[1;32mIf in adb just type login and then try to run the speedtest command\e[0m" - ;; - 9) echo -e "\e[1;32mGoodbye!\e[0m"; break ;; - *) echo -e "\e[1;31mInvalid option\e[0m" ;; - esac -done