1
0
mirror of https://github.com/fritz-smh/yi-hack.git synced 2026-08-20 04:42:59 +00:00

Voice notification, crond, led flash for error, log storage status

Add voice notification in English
Launch crond daemon be default
Check wifi connection status before ending:
    Cannot reach gateway: flash yellow led
    Normal: notification on English and led as configuraion
Log storage status by "df -h" to log file
Minor bug fix
Strip trainling spaces
This commit is contained in:
Tuan Minh Dang
2016-09-04 16:41:52 +07:00
parent cddc53daed
commit 7cb39f8da2
17 changed files with 102 additions and 69 deletions
+65 -32
View File
@@ -26,7 +26,6 @@
# * strem audio from network to camera ==> svoxpico ? # * strem audio from network to camera ==> svoxpico ?
# * create a watchdog script # * create a watchdog script
led() { led() {
# example usage : # example usage :
# led -boff -yon # led -boff -yon
@@ -69,8 +68,8 @@ get_config() {
### first we assume that this script is started from /home/init.sh and will replace it from the below lines (which are not commented in init.sh : ### first we assume that this script is started from /home/init.sh and will replace it from the below lines (which are not commented in init.sh :
#if [ -f "/home/hd1/test/equip_test.sh" ]; then #if [ -f "/home/hd1/test/equip_test.sh" ]; then
# /home/hd1/test/equip_test.sh # /home/hd1/test/equip_test.sh
# exit # exit
#fi #fi
###################################################### ######################################################
@@ -83,6 +82,7 @@ telnetd &
### configure timezone ### configure timezone
echo "$(get_config TIMEZONE)" > /etc/TZ echo "$(get_config TIMEZONE)" > /etc/TZ
### get time is done after wifi configuration! ### get time is done after wifi configuration!
@@ -113,6 +113,10 @@ cd /home/3518
# added : # added :
himm 0x20050074 0x06802424 himm 0x20050074 0x06802424
### Let ppl hear that we start
/home/rmm "/home/hd1/voice/welcome.g726" 1
/home/rmm "/home/hd1/voice/wait.g726" 1
### start blinking blue led for configuration in progress ### start blinking blue led for configuration in progress
#/home/led_ctl -boff -yon & #/home/led_ctl -boff -yon &
led -yoff -bfast led -yoff -bfast
@@ -178,11 +182,11 @@ count=5
while [ $count -gt 0 ] while [ $count -gt 0 ]
do do
if [ -f "/tmp/init_finish" ]; then if [ -f "/tmp/init_finish" ]; then
break break
else else
count=`expr $count - 1` count=`expr $count - 1`
echo "wait init" $count echo "wait init" $count
sleep 1 sleep 1
fi fi
done done
@@ -256,12 +260,16 @@ log "Debug mode = $(get_config DEBUG)"
# first, configure wifi # first, configure wifi
### Let ppl hear that we start connect wifi
/home/rmm "/home/hd1/voice/connectting.g726" 1
log "Check for wifi configuration file...*" log "Check for wifi configuration file...*"
log $(find /home -name "wpa_supplicant.conf") log $(find /home -name "wpa_supplicant.conf")
log "Start wifi configuration..." log "Start wifi configuration..."
log $(/home/wpa_supplicant -B -i ra0 -c /home/wpa_supplicant.conf ) res=$(/home/wpa_supplicant -B -i ra0 -c /home/wpa_supplicant.conf )
log "Status for wifi configuration=$? (0 is ok)" log "Status for wifi configuration=$? (0 is ok)"
log "Wifi configuration answer: $res"
log "Do network configuration 1/2 (ip and gateway)" log "Do network configuration 1/2 (ip and gateway)"
#ifconfig ra0 192.168.1.121 netmask 255.255.255.0 #ifconfig ra0 192.168.1.121 netmask 255.255.255.0
@@ -289,6 +297,12 @@ log "Done"
log "New datetime is $(date)" log "New datetime is $(date)"
### Check if reach gateway and notify
ping -c1 -W2 $(get_config GATEWAY) > /dev/null
if [ 0 -eq $? ]; then
/home/rmm "/home/hd1/voice/wifi_connected.g726" 1
fi
### set the root password ### set the root password
root_pwd=$(get_config ROOT_PASSWORD) root_pwd=$(get_config ROOT_PASSWORD)
[ $? -eq 0 ] && echo "root:$root_pwd" | chpasswd [ $? -eq 0 ] && echo "root:$root_pwd" | chpasswd
@@ -301,13 +315,6 @@ led -yoff -bon
### Rename the timeout sound file to avoid being spammed with chinese audio stuff... ### Rename the timeout sound file to avoid being spammed with chinese audio stuff...
[ -f /home/timeout.g726 ] && mv /home/timeout.g726 /home/timeout.g726.OFF [ -f /home/timeout.g726 ] && mv /home/timeout.g726 /home/timeout.g726.OFF
### Rmm stuff
# without this, most things does not work (http server, rtsp)
# It starts to use the cloud (which is no more launched) so you will find timeout in the logs
cd /home
./rmm &
sync sync
### Launch FTP server ### Launch FTP server
@@ -355,22 +362,6 @@ cd /home
./record_event & ./record_event &
./mp4record 60 & ./mp4record 60 &
### Launch script to check for motion the last minute
/home/hd1/test/check_motion.sh &
### Rtsp server
cd /home/hd1/test/
log "Start rtsp server : rtspsvr${RTSP_VERSION}..."
if [[ $(get_config DEBUG) == "yes" ]] ; then
./rtspsvr${RTSP_VERSION} > /${LOG_DIR}/log_rtsp.txt 2>&1 &
else
./rtspsvr${RTSP_VERSION} &
fi
sleep 1
log "Check for rtsp process : "
ps | grep rtspsvr | grep -v grep >> ${LOG_FILE}
sleep 5
### Some configuration ### Some configuration
@@ -395,14 +386,56 @@ himm 0x20030048 0x302
rm /home/hd1/FSCK* rm /home/hd1/FSCK*
# Check and create crontabs folder
crontab_folder="/var/spool/cron/crontabs"
if [ ! -r "$crontab_folder" ]; then
mkdir -p "$crontab_folder"
fi
# Start crond daemon
/usr/sbin/crond -b
### Final led color ### Final led color
led $(get_config LED_WHEN_READY) ### Check if reach gateway and notify
ping -c1 -W2 $(get_config GATEWAY) > /dev/null
if [ 0 -eq $? ]; then
led $(get_config LED_WHEN_READY)
/home/rmm "/home/hd1/voice/success.g726" 1
else
led -boff -yfast
fi
### Rmm stuff
# without this, most things does not work (http server, rtsp)
# It starts to use the cloud (which is no more launched) so you will find timeout in the logs
# This must be launched after all "/home/rmm" command calls
cd /home
./rmm &
### Rtsp server
cd /home/hd1/test/
log "Start rtsp server : rtspsvr${RTSP_VERSION}..."
if [[ $(get_config DEBUG) == "yes" ]] ; then
./rtspsvr${RTSP_VERSION} > /${LOG_DIR}/log_rtsp.txt 2>&1 &
else
./rtspsvr${RTSP_VERSION} &
fi
sleep 1
log "Check for rtsp process : "
ps | grep rtspsvr | grep -v grep >> ${LOG_FILE}
sleep 5
### List the processes after startup ### List the processes after startup
log "Processes after startup :" log "Processes after startup :"
ps >> ${LOG_FILE} ps >> ${LOG_FILE}
### List storage status
log "Storage status :"
df -h >> ${LOG_FILE}
### to make sure log are written... ### to make sure log are written...
sync sync
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.