mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-13 02:24:27 +05:00
fix: made log upload function multi instance capable
This commit is contained in:
@@ -39,42 +39,54 @@ accept_upload_conditions(){
|
|||||||
upload_selection(){
|
upload_selection(){
|
||||||
source_kiauh_ini
|
source_kiauh_ini
|
||||||
[ "$logupload_accepted" = "false" ] && accept_upload_conditions
|
[ "$logupload_accepted" = "false" ] && accept_upload_conditions
|
||||||
KLIPPY_LOG=/tmp/klippy.log
|
|
||||||
MOONRAKER_LOG=/tmp/moonraker.log
|
### find all suitable logfiles for klipper
|
||||||
DWC2_LOG=/tmp/dwc2.log
|
logfiles=()
|
||||||
|
if ls /tmp/klippy*.log 2>/dev/null 1>&2; then
|
||||||
|
for kl_log in $(find /tmp/klippy*.log); do
|
||||||
|
logfiles+=($kl_log)
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if ls /tmp/moonraker*.log 2>/dev/null 1>&2; then
|
||||||
|
for mr_log in $(find /tmp/moonraker*.log); do
|
||||||
|
logfiles+=($mr_log)
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if ls /tmp/dwc2*.log 2>/dev/null 1>&2; then
|
||||||
|
for dwc_log in $(find /tmp/dwc2*.log); do
|
||||||
|
logfiles+=($dwc_log)
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
### draw interface
|
||||||
|
i=0
|
||||||
top_border
|
top_border
|
||||||
echo -e "| ${yellow}~~~~~~~~~~~~~~~ [ Log Upload ] ~~~~~~~~~~~~~~${default} |"
|
echo -e "| ${yellow}~~~~~~~~~~~~~~~ [ Log Upload ] ~~~~~~~~~~~~~~${default} |"
|
||||||
hr
|
hr
|
||||||
echo -e "| You can choose the following files for uploading: |"
|
echo -e "| You can choose the following files for uploading: |"
|
||||||
echo -e "| 1) klippy.log |"
|
for log in ${logfiles[@]}; do
|
||||||
echo -e "| 2) moonraker.log |"
|
printf "| $i) %-50s|\n" "${logfiles[$i]}"
|
||||||
echo -e "| 3) dwc2.log |"
|
i=$((i + 1))
|
||||||
|
done
|
||||||
quit_footer
|
quit_footer
|
||||||
while true; do
|
while true; do
|
||||||
read -p "${cyan}Please select:${default} " choice
|
read -p "${cyan}Please select:${default} " choice
|
||||||
case "$choice" in
|
if [ $choice = "q" ] || [ $choice = "Q" ]; then
|
||||||
1)
|
clear && main_menu && break
|
||||||
clear && print_header
|
elif [ $choice -le ${#logfiles[@]} ]; then
|
||||||
upload_log "$KLIPPY_LOG"
|
upload_log "${logfiles[$choice]}"
|
||||||
upload_selection
|
upload_selection
|
||||||
;;
|
else
|
||||||
2)
|
|
||||||
clear && print_header
|
clear && print_header
|
||||||
upload_log "$MOONRAKER_LOG"
|
ERROR_MSG="File not found!" && print_msg && clear_msg
|
||||||
upload_selection
|
upload_selection
|
||||||
;;
|
fi
|
||||||
3)
|
|
||||||
clear && print_header
|
|
||||||
upload_log "$DWC2_LOG"
|
|
||||||
upload_selection
|
|
||||||
;;
|
|
||||||
q | Q) clear; main_menu; break;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
upload_log(){
|
upload_log(){
|
||||||
if [ -f "$1" ]; then
|
if [ -f "$1" ]; then
|
||||||
|
clear && print_header
|
||||||
status_msg "Uploading $1 ..."
|
status_msg "Uploading $1 ..."
|
||||||
LINK=$(curl -s --upload-file $1 'http://paste.c-net.org/')
|
LINK=$(curl -s --upload-file $1 'http://paste.c-net.org/')
|
||||||
[ ! -z "$LINK" ] && ok_msg "$1 upload successfull!"
|
[ ! -z "$LINK" ] && ok_msg "$1 upload successfull!"
|
||||||
@@ -83,7 +95,7 @@ upload_log(){
|
|||||||
unset LINK
|
unset LINK
|
||||||
else
|
else
|
||||||
clear && print_header
|
clear && print_header
|
||||||
ERROR_MSG="$1 not found!" && print_msg && clear_msg
|
ERROR_MSG="File not found!" && print_msg && clear_msg
|
||||||
upload_selection
|
upload_selection
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user