sdxpinn-mount-fix 1.0.7
Using a post init.d script now to add extra opkg status entries
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
Package: sdxpinn-mount-fix
|
||||
Version: 1.0.6
|
||||
Version: 1.0.7
|
||||
Architecture: aarch64_cortex-a53
|
||||
Maintainer: Cameron Thompson iamromulan@github.com
|
||||
Description: Creates a usable mount space and overlay for SDXPINN modems
|
||||
|
||||
@@ -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)..."
|
||||
}
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/bin/ash
|
||||
|
||||
# Function to update the status file with a properly formatted entry
|
||||
add_to_status_file() {
|
||||
local bundled_package_name="$1"
|
||||
local version="$2"
|
||||
local depends="$3"
|
||||
local arch="$4"
|
||||
local installed_time="$5"
|
||||
|
||||
# Status file location
|
||||
local status_file="/usr/lib/opkg/status"
|
||||
|
||||
# Debugging: Output the details of the package being added
|
||||
echo "Adding package: $bundled_package_name"
|
||||
echo "Version: $version"
|
||||
echo "Depends: $depends"
|
||||
echo "Architecture: $arch"
|
||||
echo "Installed-Time: $installed_time"
|
||||
|
||||
# Check if the package already exists in the status file
|
||||
if grep -q "Package: $bundled_package_name" "$status_file"; then
|
||||
echo "Removing old entry for $bundled_package_name from $status_file"
|
||||
sed -i "/Package: $bundled_package_name/,/^$/d" "$status_file"
|
||||
else
|
||||
echo "No existing entry for $bundled_package_name found. Adding new entry."
|
||||
fi
|
||||
|
||||
# Append the new formatted entry to the status file
|
||||
echo "Appending new entry for $bundled_package_name to $status_file"
|
||||
cat << EOF >> "$status_file"
|
||||
Package: $bundled_package_name
|
||||
Version: $version
|
||||
Depends: $depends
|
||||
Status: install user installed
|
||||
Architecture: $arch
|
||||
Installed-Time: $installed_time
|
||||
|
||||
EOF
|
||||
|
||||
# Verification: Check if the package was added correctly
|
||||
if grep -q "Package: $bundled_package_name" "$status_file"; then
|
||||
echo "Successfully added $bundled_package_name to $status_file."
|
||||
else
|
||||
echo "Failed to add $bundled_package_name to $status_file."
|
||||
fi
|
||||
}
|
||||
|
||||
# Example usage: adding `libinotifytools` and `inotifywait` with dummy values
|
||||
add_to_status_file "libinotifytools" "3.20.11.0-1" "libc" "aarch64_cortex-a53" "315965672"
|
||||
add_to_status_file "inotifywait" "3.20.11.0-1" "libc, libinotifytools" "aarch64_cortex-a53" "315965672"
|
||||
|
||||
# Output the entire status file for review
|
||||
echo "Current status file:"
|
||||
cat /usr/lib/opkg/status
|
||||
|
||||
echo "Status file update completed."
|
||||
Reference in New Issue
Block a user