Merge branch 'development-SDXPINN' into SDXPINN
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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..."
|
||||
|
||||
@@ -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
|
||||
@@ -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)..."
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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/
|
||||
Binary file not shown.
@@ -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
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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 <daniel@makrotopia.org>
|
||||
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.
|
||||
@@ -1 +0,0 @@
|
||||
/usr/bin/inotifywait
|
||||
@@ -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 $@
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ -s ${IPKG_INSTROOT}/lib/functions.sh ] || exit 0
|
||||
. ${IPKG_INSTROOT}/lib/functions.sh
|
||||
default_prerm $0 $@
|
||||
@@ -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 <daniel@makrotopia.org>
|
||||
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.
|
||||
@@ -1,3 +0,0 @@
|
||||
/usr/lib/libinotifytools.so.0.4.1
|
||||
/usr/lib/libinotifytools.so
|
||||
/usr/lib/libinotifytools.so.0
|
||||
@@ -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 $@
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ -s ${IPKG_INSTROOT}/lib/functions.sh ] || exit 0
|
||||
. ${IPKG_INSTROOT}/lib/functions.sh
|
||||
default_prerm $0 $@
|
||||
@@ -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
|
||||
|
||||
343
ipk-source/sdxpinn-mount-fix/root/usrdata/etc/init.d/mount-fix
Executable file
343
ipk-source/sdxpinn-mount-fix/root/usrdata/etc/init.d/mount-fix
Executable file
@@ -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"
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1 +1 @@
|
||||
1
|
||||
2
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user