Update postinst

This commit is contained in:
iamromulan
2024-10-04 21:44:25 -04:00
parent f7e89663ee
commit 861085cb26

View File

@@ -1,21 +1,35 @@
#!/bin/ash #!/bin/ash
# Define the package name # Define the package name for the main package
PKG_NAME="sdxpinn-mount-fix" PKG_NAME="sdxpinn-mount-fix"
# Define the list file location
LIST_FILE="/usr/lib/opkg/info/${PKG_NAME}.list" LIST_FILE="/usr/lib/opkg/info/${PKG_NAME}.list"
# Replace distfeeds.conf with non-working sources commented out # Function to handle bundled packages post-install
# Check if the temporary distfeeds.conf file exists handle_bundled_postinst() {
if [ -f /tmp/distfeeds.conf ]; then local bundled_package="$1"
# Backup the existing /etc/opkg/distfeeds.conf if it exists
if [ -f /etc/opkg/distfeeds.conf ]; then # Use the target package name for default_postinst instead of $0
cp /etc/opkg/distfeeds.conf /etc/opkg/distfeeds.conf.bak if [ "${IPKG_NO_SCRIPT}" = "1" ]; then
echo "Backed up original /etc/opkg/distfeeds.conf to /etc/opkg/distfeeds.conf.bak" return 0
fi fi
# Move the new distfeeds.conf from /tmp to /etc/opkg # 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"
default_postinst "$bundled_package" $@
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 mv /tmp/distfeeds.conf /etc/opkg/distfeeds.conf
echo "Replaced /etc/opkg/distfeeds.conf with the custom version." echo "Replaced /etc/opkg/distfeeds.conf with the custom version."
else else
@@ -25,57 +39,37 @@ fi
echo "Combo package cleanup in progress..." echo "Combo package cleanup in progress..."
# Check if the .list file exists and modify it # Remove entries in the .list file that refer to opkg control files
if [ -f "$LIST_FILE" ]; then if [ -f "$LIST_FILE" ]; then
# Remove any lines that start with /usr/lib/opkg/info/
sed -i '/^\/usr\/lib\/opkg\/info\//d' "$LIST_FILE" sed -i '/^\/usr\/lib\/opkg\/info\//d' "$LIST_FILE"
echo "Removed control file entries from $LIST_FILE." echo "Removed control file entries from $LIST_FILE."
else else
echo "Warning: ${LIST_FILE} not found." echo "Warning: ${LIST_FILE} not found."
fi fi
# Make the init scripts and binaries executable
chmod +x /etc/init.d/mount-fix /etc/init.d/init-overlay-watchdog /usr/sbin/init-overlay-watchdog.sh
# Make the init script executable # Enable and start the services
chmod +x /etc/init.d/mount-fix echo "Starting services..."
chmod +x /etc/init.d/init-overlay-watchdog
chmod +x /usr/sbin/init-overlay-watchdog.sh
# Enable and start the service
service mount-fix enable service mount-fix enable
service mount-fix start service mount-fix start
sleep 1 sleep 1
service init-overlay-watchdog enable service init-overlay-watchdog enable
service init-overlay-watchdog start service init-overlay-watchdog start
echo -e "\e[32m sdxpinn-mount-fix installed! Here is the new file structure! \e[0m" echo -e "\e[32m sdxpinn-mount-fix installed! Here is the new file structure! \e[0m"
echo -e "\e[32m ============================================================ \e[0m" echo -e "\e[32m ============================================================ \e[0m"
mount && df -h mount && df -h
echo -e "\e[32m ============================================================ \e[0m" echo -e "\e[32m ============================================================ \e[0m"
echo -e "\e[32m sdxpinn-mount-fix installed! New file structure above! \e[0m" echo -e "\e[32m sdxpinn-mount-fix installed! New file structure above! \e[0m"
# Define the target bundled package name for this script # Handle bundled packages
BUNDLED_PACKAGE_NAME_1="libinotifytools" BUNDLED_PACKAGES=("libinotifytools" "inotifywait")
# Check if the IPKG_NO_SCRIPT flag is set or if the required functions script is missing for package in "${BUNDLED_PACKAGES[@]}"; do
[ "${IPKG_NO_SCRIPT}" = "1" ] && exit 0 handle_bundled_postinst "$package"
[ -s ${IPKG_INSTROOT}/lib/functions.sh ] || exit 0 done
# Source the necessary functions
. ${IPKG_INSTROOT}/lib/functions.sh
# Use the target package name for default_postinst instead of $0
default_postinst "${BUNDLED_PACKAGE_NAME_1}" $@
# Define the target bundled package name for this script
BUNDLED_PACKAGE_NAME_2="inotifywait"
# Check if the IPKG_NO_SCRIPT flag is set or if the required functions script is missing
[ "${IPKG_NO_SCRIPT}" = "1" ] && exit 0
[ -s ${IPKG_INSTROOT}/lib/functions.sh ] || exit 0
# Source the necessary functions
. ${IPKG_INSTROOT}/lib/functions.sh
# Use the target package name for default_postinst instead of $0
default_postinst "${BUNDLED_PACKAGE_NAME_2}" $@
exit 0 exit 0