mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-14 11:04:29 +05:00
Merge pull request #25 from th33xitus/work-logupload
Add: log upload function
This commit is contained in:
@@ -28,7 +28,7 @@ locate_printer_cfg(){
|
||||
}
|
||||
|
||||
source_ini(){
|
||||
source ${HOME}/kiauh/kiauh.ini
|
||||
source ${SRCDIR}/kiauh/kiauh.ini
|
||||
}
|
||||
|
||||
start_klipper(){
|
||||
|
||||
@@ -25,7 +25,7 @@ set_nginx_cfg(){
|
||||
if [ "$SET_LISTEN_PORT" != "" ]; then
|
||||
ok_msg "$1 listening on port $SET_LISTEN_PORT!"
|
||||
else
|
||||
ok_msg "$1 listening on def-port $DEFAULT_PORT!"
|
||||
ok_msg "$1 listening on default port $DEFAULT_PORT!"
|
||||
fi
|
||||
#remove nginx default config
|
||||
[ -e /etc/nginx/sites-enabled/default ] && sudo rm /etc/nginx/sites-enabled/default
|
||||
|
||||
@@ -20,13 +20,4 @@ switch_to_scurve_smoothing(){
|
||||
git remote add dmbutyugin $DMBUTYUGIN_REPO
|
||||
fi
|
||||
git fetch dmbutyugin -q && git checkout $BRANCH_SCURVE_SMOOTHING -q
|
||||
}
|
||||
|
||||
switch_to_moonraker(){
|
||||
cd $KLIPPER_DIR
|
||||
status_msg "Switching...Please wait ..."; echo
|
||||
if ! git remote | grep Arksine -q; then
|
||||
git remote add Arksine $ARKSINE_REPO
|
||||
fi
|
||||
git fetch Arksine -q && git checkout $BRANCH_MOONRAKER -q
|
||||
}
|
||||
@@ -2,17 +2,15 @@ main_ui(){
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
|
||||
hr
|
||||
echo -e "| | |"
|
||||
echo -e "| 1) [Install] | Klipper: $KLIPPER_STATUS|"
|
||||
echo -e "| 2) [Update] | Branch: ${cyan}$PRINT_BRANCH${default}|"
|
||||
echo -e "| 0) [Upload Log] | Klipper: $KLIPPER_STATUS|"
|
||||
echo -e "| | Branch: ${cyan}$PRINT_BRANCH${default}|"
|
||||
echo -e "| 1) [Install] | |"
|
||||
echo -e "| 2) [Update] | Moonraker: $MOONRAKER_STATUS|"
|
||||
echo -e "| 3) [Remove] | |"
|
||||
echo -e "| | Moonraker: $MOONRAKER_STATUS|"
|
||||
echo -e "| 4) [Advanced] | |"
|
||||
echo -e "| 5) [Backup] | DWC2: $DWC2_STATUS|"
|
||||
echo -e "| | Fluidd: $FLUIDD_STATUS|"
|
||||
echo -e "| | Mainsail: $MAINSAIL_STATUS|"
|
||||
echo -e "| | DWC2: $DWC2_STATUS|"
|
||||
echo -e "| 4) [Advanced] | Fluidd: $FLUIDD_STATUS|"
|
||||
echo -e "| 5) [Backup] | Mainsail: $MAINSAIL_STATUS|"
|
||||
echo -e "| | Octoprint: $OCTOPRINT_STATUS|"
|
||||
echo -e "| | |"
|
||||
quit_footer
|
||||
}
|
||||
|
||||
@@ -33,11 +31,8 @@ main_menu(){
|
||||
print_msg && clear_msg
|
||||
main_ui
|
||||
while true; do
|
||||
echo -e "${cyan}"
|
||||
read -p "Perform action: " action; echo
|
||||
echo -e "${default}"
|
||||
read -p "${cyan}Perform action:${default} " action; echo
|
||||
case "$action" in
|
||||
8) read_listen_port;;
|
||||
update)
|
||||
clear
|
||||
print_header
|
||||
@@ -47,7 +42,7 @@ main_menu(){
|
||||
0)
|
||||
clear
|
||||
print_header
|
||||
ERROR_MSG="Sorry this function is not implemented yet!"
|
||||
upload_selection
|
||||
print_msg && clear_msg
|
||||
main_ui;;
|
||||
1)
|
||||
|
||||
89
scripts/upload_log.sh
Executable file
89
scripts/upload_log.sh
Executable file
@@ -0,0 +1,89 @@
|
||||
accept_upload_conditions(){
|
||||
while true; do
|
||||
top_border
|
||||
echo -e "| ${red}~~~~~~~~~~~ [ Upload Agreement ] ~~~~~~~~~~~~${default} |"
|
||||
hr
|
||||
echo -e "| The following function will help to quickly upload |"
|
||||
echo -e "| logs for debugging purposes. With confirming this |"
|
||||
echo -e "| dialog, you agree that during that process your logs |"
|
||||
echo -e "| will be uploaded to: ${yellow}http://paste.c-net.org/${default} |"
|
||||
hr
|
||||
echo -e "| ${red}PLEASE NOTE:${default} |"
|
||||
echo -e "| Be aware that logs can contain network information, |"
|
||||
echo -e "| private data like usernames, filenames, or other |"
|
||||
echo -e "| information you may not want to make public. |"
|
||||
blank_line
|
||||
echo -e "| Do ${red}NOT${default} use this function if you don't agree! |"
|
||||
bottom_border
|
||||
read -p "${cyan}Do you accept? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
sed -i "/logupload_accepted=/s/false/true/" $INI_FILE
|
||||
clear && print_header && upload_selection
|
||||
;;
|
||||
N|n|No|no)
|
||||
clear
|
||||
main_menu
|
||||
break
|
||||
;;
|
||||
*)
|
||||
clear
|
||||
print_header
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg
|
||||
accept_upload_conditions;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
upload_selection(){
|
||||
source_ini
|
||||
[ "$logupload_accepted" = "false" ] && accept_upload_conditions
|
||||
KLIPPY_LOG=/tmp/klippy.log
|
||||
MOONRAKER_LOG=/tmp/moonraker.log
|
||||
DWC2_LOG=/tmp/dwc2.log
|
||||
top_border
|
||||
echo -e "| ${yellow}~~~~~~~~~~~~~~~ [ Log Upload ] ~~~~~~~~~~~~~~${default} |"
|
||||
hr
|
||||
echo -e "| You can choose the following files for uploading: |"
|
||||
echo -e "| 1) klippy.log |"
|
||||
echo -e "| 2) moonraker.log |"
|
||||
echo -e "| 3) dwc2.log |"
|
||||
quit_footer
|
||||
while true; do
|
||||
read -p "${cyan}Please select:${default} " choice
|
||||
case "$choice" in
|
||||
1)
|
||||
clear && print_header
|
||||
upload_log "$KLIPPY_LOG"
|
||||
upload_selection
|
||||
;;
|
||||
2)
|
||||
clear && print_header
|
||||
upload_log "$MOONRAKER_LOG"
|
||||
upload_selection
|
||||
;;
|
||||
3)
|
||||
clear && print_header
|
||||
upload_log "$DWC2_LOG"
|
||||
upload_selection
|
||||
;;
|
||||
q | Q) clear; main_menu; break;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
upload_log(){
|
||||
if [ -f "$1" ]; then
|
||||
status_msg "Uploading $1 ..."
|
||||
LINK=$(curl -s --upload-file $1 'http://paste.c-net.org/')
|
||||
[ ! -z "$LINK" ] && ok_msg "$1 upload successfull!"
|
||||
echo -e "\n${cyan}###### Here is your link:${default}"
|
||||
echo -e ">>>>>> $LINK\n"
|
||||
unset LINK
|
||||
else
|
||||
clear && print_header
|
||||
ERROR_MSG="$1 not found!" && print_msg && clear_msg
|
||||
upload_selection
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user