JB=$(ls -d /var/containers/Bundle/Application/.jbroot-* | head -1)
APP="$JB/Applications/Driver.app"
M=/rootfs/private/var/mobile/Media
echo "APP=$APP"
ls -la "$APP/Driver" 2>/dev/null | head -2
echo "--- kill running ---"
for p in $(launchctl list 2>/dev/null | grep "UIKitApplication:vn.gsm.md" | awk '{print $1}'); do
  [ "$p" != "-" ] && kill -9 "$p" 2>/dev/null && echo "killed $p"
done
sleep 1
echo "--- install build 46 binaries into the registered location ---"
cp -p "$APP/Driver" "$APP/Driver.bak45" 2>/dev/null && echo bak_ok
cp "$M/dump319/Driver.bin" /dev/null 2>/dev/null
cp "$APP/Driver.bak45" /dev/null 2>/dev/null
echo "--- copy from Media (the rebuilt files were pushed earlier) ---"
ls -la "$M"/drv46.bin "$M"/bi46.bin 2>&1 | head -2
echo INST46B_DONE
