Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong voice path add feat ftp upload housekeeper #125

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions sd/test/crontabs_root
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# cat /var/spool/cron/crontabs/root
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
15 changes: 9 additions & 6 deletions sd/test/equip_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ LOG_FILE=${LOG_DIR}/log.txt

log_init() {
# clean the previous log file and add a starting line
echo "Starting to log..." > /home/hd1/test/log.txt
echo "[$(date +'%Y%m%d-%H%M%S')] Starting to log..." > /home/hd1/test/log.txt
}

log() {
Expand Down Expand Up @@ -114,8 +114,8 @@ cd /home/3518
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
/home/rmm "/home/hd1/test/voice/welcome.g726" 1
/home/rmm "/home/hd1/test/voice/wait.g726" 1

### start blinking blue led for configuration in progress
#/home/led_ctl -boff -yon &
Expand Down Expand Up @@ -261,7 +261,7 @@ log "Debug mode = $(get_config DEBUG)"
# first, configure wifi

### Let ppl hear that we start connect wifi
/home/rmm "/home/hd1/voice/connectting.g726" 1
/home/rmm "/home/hd1/test/voice/connectting.g726" 1

log "Check for wifi configuration file...*"
log $(find /home -name "wpa_supplicant.conf")
Expand Down Expand Up @@ -300,7 +300,7 @@ 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
/home/rmm "/home/hd1/test/voice/wifi_connected.g726" 1
fi

### set the root password
Expand Down Expand Up @@ -391,6 +391,9 @@ crontab_folder="/var/spool/cron/crontabs"
if [ ! -r "$crontab_folder" ]; then
mkdir -p "$crontab_folder"
fi
if [ ! -r "/var/spool/cron/crontabs/root" ]; then
cp /home/hd1/test/crontabs_root /var/spool/cron/crontabs/root
fi
# Start crond daemon
/usr/sbin/crond -b

Expand All @@ -400,7 +403,7 @@ fi
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
/home/rmm "/home/hd1/test/voice/success.g726" 1
else
led -boff -yfast
fi
Expand Down
167 changes: 167 additions & 0 deletions sd/test/scripts/ftp_upload/common_lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#!/bin/sh

DEFAULT_SCRIPT_DIR="/tmp/hd1/test/scripts"
DEFAULT_RECORD_DIR="/tmp/hd1/record/"
DEFAULT_CONFIG_FILE="/home/hd1/test/yi-hack.cfg"

max_d01=31
max_d02=28
max_d03=31
max_d04=30
max_d05=31
max_d06=30
max_d07=31
max_d08=31
max_d09=30
max_d10=31
max_d11=30
max_d12=31

led() {
# example usage :
# led -boff -yon
# options :
# -bfast
# -bon
# -boff
# -yfast
# -yon
# -yoff

# first, kill current led_ctl process
kill $(ps | grep led_ctl | grep -v grep | awk '{print $1}')
# then process
/home/led_ctl $@ &

}

get_config()
{
param=$1
conf_file=${2-"$DEFAULT_CONFIG_FILE"}
count=$(grep -e ^\s*${param}\s* ${conf_file} | wc -l)
if [ $count -gt 1 ]; then
log "ERROR: Found $count line for ${param}"
fi

grep -e ^\s*${param}\s* $conf_file | cut -d"=" -f2
}

is_server_live()
{
ping -c1 -W2 $1 > /dev/null
return $?
}

is_pid_exist()
{
count=$(ps | grep $1 | wc -l)
if [ $count -gt 1 ]; then
return 0
fi
return 1
}

pid_store()
{
if [ ! -r "$2" ]; then
log "[$(basename "$0")] PID file $2 not existed"
fi
echo $1 > $2
}

pid_get()
{
if [ ! -r "$1" ]; then
log "[$(basename "$0")] PID file $1 not existed"
fi
cat $1
}

pid_clear()
{
if [ ! -r "$1" ]; then
log "[$(basename "$0")] PID file $1 not existed"
fi
cat /dev/null > $1
}

log()
{
echo $3 "$(date +'%Y-%m-%dT%H:%M:%S%z') $1" >> $2
}

unreach_get()
{
if [ ! -r "$1" ]; then
log "[$(basename "$0")] Unreach file $1 not existed"
fi
urcount=$(cat $1)
if [ -z "$urcount" ]; then
urcount=0
fi
echo $urcount
}

unreach_increase()
{
urfile=$1
if [ ! -r "$urfile" ]; then
log "[$(basename "$0")] Unreach file $urfile not existed"
fi
urcount=$(unreach_get $urfile)
urcount=$((urcount + 1))
echo $urcount > $urfile
}

unreach_reset()
{
if [ ! -r "$1" ]; then
log "[$(basename "$0")] Unreach file $1 not existed"
fi
echo 0 > $1
}


is_leap_year()
{
year=$1
if [ $((year % 400)) -eq 0 ]; then
return 0
elif [ $((year % 4)) -eq 0 ] && [ $((year % 100)) -ne 0 ]; then
return 0
else
return 1
fi
}


check_offline_duration()
{
# Check if execution time within Gateway Off duration
gw_off_start=$(get_config GW_OFF_START)
gw_off_end=$(get_config GW_OFF_END)
if [ ! -z "$gw_off_start" ] && [ ! -z "$gw_off_end" ]; then
log "[$NAME] Check gateway offline duration" ${FTP_LOG}
gw_off_start=$(echo $gw_off_start | sed 's/://g')
gw_off_end=$(echo $gw_off_end | sed 's/://g')
current_time=$(date +%H%M%S)
if [ $gw_off_start -gt $gw_off_end ]; then
if [ $gw_off_start -lt 1200 ]; then
gw_off_start=$((gw_off_start + 2400))
fi
if [ $gw_off_end -lt 1200 ]; then
gw_off_end=$((gw_off_end + 2400))
fi
if [ $current_time -lt 1200 ]; then
current_time=$((current_time + 2400))
fi
fi
if [ $current_time -gt $gw_off_start ] && [ $current_time -lt $gw_off_end ]; then
log "[$NAME] Excution at $gw_off_start < $current_time < $gw_off_end. Do nothing" ${FTP_LOG}
return 1
fi
fi
return 0
}

1 change: 1 addition & 0 deletions sd/test/scripts/ftp_upload/ftp.pid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions sd/test/scripts/ftp_upload/ftp_upload.mem
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2016Y12M15D13H/53M00S.mp4
Loading