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