#!/bin/sh /etc/rc.common
# Finish nested IPK install after bmsos-bundle upload.
# Must survive LuCI/rpcd timeouts — do NOT run nested opkg inside postinst foreground.

START=99
STOP=10
USE_PROCD=1

start_service() {
	[ -f /etc/bmsos-bundle.ok ] && return 0
	[ -x /usr/bin/bmsos-bundle-install ] || return 0
	[ -d /usr/lib/bmsos-bundle/ipks ] || return 0

	procd_open_instance
	procd_set_param command /bin/sh -c \
		'/usr/bin/bmsos-bundle-install > /tmp/bmsos-bundle-install.log 2>&1; echo exit:$? >> /tmp/bmsos-bundle-install.log'
	procd_set_param nice 5
	procd_close_instance
}
