#!/bin/sh

disable_services() {
	local T0=$(date +%s)
	if [ $1 -eq 0 ] ; then
		nothup bash -c "systemctl stop taosd ; sync"
	else
		systemctl stop linit
		systemctl stop taosd ; sync
	fi
	systemctl stop emsd
	systemctl stop emud
	systemctl stop script
	systemctl stop bmser_lib
	systemctl stop check_history_data
	systemctl stop tmpubuslog
	local T1=$(date +%s)
	return $((T1 - T0))
}

export PATH=/opt/lnxall_app/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[ -e /lib/dyiot/init.d/dido_modbus_tcp ] && /lib/dyiot/init.d/dido_modbus_tcp stop
nothup lua /lib/dyiot/bin/setdodown.lua

disable_services 0
[ $? -le 2 ] && sleep 1
disable_services 1
exit 0
