SD_dir="/run/media/mmcblk1p1"
srcMDDB_dir="/usr/share/modem/db/"
dstMDDB_dir="/run/media/mmcblk1p1/mtklog/mdlog1/"

do_tag_MDDB_sdcard() {
	if [ ! -d "$dstMDDB_dir" ]; then
		mkdir -p "$dstMDDB_dir"
	fi
	cp -f "$srcMDDB_dir"*"" $dstMDDB_dir
}

do_automount_postfun() {
	if [ -x /bin/syslogctl ];then
		/bin/syslogctl restart
	fi
	systemctl start tcpdump
	if [ -d "$SD_dir" ]; then
		do_tag_MDDB_sdcard
	fi
}

do_remove_prefun() {
	if [ -x /bin/syslogctl ];then
		/bin/syslogctl stop
	fi
	if [ -x /sbin/eemcs_mdlogger ];then
		echo 5 | /sbin/eemcs_mdlogger_ctrl
	fi
	systemctl stop tcpdump
}

do_remove_postfun() {
	if [ -x /bin/syslogctl ];then
		/bin/syslogctl start
	fi
}

case "$1" in
	automount_postfun )
		do_automount_postfun
		;;

	remove_prefun )
		do_remove_prefun
		;;

	remove_postfun)
		do_remove_postfun
		;;
	* )
		echo "Usage: $0 automount_postfun|remove_prefun|remove_postfun"
		;;

esac
