This commit is contained in:
Cyril 2024-03-11 13:32:54 +01:00
parent d1a341fde9
commit 46ddf91399
3 changed files with 149 additions and 32 deletions

View file

@ -10,18 +10,21 @@ function tools_menu_ui_ke() {
menu_option ' 1' 'Prevent updating' 'Klipper configuration files'
menu_option ' 2' 'Allow updating' 'Klipper configuration files'
hr
menu_option ' 3' 'Restart' 'Nginx service'
menu_option ' 4' 'Restart' 'Moonraker service'
menu_option ' 5' 'Restart' 'Klipper service'
menu_option ' 3' 'Enable' 'camera settings in Moonraker'
menu_option ' 4' 'Disable' 'camera settings in Moonraker'
hr
menu_option ' 6' 'Update' 'Entware packages'
menu_option ' 5' 'Restart' 'Nginx service'
menu_option ' 6' 'Restart' 'Moonraker service'
menu_option ' 7' 'Restart' 'Klipper service'
hr
menu_option ' 7' 'Clear' 'cache'
menu_option ' 8' 'Clear' 'logs files'
menu_option ' 8' 'Update' 'Entware packages'
hr
menu_option ' 9' 'Restore' 'a previous firmware'
menu_option ' 9' 'Clear' 'cache'
menu_option '10' 'Clear' 'logs files'
hr
menu_option '10' 'Reset' 'factory settings'
menu_option '11' 'Restore' 'a previous firmware'
hr
menu_option '12' 'Reset' 'factory settings'
hr
inner_line
hr
@ -52,36 +55,48 @@ function tools_menu_ke() {
run "allow_updating_klipper_files" "tools_menu_ui_ke"
fi;;
3)
if grep -q "^\[webcam Camera\]$" "$MOONRAKER_CFG"; then
error_msg "Camera settings are alredy enabled in Moonraker!"
else
run "enable_camera_settings" "tools_menu_ui_ke"
fi;;
4)
if grep -q "^#\[webcam Camera\]" "$MOONRAKER_CFG"; then
error_msg "Camera settings are alredy disabled in Moonraker!"
else
run "disable_camera_settings" "tools_menu_ui_ke"
fi;;
5)
if [ ! -d "$NGINX_FOLDER" ]; then
error_msg "Nginx is not installed!"
else
run "restart_nginx_action" "tools_menu_ui_ke"
fi;;
4)
6)
if [ ! -d "$MOONRAKER_FOLDER" ]; then
error_msg "Moonraker is not installed!"
else
run "restart_moonraker_action" "tools_menu_ui_ke"
fi;;
5)
7)
if [ ! -f "$INITD_FOLDER"/S55klipper_service ]; then
error_msg "Klipper service is not present!"
else
run "restart_klipper_action" "tools_menu_ui_ke"
fi;;
6)
8)
if [ ! -f "$ENTWARE_FILE" ]; then
error_msg "Entware is not installed!"
else
run "update_entware_packages" "tools_menu_ui_ke"
fi;;
7)
run "clear_cache" "tools_menu_ui_ke";;
8)
run "clear_logs" "tools_menu_ui_ke";;
9)
run "restore_previous_firmware" "tools_menu_ui_ke";;
run "clear_cache" "tools_menu_ui_ke";;
10)
run "clear_logs" "tools_menu_ui_ke";;
11)
run "restore_previous_firmware" "tools_menu_ui_ke";;
12)
run "reset_factory_settings" "tools_menu_ui_ke";;
B|b)
clear; main_menu; break;;

View file

@ -11,18 +11,21 @@ function tools_menu_ui() {
menu_option ' 2' 'Allow updating' 'Klipper configuration files'
menu_option ' 3' 'Fix' 'printing Gcode files from folder'
hr
menu_option ' 4' 'Restart' 'Nginx service'
menu_option ' 5' 'Restart' 'Moonraker service'
menu_option ' 6' 'Restart' 'Klipper service'
menu_option ' 4' 'Enable' 'camera settings in Moonraker'
menu_option ' 5' 'Disable' 'camera settings in Moonraker'
hr
menu_option ' 7' 'Update' 'Entware packages'
menu_option ' 6' 'Restart' 'Nginx service'
menu_option ' 7' 'Restart' 'Moonraker service'
menu_option ' 8' 'Restart' 'Klipper service'
hr
menu_option ' 8' 'Clear' 'cache'
menu_option ' 9' 'Clear' 'logs files'
menu_option ' 9' 'Update' 'Entware packages'
hr
menu_option '10' 'Restore' 'a previous firmware'
menu_option '10' 'Clear' 'cache'
menu_option '11' 'Clear' 'logs files'
hr
menu_option '11' 'Reset' 'factory settings'
menu_option '12' 'Restore' 'a previous firmware'
hr
menu_option '13' 'Reset' 'factory settings'
hr
inner_line
hr
@ -57,36 +60,48 @@ function tools_menu() {
run "printing_gcode_from_folder" "tools_menu_ui"
fi;;
4)
if grep -q "^\[webcam Camera\]$" "$MOONRAKER_CFG"; then
error_msg "Camera settings are alredy enabled in Moonraker!"
else
run "enable_camera_settings" "tools_menu_ui"
fi;;
5)
if grep -q "^#\[webcam Camera\]" "$MOONRAKER_CFG"; then
error_msg "Camera settings are alredy disabled in Moonraker!"
else
run "disable_camera_settings" "tools_menu_ui"
fi;;
6)
if [ ! -d "$NGINX_FOLDER" ]; then
error_msg "Nginx is not installed!"
else
run "restart_nginx_action" "tools_menu_ui"
fi;;
5)
7)
if [ ! -d "$MOONRAKER_FOLDER" ]; then
error_msg "Moonraker is not installed!"
else
run "restart_moonraker_action" "tools_menu_ui"
fi;;
6)
8)
if [ ! -f "$INITD_FOLDER"/S55klipper_service ]; then
error_msg "Klipper service is not present!"
else
run "restart_klipper_action" "tools_menu_ui"
fi;;
7)
9)
if [ ! -f "$ENTWARE_FILE" ]; then
error_msg "Entware is not installed!"
else
run "update_entware_packages" "tools_menu_ui"
fi;;
8)
run "clear_cache" "tools_menu_ui";;
9)
run "clear_logs" "tools_menu_ui";;
10)
run "restore_previous_firmware" "tools_menu_ui";;
run "clear_cache" "tools_menu_ui";;
11)
run "clear_logs" "tools_menu_ui";;
12)
run "restore_previous_firmware" "tools_menu_ui";;
13)
run "reset_factory_settings" "tools_menu_ui";;
B|b)
clear; main_menu; break;;

