-for deb in /var/mobile/Media/Cydia/AutoInstall/*.deb; do
- /usr/bin/dpkg -i "${deb}" && /bin/rm "${deb}"
-done
+
+debs=(/var/root/Media/Cydia/AutoInstall/*.deb)
+if [[ ${#debs[@]} -ne 0 && -f ${debs[0]} ]]; then
+ dpkg -i "${debs[@]}"
+ rm -f "${debs[@]}"
+ cache=
+fi
+
+if [[ ${cache+@} ]]; then
+ su -c uicache mobile
+fi