refactor: some tweaks
Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
@@ -22,7 +22,7 @@ function install_fluidd(){
|
|||||||
print_error "${error}" && return
|
print_error "${error}" && return
|
||||||
fi
|
fi
|
||||||
### checking dependencies
|
### checking dependencies
|
||||||
local dep=(nginx)
|
local dep=(wget nginx)
|
||||||
dependency_check "${dep[@]}"
|
dependency_check "${dep[@]}"
|
||||||
### check if moonraker is already installed
|
### check if moonraker is already installed
|
||||||
system_check_webui
|
system_check_webui
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ function read_kiauh_ini(){
|
|||||||
log_error "Reading from .kiauh.ini failed! File not found!"
|
log_error "Reading from .kiauh.ini failed! File not found!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
log_info "${func}: reading from .kiauh.ini"
|
log_info "Reading from .kiauh.ini ... (${func})"
|
||||||
source "${INI_FILE}"
|
source "${INI_FILE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,11 +411,6 @@ function dependency_check(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function system_check_webui(){
|
function system_check_webui(){
|
||||||
### check system for an installed and enabled octoprint service
|
|
||||||
if sudo systemctl list-unit-files | grep -E "octoprint.*" | grep "enabled" &>/dev/null; then
|
|
||||||
OCTOPRINT_ENABLED="true"
|
|
||||||
fi
|
|
||||||
|
|
||||||
### check system for an installed haproxy service
|
### check system for an installed haproxy service
|
||||||
if [[ $(dpkg-query -f'${Status}' --show haproxy 2>/dev/null) = *\ installed ]]; then
|
if [[ $(dpkg-query -f'${Status}' --show haproxy 2>/dev/null) = *\ installed ]]; then
|
||||||
HAPROXY_FOUND="true"
|
HAPROXY_FOUND="true"
|
||||||
@@ -433,13 +428,12 @@ function system_check_webui(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fetch_webui_ports(){
|
function fetch_webui_ports(){
|
||||||
### read listen ports from possible installed interfaces
|
### read ports from possible installed interfaces and write them to ~/.kiauh.ini
|
||||||
### and write them to ~/.kiauh.ini
|
local interfaces=("mainsail" "fluidd" "octoprint")
|
||||||
WEBIFS=(mainsail fluidd octoprint)
|
for interface in "${interfaces[@]}"; do
|
||||||
for interface in "${WEBIFS[@]}"; do
|
|
||||||
if [ -f "/etc/nginx/sites-available/${interface}" ]; then
|
if [ -f "/etc/nginx/sites-available/${interface}" ]; then
|
||||||
port=$(grep -E "listen" "/etc/nginx/sites-available/${interface}" | head -1 | sed 's/^\s*//' | sed 's/;$//' | cut -d" " -f2)
|
port=$(grep -E "listen" "/etc/nginx/sites-available/${interface}" | head -1 | sed 's/^\s*//' | sed 's/;$//' | cut -d" " -f2)
|
||||||
if [ ! -n "$(grep -E "${interface}_port" "${INI_FILE}")" ]; then
|
if ! grep -Eq "${interface}_port" "${INI_FILE}"; then
|
||||||
sed -i '$a'"${interface}_port=${port}" "${INI_FILE}"
|
sed -i '$a'"${interface}_port=${port}" "${INI_FILE}"
|
||||||
else
|
else
|
||||||
sed -i "/^${interface}_port/d" "${INI_FILE}"
|
sed -i "/^${interface}_port/d" "${INI_FILE}"
|
||||||
@@ -481,10 +475,10 @@ function update_system(){
|
|||||||
function check_usergroups(){
|
function check_usergroups(){
|
||||||
local group_dialout group_tty
|
local group_dialout group_tty
|
||||||
if grep -q "dialout" </etc/group && ! grep -q "dialout" <(groups "${USER}"); then
|
if grep -q "dialout" </etc/group && ! grep -q "dialout" <(groups "${USER}"); then
|
||||||
group_dialout=false
|
group_dialout="false"
|
||||||
fi
|
fi
|
||||||
if grep -q "tty" </etc/group && ! grep -q "tty" <(groups "${USER}"); then
|
if grep -q "tty" </etc/group && ! grep -q "tty" <(groups "${USER}"); then
|
||||||
group_tty=false
|
group_tty="false"
|
||||||
fi
|
fi
|
||||||
if [ "${group_dialout}" == "false" ] || [ "${group_tty}" == "false" ] ; then
|
if [ "${group_dialout}" == "false" ] || [ "${group_tty}" == "false" ] ; then
|
||||||
top_border
|
top_border
|
||||||
|
|||||||
Reference in New Issue
Block a user