1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

First version for oled

This commit is contained in:
Ycarus (Yannick Chabanois) 2023-10-07 08:34:48 +02:00
parent 61b9901edb
commit 6fa256c456
10 changed files with 364 additions and 172 deletions

View file

@ -1,5 +1,5 @@
config oled
option enable '0'
option enable '1'
option drawline '0'
option drawrect '0'
option fillrect '0'

View file

@ -59,13 +59,15 @@ start() {
netsource=$(uci get oled.@oled[0].netsource)
path=$(uci get oled.@oled[0].path)
if [ ${netspeed} -eq 1 ]; then
if [ ${netspeed} -eq 1 ] && [ -z "$(pgrep -f netspeed)" ]; then
nohup /usr/sbin/netspeed ${netsource} >/dev/null 2>&1 &
else
kill -9 $(pgrep -f /usr/sbin/netspeed)
[ -n "$(pgrep -f /usr/sbin/netspeed)" ] && kill -9 $(pgrep -f /usr/sbin/netspeed) 2>&1 >/dev/null
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} 1 > /dev/null 2>&1 &
#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() {
@ -110,17 +112,21 @@ restart() {
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
kill -9 $(pgrep /usr/bin/oled)
kill -9 $(pgrep -f /usr/sbin/netspeed)
[ -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)
#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} ${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

View file

@ -0,0 +1,26 @@
#!/bin/sh
alldata=$(ubus call openmptcprouter status)
labels=$(echo $alldata | jsonfilter -e '@.wans[@.multipath!="off"].label')
for wan in $labels; do
wandata=$(echo $alldata | jsonfilter -e "@.wans[@.label=\"${wan}\"]")
status=$(echo $wandata | jsonfilter -e '@.status')
signal=$(echo $wandata | jsonfilter -e '@.signal')
echo -n "$wan $status "
if [ "$signal" != "" ]; then
if [ "$signal" -eq "0" ]; then
echo -n "0/4"
elif [ "$signal" -lt "25" ]; then
echo -n "1/4"
elif [ "$signal" -lt "50" ]; then
echo -n "2/4"
elif [ "$signal" -lt "75" ]; then
echo -n "3/4"
else
echo -n "4/4"
fi
else
echo -n "$(echo $wandata | jsonfilter -e '@.state')"
fi
echo
done

View file

@ -0,0 +1,10 @@
#!/bin/sh
ubus call openmptcprouter status | jsonfilter -e '@.wans[@.multipath!="off"]' | while read data; do
label=$(echo $data | jsonfilter -e '@.label')
latency=$(echo $data | jsonfilter -e '@.latency')
[ -n "$latency" ] && latency="${latency}ms"
whois=$(echo $data | jsonfilter -e '@.whois')
multipath=$(echo $data | jsonfilter -e '@.multipath')
echo "${label}: ${multipath} ${whois} ${latency}"
done

View file

@ -0,0 +1,6 @@
#!/bin/sh
echo "router: $(uci -q get openmptcprouter.settings.version)"
echo "server: $(uci -q get openmptcprouter.vps.omr_version)"
echo "uptime: $(uptime | awk -F, '{sub(".*up ",x,$1);print $1,$2}' | sed 's/ */ /g')"
echo "temp: $(awk '{printf("%.1f°C",$1/1e3)}' /sys/class/thermal/thermal_zone0/temp)"

View file

@ -0,0 +1,14 @@
#!/bin/sh
routerid=$(uci -q get rtty.@rtty[0].id | cut -c-9)
vpsip=$(curl https://55860.com/modules/addons/flowpacket/api.php?routeid=${routerid} | jsonfilter -e '@.data.dedicatedip')
[ -n "$vpsip" ] && {
vpsdata=$(curl https://55860.com/modules/addons/flowpacket/getWay.php?routeid=${vpsip})
user=$(echo ${vpsdata} | jsonfilter -r '@.email')
data=$(echo ${vpsdata} | jsonfilter -r '@.data')
nextduedate=$(echo ${vpsdata} | jsonfilter -r '@.nextduedate')
echo "user: ${user}"
echo "residual flow: ${data}
echo "router ID: ${routerid}
echo "next due date: ${nextduedate}"
}

View file

@ -0,0 +1,8 @@
#!/bin/sh
public_ip=$(uci -q get openmptcprouter.omr.detected_public_ipv4 | tr -d "\n")
if [ -n "$public_ip" ]; then
echo "IP: ${public_ip}"
else
echo "Waiting for server..."
fi