View file

@ -36,6 +36,28 @@ function printing_gcode_from_folder_message(){
bottom_line
}
function enable_camera_settings_message(){
top_line
title 'Enable camera settings in Moonraker' "${yellow}"
inner_line
hr
echo -e "${cyan}This allows to enable camera settings in Moonraker for ${white}"
echo -e "${cyan}Fluidd and Mainsail Web interfaces. ${white}"
hr
bottom_line
}
function disable_camera_settings_message(){
top_line
title 'Disable camera settings in Moonraker' "${yellow}"
inner_line
hr
echo -e "${cyan}This allows to disable camera settings in Moonraker for ${white}"
echo -e "${cyan}Fluidd and Mainsail Web interfaces. ${white}"
hr
bottom_line
}
function restore_previous_firmware_message(){
top_line
title 'Restore a previous firmware' "${yellow}"
@ -149,6 +171,71 @@ function printing_gcode_from_folder(){
done
}
function enable_camera_settings(){
enable_camera_settings_message
local yn
while true; do
read -p "${white} Do you want to enable ${green}camera settings in Moonraker ${white}? (${yellow}y${white}/${yellow}n${white}): ${yellow}" yn
case "${yn}" in
Y|y)
echo -e "${white}"
if grep -q "#\[webcam Camera\]" "$MOONRAKER_CFG" ; then
echo -e "Info: Enabling camera settings in moonraker.conf file..."
sed -i -e 's/^\s*#[[:space:]]*\[webcam Camera\]/[webcam Camera]/' -e '/^\[webcam Camera\]/,/^\s*$/ s/^\(\s*\)#/\1/' "$MOONRAKER_CFG"
else
echo -e "Info: Camera settings are already enabled in moonraker.conf file..."
fi
local ip_address=$(check_ipaddress)
if grep -q "stream_url: http://xxx.xxx.xxx.xxx:8080/?action=stream" "$MOONRAKER_CFG"; then
echo -e "Info: Replacing stream_url IP address..."
sed -i "s|http://xxx.xxx.xxx.xxx:|http://$ip_address:|g" "$MOONRAKER_CFG"
fi
if grep -q "snapshot_url: http://xxx.xxx.xxx.xxx:8080/?action=snapshot" "$MOONRAKER_CFG"; then
echo -e "Info: Replacing snapshot_url IP address..."
sed -i "s|http://xxx.xxx.xxx.xxx:|http://$ip_address:|g" "$MOONRAKER_CFG"
fi
echo -e "Info: Restarting Moonraker service..."
stop_moonraker
start_moonraker
ok_msg "Camera settings have been enabled in Moonraker successfully!"
return;;
N|n)
error_msg "Activation canceled!"
return;;
*)
error_msg "Please select a correct choice!";;
esac
done
}
function disable_camera_settings(){
disable_camera_settings_message
local yn
while true; do
read -p "${white} Do you want to disable ${green}camera settings in Moonraker ${white}? (${yellow}y${white}/${yellow}n${white}): ${yellow}" yn
case "${yn}" in
Y|y)
echo -e "${white}"
if grep -q "\[webcam Camera\]" "$MOONRAKER_CFG" ; then
echo -e "Info: Disabling camera settings in moonraker.conf file..."
sed -i '/^\[webcam Camera\]/,/^\s*$/ s/^\(\s*\)\([^#]\)/#\1\2/' "$MOONRAKER_CFG"
else
echo -e "Info: Camera settings are already disabled in moonraker.conf file..."
fi
echo -e "Info: Restarting Moonraker service..."
stop_moonraker
start_moonraker
ok_msg "Camera settings have been disabled in Moonraker successfully!"
return;;
N|n)
error_msg "Deactivation canceled!"
return;;
*)
error_msg "Please select a correct choice!";;
esac
done
}
function restart_nginx_action(){
echo
local yn