#!/bin/sh
# chkconfig: 2345 25 75
### BEGIN INIT INFO
# Provides:          kccm
# Required-Start:    
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      1
# Short-Description: Start kccm applications at boot time
# Description:       Run the aws-iot app required for KCCM.
# X-Start-Before:
# X-Stop-After:
# X-Timesys-Start-Number:  25
# X-Timesys-Stop-Number:  75
### END INIT INFO

case "${1}" in
  start)                   
	cd /home/
	./createsha1.sh
	sync
	sleep 3
	rm -rf /home/createsha1.sh
	./update.sh                       
       cd /kccm/script/
       chmod +x supervisor
       ./supervisor&
	/usr/bin/crontab /etc/crontab.conf
	sleep 1
	/usr/sbin/crond &
	cd /
       echo "KCCM apps started"
    ;;

  stop)
    echo "KCCM apps stopped"
    ;;

  restart)
    ${0} stop
    sleep 1
    ${0} start
    ;;

  *)
    echo "Usage: $0 [start|stop|restart]"
    ;;
esac
