reworked dskstatus and commented out inline kbd

This commit is contained in:
celso 2023-11-24 12:02:12 -03:00
parent 3691b2d2d9
commit 24c6cc906b
1 changed files with 33 additions and 35 deletions

68
bot.sh
View File

@ -24,58 +24,56 @@ exec 2>>"${bot_tmpdir}/error.log"
. ./bashbot-lib/bashbot-lib.sh . ./bashbot-lib/bashbot-lib.sh
. ./bashbot-lib/viewer.sh . ./bashbot-lib/viewer.sh
#
declare -a kbd_rows=( 2 ) #declare -a kbd_rows=( 2 )
declare -a kbd_text=( "remount", "fix disk" ) #declare -a kbd_text=( "remount" "fix disk" )
declare -a kbd_data=( "remount", "fixdisk" ) #declare -a kbd_data=( "remount" "fixdisk" )
inline_kbd=$(mkinline_kbd kbd_rows kbd_text kbd_data) #inline_kbd=$(mkinline_kbd kbd_rows kbd_text kbd_data)
unset kbd_rows #unset kbd_rows
unset kbd_text #unset kbd_text
unset kbd_data #unset kbd_data
dsk_status(){ dsk_status(){
local BUF="$(dmesg | grep unmounting | tail -n1)" local BUF="$(dmesg | grep unmounting | tail -n1)"
local TIMECODE="$(awk '{print $1}' <<< "${BUF}")" local TIMECODE="$(awk '{print $1}' <<< "${BUF}")"
for i in $(awk 'print $1' ./checked.txt); do grep "${TIMECODE}" /tmp/dskbot/checked.txt >/dev/null 2>&1 || {
[ ! "${i}" = "${TIMECODE}" ] && { printf "%s\n" "${TIMECODE}" >> /tmp/dskbot/checked.txt
printf "%s\n" "${TIMECODE}" >> /tmp/diskconnectbot/checked.txt local TIME="$(date +'%a %d/%m - %T')"
local TIME="$(date +'%a %d/%m - %T')" local DISK="$(grep -o "sd[a-d][0-9]" <<< "${BUF}")"
local DISK="$(grep -o "sd[a-d][0-9]" <<< "${BUF}")" [ ! -z "${DISK}" ] && {
[ ! -z "${DISK}" ] && { local MOUNTED="$(mount | grep "${DISK}")"
local MOUNTED="$(mount | grep "${DISK}")" [ -z "${MOUNTED}" ] && printf "%s is not mounted\n" "${DISK}" || {
[ -z "${MOUNTED}" ] && printf "%s is not mounted\n" "${DISK}" || { local STATUS="$(grep -o "r[ow]" <<< "${MOUNTED}")"
local STATUS="$(grep -o "r[ow]")" case "${STATUS}" in
case "${STATUS}" in "ro") printf "%s is mounted read-only\n" "${DISK}";;
"ro") printf "%s is mounted read-only\n" "${DISK}";; "rw") printf "%s is mounted read-write\n" "${DISK}";;
"rw") printf "%s is mounted read-write\n" "${DISK}";; *) printf "%s is mounted as neither read-write nor read-only" "${DISK}";;
*) printf "%s is mounted as neither read-write nor read-only" "${DISK}";; esac
esac
}
} }
} }
done }
} }
while [ "${1}" = "start" ]; do while [ "${1}" = "start" ]; do
PANIC="$(dsk_status)" PANIC="$(dsk_status)"
[ ! -z "${PANIC}" ] && { [ ! -z "${PANIC}" ] && {
for i in $(awk '{print $1}' ./allowed_ids.txt); do for i in $(awk '{print $1}' ./allowed_ids.txt); do
sendmsg "${i}" "${PANIC}" "${inline_kbd}" sendmsg "${i}" "${PANIC}" #"${inline_kbd}"
done done
} }
getupd >/dev/null || continue getupd >/dev/null || continue
declare -A curmsg declare -A curmsg
getmsg_content curmsg updates.txt getmsg_content curmsg updates.txt
view_content curmsg view_content curmsg
[ "curmsg[callback]" = "remount" ] && { # [ "$curmsg[callback]" = "remount" ] && {
for i in $(awk '{print $1}' ./allowed_ids.txt); do # for i in $(awk '{print $1}' ./allowed_ids.txt); do
editmsg "curmsg[chat_id]" "curmsg[msg_id]" "remounting." # editmsg "curmsg[chat_id]" "curmsg[msg_id]" "remounting."
editmsg "curmsg[chat_id]" "curmsg[msg_id]" "remounting.." # editmsg "curmsg[chat_id]" "curmsg[msg_id]" "remounting.."
editmsg "curmsg[chat_id]" "curmsg[msg_id]" "remounting..." # editmsg "curmsg[chat_id]" "curmsg[msg_id]" "remounting..."
declare -A curmsg # getmsg_content curmsg sentmsgs.txt
getmsg_content curmsg sentmsgs.txt # tput setaf 3; view_content curmsg; tput sgr0
tput setaf 3; view_content curmsg; tput sgr0 # done
done # }
}
unset curmsg PANIC unset curmsg PANIC
done done