mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
144 lines
5.1 KiB
Bash
Executable file
144 lines
5.1 KiB
Bash
Executable file
#!/bin/sh /etc/rc.common
|
|
START=88
|
|
|
|
PROG=/usr/bin/oled
|
|
|
|
stop() {
|
|
kill -2 $(pgrep /usr/bin/oled)
|
|
kill -9 $(pgrep -f /usr/sbin/netspeed)
|
|
echo "oled exit..."
|
|
}
|
|
|
|
start() {
|
|
enabled=$(uci get oled.@oled[0].enable)
|
|
if [ $enabled -eq 0 ]; then
|
|
exit 0
|
|
fi
|
|
|
|
autoswitch=$(uci get oled.@oled[0].autoswitch)
|
|
from=$(uci get oled.@oled[0].from)
|
|
to=$(uci get oled.@oled[0].to)
|
|
|
|
if [ ${autoswitch} -eq 1 ]; then
|
|
hour=$(date +"%H")
|
|
min=$(date +"%M")
|
|
ihour=`expr $hour + 0`
|
|
imin=`expr $min + 0`
|
|
now=$(($ihour*60+$imin))
|
|
if [[ $now -lt $from || $now -gt $to ]]; then
|
|
stop
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
#crontab daemon
|
|
if ! grep "/etc/init.d/oled \+restart" /etc/crontabs/root >/dev/null 2>&1; then
|
|
echo "*/5 * * * * /etc/init.d/oled restart >/dev/null 2>&1" >> /etc/crontabs/root
|
|
fi
|
|
|
|
date=$(uci get oled.@oled[0].date)
|
|
lanip=$(uci get oled.@oled[0].lanip)
|
|
cputemp=$(uci get oled.@oled[0].cputemp)
|
|
cpufreq=$(uci get oled.@oled[0].cpufreq)
|
|
netspeed=$(uci get oled.@oled[0].netspeed)
|
|
time=$(uci get oled.@oled[0].time)
|
|
drawline=$(uci get oled.@oled[0].drawline)
|
|
drawrect=$(uci get oled.@oled[0].drawrect)
|
|
fillrect=$(uci get oled.@oled[0].fillrect)
|
|
drawcircle=$(uci get oled.@oled[0].drawcircle)
|
|
drawroundrect=$(uci get oled.@oled[0].drawroundrect)
|
|
fillroundrect=$(uci get oled.@oled[0].fillroundrect)
|
|
drawtriangle=$(uci get oled.@oled[0].drawtriangle)
|
|
filltriangle=$(uci get oled.@oled[0].filltriangle)
|
|
displaybitmap=$(uci get oled.@oled[0].displaybitmap)
|
|
displayinvertnormal=$(uci get oled.@oled[0].displayinvertnormal)
|
|
drawbitmapeg=$(uci get oled.@oled[0].drawbitmapeg)
|
|
rotate=$(uci get oled.@oled[0].rotate)
|
|
scroll=$(uci get oled.@oled[0].scroll)
|
|
text=$(uci get oled.@oled[0].text)
|
|
netsource=$(uci get oled.@oled[0].netsource)
|
|
path=$(uci get oled.@oled[0].path)
|
|
|
|
if [ ${netspeed} -eq 1 ] && [ -z "$(pgrep -f netspeed)" ]; then
|
|
nohup /usr/sbin/netspeed ${netsource} >/dev/null 2>&1 &
|
|
else
|
|
[ -n "$(pgrep -f /usr/sbin/netspeed)" ] && kill -9 $(pgrep -f /usr/sbin/netspeed) 2>&1 >/dev/null
|
|
rm -f /tmp/netspeed
|
|
fi
|
|
#logger -t "oled" "${PROG} ${date} ${lanip} ${cputemp} ${cpufreq} ${netspeed} ${time} ${drawline} ${drawrect} ${fillrect} ${drawcircle} ${drawroundrect} ${fillroundrect} ${drawtriangle} ${filltriangle} ${displaybitmap} ${displayinvertnormal} ${drawbitmapeg} ${scroll} ${text} ${netsource} ${path} ${rotate} 1"
|
|
#nohup ${PROG} ${date} ${lanip} ${cputemp} ${cpufreq} ${netspeed} ${time} ${drawline} ${drawrect} ${fillrect} ${drawcircle} ${drawroundrect} ${fillroundrect} ${drawtriangle} ${filltriangle} ${displaybitmap} ${displayinvertnormal} ${drawbitmapeg} ${scroll} "${text}" "${netsource}" "${path}" ${rotate} 1 > /dev/null 2>&1 &
|
|
nohup ${PROG} eth0 /dev/i2c-0 > /dev/null 2>&1 &
|
|
}
|
|
|
|
restart() {
|
|
enabled=$(uci get oled.@oled[0].enable)
|
|
pgrep -f ${PROG} >/dev/null
|
|
if [ $? -eq 0 ]; then
|
|
if [ $enabled -eq 1 ]; then
|
|
autoswitch=$(uci get oled.@oled[0].autoswitch)
|
|
from=$(uci get oled.@oled[0].from)
|
|
to=$(uci get oled.@oled[0].to)
|
|
if [ ${autoswitch} -eq 1 ]; then
|
|
hour=$(date +"%H")
|
|
min=$(date +"%M")
|
|
ihour=`expr $hour + 0`
|
|
imin=`expr $min + 0`
|
|
now=$(($ihour*60+$imin))
|
|
if [[ $now -lt $from || $now -gt $to ]]; then
|
|
stop
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
date=$(uci get oled.@oled[0].date)
|
|
lanip=$(uci get oled.@oled[0].lanip)
|
|
cputemp=$(uci get oled.@oled[0].cputemp)
|
|
cpufreq=$(uci get oled.@oled[0].cpufreq)
|
|
netspeed=$(uci get oled.@oled[0].netspeed)
|
|
time=$(uci get oled.@oled[0].time)
|
|
drawline=$(uci get oled.@oled[0].drawline)
|
|
drawrect=$(uci get oled.@oled[0].drawrect)
|
|
fillrect=$(uci get oled.@oled[0].fillrect)
|
|
drawcircle=$(uci get oled.@oled[0].drawcircle)
|
|
drawroundrect=$(uci get oled.@oled[0].drawroundrect)
|
|
fillroundrect=$(uci get oled.@oled[0].fillroundrect)
|
|
drawtriangle=$(uci get oled.@oled[0].drawtriangle)
|
|
filltriangle=$(uci get oled.@oled[0].filltriangle)
|
|
displaybitmap=$(uci get oled.@oled[0].displaybitmap)
|
|
displayinvertnormal=$(uci get oled.@oled[0].displayinvertnormal)
|
|
drawbitmapeg=$(uci get oled.@oled[0].drawbitmapeg)
|
|
rotate=$(uci get oled.@oled[0].rotate)
|
|
scroll=$(uci get oled.@oled[0].scroll)
|
|
text=$(uci get oled.@oled[0].text)
|
|
netsource=$(uci get oled.@oled[0].netsource)
|
|
path=$(uci get oled.@oled[0].path)
|
|
vpsip=0
|
|
intfstatus=0
|
|
|
|
[ -n "$(pgrep /usr/bin/oled)" ] && kill -9 $(pgrep /usr/bin/oled) 2>&1 >/dev/null
|
|
[ -n "$(pgrep -f /usr/sbin/netspeed)" ] && kill -9 $(pgrep -f /usr/sbin/netspeed) 2>&1 >/dev/null
|
|
|
|
if [ ${netspeed} -eq 1 ]; then
|
|
nohup /usr/sbin/netspeed ${netsource} >/dev/null 2>&1 &
|
|
else
|
|
#kill -9 $(pgrep -f /usr/sbin/netspeed)
|
|
rm -f /tmp/netspeed
|
|
fi
|
|
#nohup ${PROG} ${date} ${lanip} ${cputemp} ${cpufreq} ${netspeed} ${time} ${drawline} ${drawrect} ${fillrect} ${drawcircle} ${drawroundrect} ${fillroundrect} ${drawtriangle} ${filltriangle} ${displaybitmap} ${displayinvertnormal} ${drawbitmapeg} ${scroll} "${text}" "${netsource}" "${path}" ${rotate} 0 > /dev/null 2>&1 &
|
|
#nohup ${PROG} 1 1 1 1 0 60 0 0 0 0 0 0 0 0 0 0 0 0 OPENWRT eth0 /dev/i2c-0 0 1 1 1 > /dev/null 2>&1 &
|
|
nohup ${PROG} eth0 /dev/i2c-0 > /dev/null 2>&1 &
|
|
else
|
|
stop
|
|
fi
|
|
else
|
|
if [ $enabled -eq 1 ]; then
|
|
start
|
|
else
|
|
exit 0
|
|
fi
|
|
fi
|
|
}
|
|
|
|
boot() {
|
|
start
|
|
}
|