refactor: final polishing
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -22,8 +22,11 @@ function moonraker_obico_systemd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function moonraker_obico_config() {
|
function moonraker_obico_config() {
|
||||||
local moonraker_cfg_dirs=($(get_config_folders))
|
local moonraker_cfg_dirs
|
||||||
if [[ -n "${moonraker_cfg_dirs}" ]]; then
|
|
||||||
|
read -r -a moonraker_cfg_dirs <<< "$(get_config_folders)"
|
||||||
|
|
||||||
|
if (( ${#moonraker_cfg_dirs[@]} > 0 )); then
|
||||||
echo "${moonraker_cfg_dirs[${1}]}/moonraker-obico.cfg"
|
echo "${moonraker_cfg_dirs[${1}]}/moonraker-obico.cfg"
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
@@ -55,22 +58,27 @@ function obico_server_url_prompt() {
|
|||||||
blank_line
|
blank_line
|
||||||
echo -e "| For self-hosted server, specify: |"
|
echo -e "| For self-hosted server, specify: |"
|
||||||
printf "|${cyan}%-55s${white}|\n" " http://server_ip:port"
|
printf "|${cyan}%-55s${white}|\n" " http://server_ip:port"
|
||||||
echo -e "| For instance, \`http://192.168.0.5:3334\`. |"
|
echo -e "| For instance, 'http://192.168.0.5:3334'. |"
|
||||||
bottom_border
|
bottom_border
|
||||||
}
|
}
|
||||||
|
|
||||||
function moonraker_obico_setup_dialog() {
|
function moonraker_obico_setup_dialog() {
|
||||||
status_msg "Initializing Moonraker-obico installation ..."
|
status_msg "Initializing Moonraker-obico installation ..."
|
||||||
|
|
||||||
local moonraker_count moonraker_names
|
|
||||||
|
local moonraker_count
|
||||||
|
local moonraker_names
|
||||||
|
|
||||||
moonraker_count=$(moonraker_systemd | wc -w)
|
moonraker_count=$(moonraker_systemd | wc -w)
|
||||||
|
|
||||||
if (( moonraker_count == 0 )); then
|
if (( moonraker_count == 0 )); then
|
||||||
### return early if moonraker is not installed
|
### return early if moonraker is not installed
|
||||||
local error="Moonraker not installed! Please install Moonraker first!"
|
local error="Moonraker not installed! Please install Moonraker first!"
|
||||||
log_error "Moonraker-obico setup started without Moonraker being installed. Aborting setup."
|
log_error "Moonraker-obico setup started without Moonraker being installed. Aborting setup."
|
||||||
print_error "${error}" && return
|
print_error "${error}" && return
|
||||||
elif (( moonraker_count > 1 )); then
|
elif (( moonraker_count > 1 )); then
|
||||||
moonraker_names=($(get_multi_instance_names)) # moonraker_names is valid only in case of multi-instance
|
# moonraker_names is valid only in case of multi-instance
|
||||||
|
read -r -a moonraker_names <<< "$(get_multi_instance_names)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local moonraker_obico_services
|
local moonraker_obico_services
|
||||||
@@ -169,7 +177,10 @@ function moonraker_obico_setup_dialog() {
|
|||||||
clone_moonraker_obico "${MOONRAKER_OBICO_REPO}"
|
clone_moonraker_obico "${MOONRAKER_OBICO_REPO}"
|
||||||
|
|
||||||
### step 6: call moonrake-obico/install.sh with the correct params
|
### step 6: call moonrake-obico/install.sh with the correct params
|
||||||
local port=7125 moonraker_cfg_dirs=($(get_config_folders))
|
local port=7125
|
||||||
|
local moonraker_cfg_dirs
|
||||||
|
|
||||||
|
read -r -a moonraker_cfg_dirs <<< "$(get_config_folders)"
|
||||||
|
|
||||||
if (( moonraker_count == 1 )); then
|
if (( moonraker_count == 1 )); then
|
||||||
"${MOONRAKER_OBICO_DIR}/install.sh" -C "${moonraker_cfg_dirs[0]}/moonraker.conf" -p "${port}" -H 127.0.0.1 -l "${KLIPPER_LOGS}" -s -L -S "${obico_server_url}"
|
"${MOONRAKER_OBICO_DIR}/install.sh" -C "${moonraker_cfg_dirs[0]}/moonraker.conf" -p "${port}" -H 127.0.0.1 -l "${KLIPPER_LOGS}" -s -L -S "${obico_server_url}"
|
||||||
@@ -191,7 +202,7 @@ function moonraker_obico_setup_dialog() {
|
|||||||
fi
|
fi
|
||||||
elif (( moonraker_count > 1 )); then
|
elif (( moonraker_count > 1 )); then
|
||||||
for (( i=0; i <= moonraker_count; i++ )); do
|
for (( i=0; i <= moonraker_count; i++ )); do
|
||||||
if moonraker_obico_needs_linking "$(moonraker_obico_config ${i})"; then
|
if moonraker_obico_needs_linking "$(moonraker_obico_config "${i}")"; then
|
||||||
not_linked_instances+=("${i}")
|
not_linked_instances+=("${i}")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -215,7 +226,7 @@ function moonraker_obico_setup_dialog() {
|
|||||||
blank_line
|
blank_line
|
||||||
echo -e "| If you don't want to link the printer now, you can |"
|
echo -e "| If you don't want to link the printer now, you can |"
|
||||||
echo -e "| restart the linking process later by: |"
|
echo -e "| restart the linking process later by: |"
|
||||||
echo -e "| 1. \`cd ~/kiauh && ./kiauh.sh\` to launch KIAUH. |"
|
echo -e "| 1. 'cd ~/kiauh && ./kiauh.sh' to launch KIAUH. |"
|
||||||
echo -e "| 2. Select ${green}[Install]${white} |"
|
echo -e "| 2. Select ${green}[Install]${white} |"
|
||||||
echo -e "| 3. Select ${green}[Link to Obico Server]${white} |"
|
echo -e "| 3. Select ${green}[Link to Obico Server]${white} |"
|
||||||
bottom_border
|
bottom_border
|
||||||
@@ -242,7 +253,7 @@ function moonraker_obico_setup_dialog() {
|
|||||||
for i in "${not_linked_instances[@]}"; do
|
for i in "${not_linked_instances[@]}"; do
|
||||||
local name="${moonraker_names[i]}"
|
local name="${moonraker_names[i]}"
|
||||||
status_msg "Link moonraker-obico-${name} to the Obico Server..."
|
status_msg "Link moonraker-obico-${name} to the Obico Server..."
|
||||||
"${MOONRAKER_OBICO_DIR}/scripts/link.sh" -q -n "${name}" -c "$(moonraker_obico_config ${i})"
|
"${MOONRAKER_OBICO_DIR}/scripts/link.sh" -q -n "${name}" -c "$(moonraker_obico_config "${i}")"
|
||||||
done
|
done
|
||||||
fi # (( moonraker_count == 1 ))
|
fi # (( moonraker_count == 1 ))
|
||||||
fi # (( ${#not_linked_instances[@]} > 0 ))
|
fi # (( ${#not_linked_instances[@]} > 0 ))
|
||||||
|
|||||||
Reference in New Issue
Block a user