#!/bin/bash

/usr/local/bin/hj/s700_oled >> /dev/null 2>&1 &

sysctl -p;

CRON_FILE="/etc/crontab"

#disable crontab
service cron stop
sed -i 's%\(.*/home/hj/smarthome/script/monitor.sh\)%#\1%' $CRON_FILE;

#/usr/local/bin/hj/hj_auth_ccuid.sh
ccuid_hostname=`cat /etc/hj_ccuid`;
curr_hostname=`cat /etc/hostname`;
if [ "$ccuid_hostname" != "$curr_hostname" ]; then
        echo "$ccuid_hostname" > /etc/hostname;
        hostname $ccuid_hostname;
fi

ping -c 1 -W 1 114.114.114.114
if [ $? -eq 0 ];then
   ntpdate -p 2 0.debian.pool.ntp.org && hwclock -w --utc
fi

/usr/local/bin/hj/HJ_Firmware monitor upgrade.cloud.hijaytech.com upgrade.cloud.hijaytech.com >/dev/null 2>&1 &

sleep 1
sh /usr/local/bin/hj/check_konkeyunzhiyi.sh &

#enable crontab
sed -i 's%\(^##*\)\(.*/home/hj/smarthome/script/monitor.sh\)%\2%' $CRON_FILE;
service cron start

