#!/bin/sh -


if [ -f '/etc/profile' ]; then
	. /etc/profile
	_apt_cache='/var/cache'
	_givemedeb_daemon='/Library/LaunchDaemons/com.nan.givemedeb.plist'
elif [ -f '/var/jb/etc/profile' ]; then
	. /var/jb/etc/profile
	_apt_cache='/var/jb/var/cache'
	_givemedeb_daemon='/var/jb/Library/LaunchDaemons/com.nan.givemedeb.plist'
else
	echo 'Where the fuck "profile"?' 1>&2
	exit 1
fi
_save_path='/var/mobile/Downloads/dpkg_triggered'
_tmp_folder="${_apt_cache}/givemedeb_caches"

if [ -e "${_tmp_folder}" ]; then
	mkdir -p "${_save_path}"
	mv -f "${_tmp_folder}/"* "${_save_path}"
	rm -rf "${_tmp_folder}"
fi
launchctl unload "${_givemedeb_daemon}"
exit 0
