mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-30 13:35:13 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
0d155c70be
commit
32600acc60
14258 files changed
+3954570
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
PUREMAC="${1:0:8}"
|
||||
LMAC=$(echo $PUREMAC | awk '{ print toupper($0) }')
|
||||
MAC=${LMAC//:/}
|
||||
|
||||
maclist=$(curl -s -k -L -X GET -H "Content-Type: application/json; charset=utf-8" \
|
||||
-H "Origin: https://regauth.standards.ieee.org" \
|
||||
-H "Referer: https://regauth.standards.ieee.org/standards-ra-web/pub/view.html" \
|
||||
"https://services13.ieee.org/RST/standards-ra-web/rest/assignments/?registry=MA-L&sortby=organization&sortorder=asc&text=${MAC}")
|
||||
|
||||
IDS=${MAC//-/}
|
||||
HEX=$(jsonfilter -s "$maclist" -e $.data.hits[*].assignmentNumberHex)
|
||||
|
||||
i=0
|
||||
for hexs in $HEX
|
||||
do
|
||||
if [ "$hexs" == "$IDS" ]; then
|
||||
name=$(jsonfilter -s "$maclist" -e $.data.hits[$i].organizationName)
|
||||
#echo "Identifier: $LMAC"
|
||||
echo "Organization: $name"
|
||||
exit
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
echo "Organization: Not Found!"
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
DEVICE="$1"
|
||||
NL="$2"
|
||||
|
||||
ping ${DEVICE} -w 1 -q &>/dev/null; [ $? == 0 ] && echo -en "Up" || echo -en "Down"
|
||||
if [ -z ${NL} ];then
|
||||
echo -en "\n"
|
||||
fi
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
INTERFACE="$1"
|
||||
|
||||
if [ -n "$INTERFACE" ]; then
|
||||
echo -en "\`\`\`$(ifconfig $INTERFACE)\`\`\`"
|
||||
else
|
||||
echo -en "Usage: */ifconfig {interface}*"
|
||||
fi
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
uname -a
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
echo -en "Current DHCP leases:\n\`\`\`\n "
|
||||
echo -en "Exp date | HWaddr | IP\n"
|
||||
file='/tmp/dhcp.leases'
|
||||
while IFS= read -r line <&3; do
|
||||
echo -en "$(date -d @$(printf '%s\n' "$line" | awk '{print $1}') +'%d.%m %H:%M') | "
|
||||
printf '%s' "$line" | awk '{print $2" | "$3}'
|
||||
done 3< $file
|
||||
echo -en "\`\`\`"
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
echo -en "\`\`\` \n"
|
||||
echo -en "$(cat /proc/meminfo | sed -n '1,5p')\`\`\`"
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
netstat -ntu | grep -v "127.0.0.1" | grep -v "::ffff:" |grep "ESTABLISHED\|CLOSED\|TIME_WAIT" | sed -e 's/_/\\_/g' | awk '{print "Protocolo: " $1 " \nOrigem: " $4 "\nDestino: " $5 "\nState: " $6 "\n" } '
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
#!/bin/sh
|
||||
|
||||
ACTION=$1
|
||||
PKG="$2 $3 $4 $5 $6"
|
||||
|
||||
update_(){
|
||||
opkg update > /dev/null 2>&1
|
||||
MSG="List updated."
|
||||
}
|
||||
|
||||
list_(){
|
||||
PKGS="$(opkg list-upgradable)"
|
||||
MSG="\`\`\`\n$PKGS\`\`\`"
|
||||
if [ "$PKGS" ]; then
|
||||
MSG="Packages to upgrade are:\n${MSG}"
|
||||
else
|
||||
MSG="Noting to upgrade"
|
||||
fi
|
||||
}
|
||||
|
||||
listpkg_(){
|
||||
PKGS="$(opkg ${ACTION} ${PKG})"
|
||||
if [ "$PKGS" ]; then
|
||||
MSG="\`\`\`\n$PKGS\`\`\`"
|
||||
else
|
||||
MSG="Package $2 not found."
|
||||
fi
|
||||
}
|
||||
|
||||
upgrade_(){
|
||||
PKGS="$(opkg list-upgradable | awk '{print $1}')"
|
||||
opkg upgrade $(echo ${PKGS}) > /dev/null 2>&1
|
||||
MSG="Upgraded package(s):\n\`\`\`\n${PKGS}\`\`\`"
|
||||
}
|
||||
|
||||
install_(){
|
||||
opkg ${ACTION} ${PKG} > /dev/null 2>&1
|
||||
MSG="Package(s): $PKG installed."
|
||||
}
|
||||
|
||||
remove_(){
|
||||
opkg ${ACTION} ${PKG} > /dev/null 2>&1
|
||||
MSG="Package(s): $PKG removed."
|
||||
}
|
||||
|
||||
installed_(){
|
||||
PKGS="$(opkg list-installed | awk '{print $1}')"
|
||||
#PKGS="Test TEst2 TEst3"
|
||||
MSG="Installed package(s):\n\`\`\`\n$(echo ${PKGS})\`\`\`"
|
||||
}
|
||||
|
||||
help_(){
|
||||
MSG="Usage: */opkg command [argument]*\n\
|
||||
Aviable opkg commands:\n\
|
||||
\t\tupdate - update packages list\n\
|
||||
\t\tlist pkgmane - show package\n\
|
||||
\t\tinstall pkgname - install packages (max 5 package names)\n\
|
||||
\t\tremove pkgname - remove packages (max 5 package names)\n\
|
||||
\t\tlist-installed [pkgname] - list installed packages [package]\n\
|
||||
\t\tlist-upgrade - list upgradabe packages\n\
|
||||
\t\trun-upgrade - run upgrade upgradable packages\n\
|
||||
\t\thelp - this help."
|
||||
}
|
||||
|
||||
case ${ACTION} in
|
||||
update)
|
||||
update_
|
||||
echo -en "$MSG"
|
||||
;;
|
||||
list)
|
||||
listpkg_
|
||||
echo -en "$MSG"
|
||||
;;
|
||||
list-upgrade)
|
||||
list_
|
||||
echo -en "$MSG"
|
||||
;;
|
||||
run-upgrade)
|
||||
upgrade_
|
||||
echo -en "$MSG"
|
||||
;;
|
||||
install)
|
||||
install_
|
||||
echo -en "$MSG"
|
||||
;;
|
||||
remove)
|
||||
remove_
|
||||
echo -en "$MSG"
|
||||
;;
|
||||
list-installed)
|
||||
installed_
|
||||
echo -en "$MSG"
|
||||
;;
|
||||
*)
|
||||
help_
|
||||
echo -en "$MSG"
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
DEVICE="$1"
|
||||
NL="$2"
|
||||
|
||||
ping ${DEVICE} -w 1 -q &>/dev/null; [ $? == 0 ] && echo -en "Up" || echo -en "Down"
|
||||
if [ -z ${NL} ];then
|
||||
echo -en "\n"
|
||||
fi
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
IFS=
|
||||
echo -ne "Aviable commands are:\n"
|
||||
|
||||
cd /usr/lib/telegrambot/plugins
|
||||
|
||||
for p in $(find . -type f -print -o -name . -o -prune |sed -e 's/.sh//g' -e 's/\.//g'); do
|
||||
echo -ne "*$p*\n"
|
||||
done
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# <https://github.com/alexwbaule/telegramopenwrt/blob/master/plugins/swports_list>
|
||||
|
||||
IFS=$'\n'
|
||||
PORTS=$(swconfig dev switch0 show | grep link | grep -oE "port:[[:digit:]][[:space:]]link:(up|down)([[:space:]]speed:[[:digit:]]+|$)")
|
||||
for port in $PORTS
|
||||
do
|
||||
id=$(echo $port | grep -oE "port:[[:digit:]]" | cut -d ':' -f 2)
|
||||
if [ "$id" == "0" ]
|
||||
then
|
||||
echo "CPU"
|
||||
elif [ "$id" == "1" ]
|
||||
then
|
||||
echo "WAN"
|
||||
elif [ "$id" == "2" ]
|
||||
then
|
||||
echo "LAN 1"
|
||||
elif [ "$id" == "3" ]
|
||||
then
|
||||
echo "LAN 2"
|
||||
elif [ "$id" == "4" ]
|
||||
then
|
||||
echo "LAN 3"
|
||||
elif [ "$id" == "5" ]
|
||||
then
|
||||
echo "LAN 4"
|
||||
elif [ "$id" == "6" ]
|
||||
then
|
||||
echo "EMPTY"
|
||||
fi
|
||||
echo -en "${port// /\n}\n\n"
|
||||
done
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
ACTION=$1
|
||||
VARIABLE=$2
|
||||
|
||||
case ${ACTION} in
|
||||
show) echo -en "\`\`\`$(uci show ${VARIABLE})\`\`\`" :;;
|
||||
get) echo -en " \`\`\`$(uci -q get ${VARIABLE})\`\`\`" :;;
|
||||
*) echo -en " Usage: */uci {show|get} [section]*" ;;
|
||||
esac
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
uptime
|
||||
@@ -0,0 +1,3 @@
|
||||
#ip r | awk '/default/{print "interface "$5": "$9}'
|
||||
IP=$(nslookup myip.opendns.com resolver1.opendns.com | awk '/^Address( 1)?: / { print $3 }')
|
||||
echo -en "[$IP](https://whois.ru/$IP)"
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# <https://github.com/alexwbaule/telegramopenwrt/blob/master/plugins/wifi_list>
|
||||
|
||||
old=$IFS
|
||||
IFS=$'\n'
|
||||
TOTAL=0
|
||||
|
||||
echo "*Wireless*"
|
||||
|
||||
for rule in $(uci show wireless | grep "default_radio" )
|
||||
do
|
||||
line=$(echo ${rule} | awk -F "." '{print $3}')
|
||||
id=$(echo ${rule} | grep ".ssid" | grep -oE "\[[[:digit:]]+\]" | awk '{gsub("\\[|]","");printf $1}')
|
||||
if [ "$id" != "" ]; then
|
||||
echo "rate: "$(iwinfo wlan${id} info | grep -oE "[[:digit:]]+\.[[:digit:]]+ MBit\/s")
|
||||
awk 'BEGIN{x='$(iwinfo wlan${id} info | grep -oE "[[:digit:]]+/[[:digit:]]+")' * 100; printf "quality: %.0f%%\n", x}'
|
||||
fi
|
||||
new=${line//\'/}
|
||||
new2=${new//_/\\_}
|
||||
new3=${new2//=/: }
|
||||
echo ${new3//\*/all}
|
||||
done
|
||||
IFS=$old
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# https://github.com/alexwbaule/telegramopenwrt/blob/master/plugins/wll_list
|
||||
for wifi in wlan0 wlan1
|
||||
do
|
||||
if [ "${wifi}" == "wlan0" ]; then
|
||||
echo -en "-----------------*${wifi} - 2.4 Ghz*-----------------------\n"
|
||||
else
|
||||
echo -en "-----------------*${wifi} - 5 Ghz*-------------------------\n"
|
||||
fi
|
||||
macaddr=$(iw dev ${wifi} station dump | grep Station | grep -oE "([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}" | awk '{printf $0 " "}')
|
||||
for lease in ${macaddr}
|
||||
do
|
||||
line=$(cat /tmp/dhcp.leases | grep ${lease})
|
||||
if [ $? == 0 ]; then
|
||||
echo "${line}" | awk '{gsub( "*","\\*" ); gsub( "_","\\_" ); printf "Device: " $4 "\nIP: " $3 "\nMac: " toupper($2) "\nState: ";system("./functions/get_ping.sh "$4" 1");printf "\n"}'
|
||||
else
|
||||
cat /proc/net/arp | grep ${lease} | awk '{gsub( "_","\\_" ); printf "IP: " $1 "\nMac: " toupper($4) "\nState: ";system("./functions/get_ping.sh "$1" 1");printf "\n"}'
|
||||
fi
|
||||
./functions/get_mac.sh "${lease}"
|
||||
echo -en "\n"
|
||||
done
|
||||
#echo -en "-----------------------------------------------------------\n"
|
||||
done
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
WOLIFACE=$1
|
||||
HWADDR=$2
|
||||
if [ -z $WOLIFACE ] && [ -z "$HWADDR" ]; then
|
||||
echo -en "Usage: */wol {interface} {hwadddress}*"
|
||||
else
|
||||
/usr/bin/etherwake -D -i "$WOLIFACE" "$HWADDR"
|
||||
fi
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
#!/bin/sh
|
||||
|
||||
PATH='/usr/bin:/usr/sbin:/bin:/sbin'
|
||||
|
||||
for v in bot_token chat_id server timeout polling_time enabled log_file plugins; do
|
||||
eval $v=$(uci -q get telegrambot.@telegram_bot[0].${v} 2>/dev/nul)
|
||||
done
|
||||
|
||||
if [ $enabled -eq 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$bot_token" ]; then
|
||||
echo "token is empty"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ -z "$chat_id" ]; then
|
||||
echo "chat_id is empty"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ -z "$server" ]; then
|
||||
server="https://api.telegram.org"
|
||||
fi
|
||||
|
||||
if [ -z "$timeout" ]; then
|
||||
timeout=30
|
||||
fi
|
||||
|
||||
if [ -z "$polling_time" ]; then
|
||||
polling_time=1
|
||||
fi
|
||||
|
||||
api="${server}/bot${bot_token}"
|
||||
|
||||
if [ ! -d "/tmp/telegrambot" ]; then
|
||||
mkdir /tmp/telegrambot
|
||||
fi
|
||||
if [ "x$plugins" = "x" ]; then
|
||||
plugins="/usr/lib/telegrambot/plugins"
|
||||
fi
|
||||
#telegram_log_file=/tmp/telegram-bot/telegram.log
|
||||
if [ "x$log_file" = "x" ]; then
|
||||
logfile=/dev/null
|
||||
else
|
||||
log_file=${log_file}
|
||||
fi
|
||||
|
||||
offset_file=/tmp/telegrambot/telegram_offset
|
||||
|
||||
command_not_found="Sorry,
|
||||
I only recognize *commands*.
|
||||
Commands are words beginning with a slash.
|
||||
Try it !
|
||||
Send [/start](/start) to get my commands list."
|
||||
|
||||
command_start="*/memory* return RAM info
|
||||
*/leases* current dhcp leases
|
||||
*/wll_list* wifi clients
|
||||
*/reboot* reboot the device
|
||||
*/wol <mac_address>* wake on lan over the Internet
|
||||
*/loc* get current location via modemmanager
|
||||
*/wanip* WAN ip address
|
||||
*/plugins* aviable commands"
|
||||
|
||||
curl -k -s -X POST $api/sendMessage \
|
||||
-d chat_id=$chat_id \
|
||||
-d parse_mode=Markdown \
|
||||
--data-urlencode text="$(uci -q get system.@system[0].hostname). TelegramBot started." &> $log_file
|
||||
|
||||
if [ -f "$offset_file" ] ; then
|
||||
offset=$( cat $offset_file )
|
||||
else
|
||||
offset=0
|
||||
echo $offset > $offset_file
|
||||
fi
|
||||
|
||||
reply_to_msg () {
|
||||
local msg_id=$1
|
||||
local origin=$2
|
||||
eval local text="$3"
|
||||
curl -k -s -X POST $api/sendMessage \
|
||||
-d reply_to_message_id=$msg_id \
|
||||
-d chat_id=$origin \
|
||||
-d parse_mode=Markdown \
|
||||
--data-urlencode text="$text" &> $log_file
|
||||
}
|
||||
|
||||
reply_to_location() {
|
||||
local msg_id=$1
|
||||
local origin=$2
|
||||
SLOT=$(mmcli -L | awk '{print $1}' | awk -F [\/] '{print $NF}')
|
||||
GPS="$(echo $(mmcli -m $SLOT --location-get -J | jsonfilter -e '@["modem"].*["gps"].*'))"
|
||||
LAT=$(echo $GPS | awk '{print $2}')
|
||||
LONG=$(echo $GPS | awk '{print $3}')
|
||||
case $LAT in
|
||||
*[0-9]*)
|
||||
curl -k -s -X POST $api/sendLocation \
|
||||
-d reply_to_message_id=$msg_id \
|
||||
-d chat_id=$origin \
|
||||
-d parse_mode=Markdown \
|
||||
-d latitude=$LAT \
|
||||
-d longitude=$LONG &>$log_file
|
||||
;;
|
||||
*)
|
||||
curl -k -s -X POST $api/sendMessage \
|
||||
-d reply_to_message_id=$msg_id \
|
||||
-d chat_id=$origin \
|
||||
-d parse_mode=Markdown \
|
||||
--data-urlencode text="Location not sended! Check your mmcli settings or GPS antenna." &>$log_file
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
while [ true ]
|
||||
do
|
||||
updates=$(curl -s -k -X GET ${api}/getUpdates?offset=${offset}&timeout=${timeout})
|
||||
status=$(jsonfilter -s "$updates" -e $.ok)
|
||||
if [ $status = 'true' ]; then
|
||||
update_ids=$(jsonfilter -s "$updates" -e $.result[*].update_id)
|
||||
for update_id in $update_ids
|
||||
do
|
||||
offset=$((update_id+1))
|
||||
echo $offset > $offset_file
|
||||
origin=$(jsonfilter -s "$updates" -e "$.result[@.update_id=$update_id].message.chat.id")
|
||||
msg_id=$(jsonfilter -s "$updates" -e "$.result[@.update_id=$update_id].message.message_id")
|
||||
command=$(jsonfilter -s "$updates" -e "$.result[@.update_id=$update_id].message.text")
|
||||
is_a_cmd=$(jsonfilter -s "$updates" -e "$.result[@.update_id=$update_id].message.entities[*].type")
|
||||
query_ans=$(jsonfilter -s "$updates" -e "$.result[@.update_id=$update_id].callback_query.id")
|
||||
origin_ans=$(jsonfilter -s "$updates" -e "$.result[@.update_id=$update_id].callback_query.message.chat.id")
|
||||
if [[ "$origin" != "$chat_id" && "$origin_ans" != "$chat_id" ]];then
|
||||
curl -k -s -X POST $api/sendMessage -d reply_to_message_id=$msg_id -d chat_id=$origin -d parse_mode=Markdown --data-urlencode \
|
||||
text="This is a Private bot. If you want to implement one for you, check this out https://github.com/ixiumu/openwrt-telegram-bot" &> $log_file
|
||||
curl -k -s -X POST $api/leaveChat -d chat_id=$origin &> $telegram_log_file
|
||||
else
|
||||
if [ $(echo "$is_a_cmd" | grep "bot_command") != "" ]; then
|
||||
|
||||
cmd=$(echo $command | awk '{print $1}')
|
||||
prms=$(echo $command | awk '{$1="";print $0}' | sed 's/^[ \t]*//g')
|
||||
parms=${prms//[\"\&\;\\\>\<\|]/}
|
||||
DATE=`date +%Y-%m-%d_%H:%M:%S`
|
||||
RETURN_TEXT=""
|
||||
if [ $send_hotname == 1 ]; then
|
||||
RETURN_TEXT="$hostname ${RETURN_TEXT}"
|
||||
fi
|
||||
|
||||
case "$cmd" in
|
||||
("/start"|"/help")
|
||||
reply_to_msg $msg_id $origin "\${command_start}"
|
||||
;;
|
||||
("/reboot")
|
||||
(echo "Call $cmd" | logger -t "telegram_bot" -p daemon.info)&
|
||||
RETURN_TEXT="Command executed!"
|
||||
UPTIME=$(awk '{printf "%0.0f\n", $1}' /proc/uptime)
|
||||
# fix bootloop commands. Add timeout 3 min
|
||||
[ "$UPTIME" -ge "180" ] && {
|
||||
reply_to_msg $msg_id $origin "\${RETURN_TEXT}" && touch /etc/banner && sleep 5 && reboot
|
||||
} || {
|
||||
RETURN_TEXT="Command not accepted! Uptime ${UPTIME} sec is smaller 180s"
|
||||
reply_to_msg $msg_id $origin "\${RETURN_TEXT}"
|
||||
;;
|
||||
("/wol")
|
||||
(echo "Call $cmd [$parms]" | logger -t "telegram_bot" -p daemon.info)&
|
||||
RETURN_TEXT="$(${plugins}/wol.sh ${parms})"
|
||||
reply_to_msg $msg_id $origin "\${RETURN_TEXT}"
|
||||
;;
|
||||
("/loc")
|
||||
reply_to_location $msg_id $origin
|
||||
;;
|
||||
(*)
|
||||
if [ -f "${plugins}/${cmd}.sh" ] ; then
|
||||
(echo "Call $cmd [$parms]" | logger -t "telegram_bot" -p daemon.info)&
|
||||
RETURN_TEXT=$(${plugins}/${cmd}.sh ${parms})
|
||||
else
|
||||
RETURN_TEXT="Command *${cmd}* not found!"
|
||||
fi
|
||||
|
||||
reply_to_msg $msg_id $origin "\${RETURN_TEXT}"
|
||||
;;
|
||||
esac
|
||||
|
||||
else
|
||||
reply_to_msg $msg_id $origin "\${command_not_found}"
|
||||
fi
|
||||
|
||||
fi
|
||||
done
|
||||
fi
|
||||
sleep $polling_time
|
||||
done&
|
||||
Reference in new issue
Block a user