sdxpinn-mount-fix 1.0.7

Using a post init.d script now to add extra opkg status entries
This commit is contained in:
iamromulan
2024-10-05 02:34:15 -04:00
parent 368825c13a
commit 4e361eb336
4 changed files with 34 additions and 87 deletions

View File

@@ -1,16 +1,13 @@
#!/bin/ash /etc/rc.common
# Include the procd init functionality
START=99
STOP=10
USE_PROCD=1
START=99
STOP=15
# Define variables for bundled packages and status file
STATUS_FILE="/usr/lib/opkg/status"
LOCK_FILE="/tmp/opkg.lock"
# Define the details for the bundled packages to be added to the status file
PACKAGE_DETAILS="
# Bundled package information to be added
BUNDLED_PACKAGES_INFO="
Package: libinotifytools
Version: 3.20.11.0-1
Depends: libc
@@ -27,30 +24,37 @@ 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/ash -c "add_status_entries"
procd_set_param respawn
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
}
add_status_entries() {
echo "add_opkg_status_bundled: Waiting for the lock file $LOCK_FILE to be released..."
while [ -f "$LOCK_FILE" ]; do
sleep 1
done
echo "add_opkg_status_bundled: Lock released. Updating $STATUS_FILE."
# Append the package details to the status file
echo "$PACKAGE_DETAILS" >> "$STATUS_FILE"
echo "add_opkg_status_bundled: Successfully updated the status file with bundled package details."
# Remove the init script to prevent it from running again
echo "add_opkg_status_bundled: Removing self from /etc/init.d..."
rm -f /etc/init.d/add_opkg_status_bundled
echo "add_opkg_status_bundled: Service removed successfully."
echo "add_opkg_status_bundled: Exiting service."
stop_service() {
echo "Stopping add_opkg_status_bundled service (if running)..."
}