mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-16 20:14:32 +05:00
shellcheck: apply fixes for SC2086
This commit is contained in:
@@ -39,7 +39,7 @@ dwc_setup_dialog(){
|
|||||||
while true; do
|
while true; do
|
||||||
echo
|
echo
|
||||||
top_border
|
top_border
|
||||||
if [ $INSTANCE_COUNT -gt 1 ]; then
|
if [ "$INSTANCE_COUNT" -gt 1 ]; then
|
||||||
printf "|%-55s|\n" " $INSTANCE_COUNT Klipper instances were found!"
|
printf "|%-55s|\n" " $INSTANCE_COUNT Klipper instances were found!"
|
||||||
else
|
else
|
||||||
echo -e "| 1 Klipper instance was found! | "
|
echo -e "| 1 Klipper instance was found! | "
|
||||||
@@ -118,7 +118,7 @@ dwc_setup(){
|
|||||||
|
|
||||||
### step 1: get dwc2-for-klipper
|
### step 1: get dwc2-for-klipper
|
||||||
status_msg "Downloading DWC2-for-Klipper-Socket ..."
|
status_msg "Downloading DWC2-for-Klipper-Socket ..."
|
||||||
cd ${HOME} && git clone $DWC2FK_REPO
|
cd "${HOME}" && git clone "$DWC2FK_REPO"
|
||||||
ok_msg "Download complete!"
|
ok_msg "Download complete!"
|
||||||
|
|
||||||
### step 2: install dwc2 dependencies and create python virtualenv
|
### step 2: install dwc2 dependencies and create python virtualenv
|
||||||
@@ -127,7 +127,7 @@ dwc_setup(){
|
|||||||
create_dwc_virtualenv
|
create_dwc_virtualenv
|
||||||
|
|
||||||
### step 3: create dwc2.cfg folder and dwc2.cfg
|
### step 3: create dwc2.cfg folder and dwc2.cfg
|
||||||
[ ! -d $DWC_CONF_LOC ] && mkdir -p $DWC_CONF_LOC
|
[ ! -d "$DWC_CONF_LOC" ] && mkdir -p "$DWC_CONF_LOC"
|
||||||
dwc_cfg_creation
|
dwc_cfg_creation
|
||||||
|
|
||||||
### step 4: download Duet Web Control
|
### step 4: download Duet Web Control
|
||||||
@@ -135,7 +135,7 @@ dwc_setup(){
|
|||||||
|
|
||||||
### step 5: create dwc instances
|
### step 5: create dwc instances
|
||||||
INSTANCE=1
|
INSTANCE=1
|
||||||
if [ $INSTANCE_COUNT -eq $INSTANCE ]; then
|
if [ "$INSTANCE_COUNT" -eq $INSTANCE ]; then
|
||||||
create_single_dwc_instance
|
create_single_dwc_instance
|
||||||
else
|
else
|
||||||
#create_multi_dwc_instance
|
#create_multi_dwc_instance
|
||||||
@@ -147,18 +147,18 @@ download_dwc_webui(){
|
|||||||
#get Duet Web Control
|
#get Duet Web Control
|
||||||
GET_DWC2_URL=$(curl -s https://api.github.com/repositories/28820678/releases/latest | grep browser_download_url | cut -d'"' -f4)
|
GET_DWC2_URL=$(curl -s https://api.github.com/repositories/28820678/releases/latest | grep browser_download_url | cut -d'"' -f4)
|
||||||
status_msg "Downloading DWC2 Web UI ..."
|
status_msg "Downloading DWC2 Web UI ..."
|
||||||
[ ! -d $DWC2_DIR ] && mkdir -p $DWC2_DIR
|
[ ! -d "$DWC2_DIR" ] && mkdir -p "$DWC2_DIR"
|
||||||
cd $DWC2_DIR && wget $GET_DWC2_URL
|
cd "$DWC2_DIR" && wget "$GET_DWC2_URL"
|
||||||
ok_msg "Download complete!"
|
ok_msg "Download complete!"
|
||||||
status_msg "Extracting archive ..."
|
status_msg "Extracting archive ..."
|
||||||
unzip -q -o *.zip
|
unzip -q -o *.zip
|
||||||
for f_ in $(find . | grep '.gz')
|
for f_ in $(find . | grep '.gz')
|
||||||
do
|
do
|
||||||
gunzip -f ${f_}
|
gunzip -f "${f_}"
|
||||||
done
|
done
|
||||||
ok_msg "Done!"
|
ok_msg "Done!"
|
||||||
status_msg "Writing DWC version to file ..."
|
status_msg "Writing DWC version to file ..."
|
||||||
echo $GET_DWC2_URL | cut -d/ -f8 > $DWC2_DIR/.version
|
echo "$GET_DWC2_URL" | cut -d/ -f8 > "$DWC2_DIR/.version"
|
||||||
ok_msg "Done!"
|
ok_msg "Done!"
|
||||||
status_msg "Remove downloaded archive ..."
|
status_msg "Remove downloaded archive ..."
|
||||||
rm -rf *.zip && ok_msg "Done!" && ok_msg "Duet Web Control installed!"
|
rm -rf *.zip && ok_msg "Done!" && ok_msg "Duet Web Control installed!"
|
||||||
@@ -178,7 +178,7 @@ install_dwc_packages()
|
|||||||
|
|
||||||
# Install desired packages
|
# Install desired packages
|
||||||
status_msg "Installing packages..."
|
status_msg "Installing packages..."
|
||||||
sudo apt-get install --yes ${PKGLIST}
|
sudo apt-get install --yes "${PKGLIST}"
|
||||||
}
|
}
|
||||||
|
|
||||||
create_dwc_virtualenv()
|
create_dwc_virtualenv()
|
||||||
@@ -186,10 +186,10 @@ create_dwc_virtualenv()
|
|||||||
status_msg "Installing python virtual environment..."
|
status_msg "Installing python virtual environment..."
|
||||||
|
|
||||||
# Create virtualenv if it doesn't already exist
|
# Create virtualenv if it doesn't already exist
|
||||||
[ ! -d ${DWC_ENV} ] && virtualenv -p /usr/bin/python3 ${DWC_ENV}
|
[ ! -d "${DWC_ENV}" ] && virtualenv -p /usr/bin/python3 "${DWC_ENV}"
|
||||||
|
|
||||||
# Install/update dependencies
|
# Install/update dependencies
|
||||||
${DWC_ENV}/bin/pip install tornado==6.0.4
|
"${DWC_ENV}"/bin/pip install tornado==6.0.4
|
||||||
}
|
}
|
||||||
|
|
||||||
create_single_dwc_startscript(){
|
create_single_dwc_startscript(){
|
||||||
@@ -303,7 +303,7 @@ create_single_dwc_instance(){
|
|||||||
|
|
||||||
create_multi_dwc_instance(){
|
create_multi_dwc_instance(){
|
||||||
status_msg "Setting up $INSTANCE_COUNT instances of Duet Web Control ..."
|
status_msg "Setting up $INSTANCE_COUNT instances of Duet Web Control ..."
|
||||||
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
|
while [ $INSTANCE -le "$INSTANCE_COUNT" ]; do
|
||||||
### multi instance variables
|
### multi instance variables
|
||||||
DWC_LOG=/tmp/dwc-$INSTANCE.log
|
DWC_LOG=/tmp/dwc-$INSTANCE.log
|
||||||
DWC_CFG="$DWC_CONF_LOC/printer_$INSTANCE/dwc2.cfg"
|
DWC_CFG="$DWC_CONF_LOC/printer_$INSTANCE/dwc2.cfg"
|
||||||
@@ -348,7 +348,7 @@ dwc_cfg_creation(){
|
|||||||
dwc_ip_list=()
|
dwc_ip_list=()
|
||||||
|
|
||||||
### create single instance dwc2.cfg file
|
### create single instance dwc2.cfg file
|
||||||
if [ $INSTANCE_COUNT -eq $INSTANCE ]; then
|
if [ "$INSTANCE_COUNT" -eq $INSTANCE ]; then
|
||||||
### set port
|
### set port
|
||||||
PORT=$DEFAULT_PORT
|
PORT=$DEFAULT_PORT
|
||||||
|
|
||||||
@@ -356,8 +356,8 @@ dwc_cfg_creation(){
|
|||||||
dwc_ip_list+=("$HOSTNAME:$PORT")
|
dwc_ip_list+=("$HOSTNAME:$PORT")
|
||||||
|
|
||||||
status_msg "Creating dwc2.cfg in $DWC_CONF_LOC"
|
status_msg "Creating dwc2.cfg in $DWC_CONF_LOC"
|
||||||
[ ! -d $DWC_CONF_LOC ] && mkdir -p $DWC_CONF_LOC
|
[ ! -d "$DWC_CONF_LOC" ] && mkdir -p "$DWC_CONF_LOC"
|
||||||
if [ ! -f $DWC_CONF_LOC/dwc2.cfg ]; then
|
if [ ! -f "$DWC_CONF_LOC/dwc2.cfg" ]; then
|
||||||
create_single_dwcfk_cfg && ok_msg "dwc2.cfg created!"
|
create_single_dwcfk_cfg && ok_msg "dwc2.cfg created!"
|
||||||
else
|
else
|
||||||
warn_msg "There is already a file called 'dwc2.cfg'!"
|
warn_msg "There is already a file called 'dwc2.cfg'!"
|
||||||
@@ -366,7 +366,7 @@ dwc_cfg_creation(){
|
|||||||
|
|
||||||
### create multi instance moonraker.conf files
|
### create multi instance moonraker.conf files
|
||||||
else
|
else
|
||||||
while [ $INSTANCE -le $INSTANCE_COUNT ]; do
|
while [ $INSTANCE -le "$INSTANCE_COUNT" ]; do
|
||||||
### set each instance to its own port
|
### set each instance to its own port
|
||||||
PORT=$(expr $DEFAULT_PORT + $INSTANCE - 1)
|
PORT=$(expr $DEFAULT_PORT + $INSTANCE - 1)
|
||||||
|
|
||||||
@@ -375,8 +375,8 @@ dwc_cfg_creation(){
|
|||||||
|
|
||||||
### start the creation of each instance
|
### start the creation of each instance
|
||||||
status_msg "Creating dwc2.cfg for instance #$INSTANCE"
|
status_msg "Creating dwc2.cfg for instance #$INSTANCE"
|
||||||
[ ! -d $DWC_CONF_LOC/printer_$INSTANCE ] && mkdir -p $DWC_CONF_LOC/printer_$INSTANCE
|
[ ! -d "$DWC_CONF_LOC/printer_$INSTANCE" ] && mkdir -p "$DWC_CONF_LOC/printer_$INSTANCE"
|
||||||
if [ ! -f $DWC_CONF_LOC/printer_$INSTANCE/dwc2.cfg ]; then
|
if [ ! -f "$DWC_CONF_LOC/printer_$INSTANCE/dwc2.cfg" ]; then
|
||||||
create_multi_dwcfk_cfg && ok_msg "dwc2.cfg created!"
|
create_multi_dwcfk_cfg && ok_msg "dwc2.cfg created!"
|
||||||
else
|
else
|
||||||
warn_msg "There is already a file called 'dwc2.cfg'!"
|
warn_msg "There is already a file called 'dwc2.cfg'!"
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ install_webui(){
|
|||||||
### process possible disruptive services
|
### process possible disruptive services
|
||||||
process_disruptive_services
|
process_disruptive_services
|
||||||
|
|
||||||
[ $1 == "mainsail" ] && IF_NAME1="Mainsail" && IF_NAME2="Mainsail "
|
[ "$1" == "mainsail" ] && IF_NAME1="Mainsail" && IF_NAME2="Mainsail "
|
||||||
[ $1 == "fluidd" ] && IF_NAME1="Fluidd" && IF_NAME2="Fluidd "
|
[ "$1" == "fluidd" ] && IF_NAME1="Fluidd" && IF_NAME2="Fluidd "
|
||||||
|
|
||||||
### exit mainsail/fluidd setup if moonraker not found
|
### exit mainsail/fluidd setup if moonraker not found
|
||||||
if [ $moonraker_chk_ok = "false" ]; then
|
if [ $moonraker_chk_ok = "false" ]; then
|
||||||
@@ -127,7 +127,7 @@ install_webui(){
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
### ask user to install the recommended webinterface macros
|
### ask user to install the recommended webinterface macros
|
||||||
if ! ls $klipper_cfg_loc/kiauh_macros.cfg 2>/dev/null 1>&2 || ! ls $klipper_cfg_loc/printer_*/kiauh_macros.cfg 2>/dev/null 1>&2; then
|
if ! ls "$klipper_cfg_loc"/kiauh_macros.cfg 2>/dev/null 1>&2 || ! ls "$klipper_cfg_loc"/printer_*/kiauh_macros.cfg 2>/dev/null 1>&2; then
|
||||||
get_user_selection_kiauh_macros "$IF_NAME2"
|
get_user_selection_kiauh_macros "$IF_NAME2"
|
||||||
fi
|
fi
|
||||||
### create /etc/nginx/conf.d/upstreams.conf
|
### create /etc/nginx/conf.d/upstreams.conf
|
||||||
@@ -161,12 +161,12 @@ symlink_webui_nginx_log(){
|
|||||||
[ ! -d "$LPATH" ] && mkdir -p "$LPATH"
|
[ ! -d "$LPATH" ] && mkdir -p "$LPATH"
|
||||||
if [ -f "$UI_ACCESS_LOG" ] && [ ! -L "$LPATH/$1-access.log" ]; then
|
if [ -f "$UI_ACCESS_LOG" ] && [ ! -L "$LPATH/$1-access.log" ]; then
|
||||||
status_msg "Creating symlink for $UI_ACCESS_LOG ..."
|
status_msg "Creating symlink for $UI_ACCESS_LOG ..."
|
||||||
ln -s $UI_ACCESS_LOG "$LPATH"
|
ln -s "$UI_ACCESS_LOG" "$LPATH"
|
||||||
ok_msg "OK!"
|
ok_msg "OK!"
|
||||||
fi
|
fi
|
||||||
if [ -f "$UI_ERROR_LOG" ] && [ ! -L "$LPATH/$1-error.log" ]; then
|
if [ -f "$UI_ERROR_LOG" ] && [ ! -L "$LPATH/$1-error.log" ]; then
|
||||||
status_msg "Creating symlink for $UI_ERROR_LOG ..."
|
status_msg "Creating symlink for $UI_ERROR_LOG ..."
|
||||||
ln -s $UI_ERROR_LOG "$LPATH"
|
ln -s "$UI_ERROR_LOG" "$LPATH"
|
||||||
ok_msg "OK!"
|
ok_msg "OK!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -178,25 +178,25 @@ install_kiauh_macros(){
|
|||||||
### create a backup of the config folder
|
### create a backup of the config folder
|
||||||
backup_klipper_config_dir
|
backup_klipper_config_dir
|
||||||
### handle multi printer.cfg
|
### handle multi printer.cfg
|
||||||
if ls $klipper_cfg_loc/printer_* 2>/dev/null 1>&2; then
|
if ls "$klipper_cfg_loc"/printer_* 2>/dev/null 1>&2; then
|
||||||
for config in $(find $klipper_cfg_loc/printer_*/printer.cfg); do
|
for config in $(find $klipper_cfg_loc/printer_*/printer.cfg); do
|
||||||
path=$(echo $config | rev | cut -d"/" -f2- | rev)
|
path=$(echo "$config" | rev | cut -d"/" -f2- | rev)
|
||||||
if [ ! -f $path/kiauh_macros.cfg ]; then
|
if [ ! -f "$path/kiauh_macros.cfg" ]; then
|
||||||
### copy kiauh_macros.cfg to config location
|
### copy kiauh_macros.cfg to config location
|
||||||
status_msg "Creating macro config file ..."
|
status_msg "Creating macro config file ..."
|
||||||
cp ${SRCDIR}/kiauh/resources/kiauh_macros.cfg $path
|
cp "${SRCDIR}/kiauh/resources/kiauh_macros.cfg" "$path"
|
||||||
### write the include to the very first line of the printer.cfg
|
### write the include to the very first line of the printer.cfg
|
||||||
sed -i "1 i [include kiauh_macros.cfg]" $path/printer.cfg
|
sed -i "1 i [include kiauh_macros.cfg]" "$path/printer.cfg"
|
||||||
ok_msg "$path/kiauh_macros.cfg created!"
|
ok_msg "$path/kiauh_macros.cfg created!"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
### handle single printer.cfg
|
### handle single printer.cfg
|
||||||
elif [ -f $klipper_cfg_loc/printer.cfg ] && [ ! -f $klipper_cfg_loc/kiauh_macros.cfg ]; then
|
elif [ -f "$klipper_cfg_loc/printer.cfg" ] && [ ! -f "$klipper_cfg_loc/kiauh_macros.cfg" ]; then
|
||||||
### copy kiauh_macros.cfg to config location
|
### copy kiauh_macros.cfg to config location
|
||||||
status_msg "Creating macro config file ..."
|
status_msg "Creating macro config file ..."
|
||||||
cp ${SRCDIR}/kiauh/resources/kiauh_macros.cfg $klipper_cfg_loc
|
cp "${SRCDIR}/kiauh/resources/kiauh_macros.cfg" "$klipper_cfg_loc"
|
||||||
### write the include to the very first line of the printer.cfg
|
### write the include to the very first line of the printer.cfg
|
||||||
sed -i "1 i [include kiauh_macros.cfg]" $klipper_cfg_loc/printer.cfg
|
sed -i "1 i [include kiauh_macros.cfg]" "$klipper_cfg_loc/printer.cfg"
|
||||||
ok_msg "$klipper_cfg_loc/kiauh_macros.cfg created!"
|
ok_msg "$klipper_cfg_loc/kiauh_macros.cfg created!"
|
||||||
fi
|
fi
|
||||||
### restart klipper service to parse the modified printer.cfg
|
### restart klipper service to parse the modified printer.cfg
|
||||||
@@ -216,7 +216,7 @@ mainsail_port_check(){
|
|||||||
select_mainsail_port
|
select_mainsail_port
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
DEFAULT_PORT=$(grep listen ${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
|
DEFAULT_PORT=$(grep listen "${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg" | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
|
||||||
SET_LISTEN_PORT=$DEFAULT_PORT
|
SET_LISTEN_PORT=$DEFAULT_PORT
|
||||||
fi
|
fi
|
||||||
SET_NGINX_CFG="true"
|
SET_NGINX_CFG="true"
|
||||||
@@ -237,7 +237,7 @@ fluidd_port_check(){
|
|||||||
select_fluidd_port
|
select_fluidd_port
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
DEFAULT_PORT=$(grep listen ${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
|
DEFAULT_PORT=$(grep listen "${SRCDIR}/kiauh/resources/klipper_webui_nginx.cfg" | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
|
||||||
SET_LISTEN_PORT=$DEFAULT_PORT
|
SET_LISTEN_PORT=$DEFAULT_PORT
|
||||||
fi
|
fi
|
||||||
SET_NGINX_CFG="true"
|
SET_NGINX_CFG="true"
|
||||||
@@ -323,10 +323,10 @@ mainsail_setup(){
|
|||||||
MAINSAIL_DL_URL=$(curl -s $MAINSAIL_REPO_API | grep browser_download_url | cut -d'"' -f4 | head -1)
|
MAINSAIL_DL_URL=$(curl -s $MAINSAIL_REPO_API | grep browser_download_url | cut -d'"' -f4 | head -1)
|
||||||
|
|
||||||
### remove existing and create fresh mainsail folder, then download mainsail
|
### remove existing and create fresh mainsail folder, then download mainsail
|
||||||
[ -d $MAINSAIL_DIR ] && rm -rf $MAINSAIL_DIR
|
[ -d "$MAINSAIL_DIR" ] && rm -rf "$MAINSAIL_DIR"
|
||||||
mkdir $MAINSAIL_DIR && cd $MAINSAIL_DIR
|
mkdir "$MAINSAIL_DIR" && cd $MAINSAIL_DIR
|
||||||
status_msg "Downloading Mainsail $MAINSAIL_VERSION ..."
|
status_msg "Downloading Mainsail $MAINSAIL_VERSION ..."
|
||||||
wget $MAINSAIL_DL_URL && ok_msg "Download complete!"
|
wget "$MAINSAIL_DL_URL" && ok_msg "Download complete!"
|
||||||
|
|
||||||
### extract archive
|
### extract archive
|
||||||
status_msg "Extracting archive ..."
|
status_msg "Extracting archive ..."
|
||||||
@@ -343,8 +343,8 @@ mainsail_setup(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
enable_mainsail_remotemode(){
|
enable_mainsail_remotemode(){
|
||||||
rm -f $MAINSAIL_DIR/config.json
|
rm -f "$MAINSAIL_DIR/config.json"
|
||||||
echo -e "{\n \"remoteMode\":true\n}" >> $MAINSAIL_DIR/config.json
|
echo -e "{\n \"remoteMode\":true\n}" >> "$MAINSAIL_DIR/config.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
fluidd_setup(){
|
fluidd_setup(){
|
||||||
@@ -352,10 +352,10 @@ fluidd_setup(){
|
|||||||
FLUIDD_DL_URL=$(curl -s $FLUIDD_REPO_API | grep browser_download_url | cut -d'"' -f4 | head -1)
|
FLUIDD_DL_URL=$(curl -s $FLUIDD_REPO_API | grep browser_download_url | cut -d'"' -f4 | head -1)
|
||||||
|
|
||||||
### remove existing and create fresh fluidd folder, then download fluidd
|
### remove existing and create fresh fluidd folder, then download fluidd
|
||||||
[ -d $FLUIDD_DIR ] && rm -rf $FLUIDD_DIR
|
[ -d "$FLUIDD_DIR" ] && rm -rf "$FLUIDD_DIR"
|
||||||
mkdir $FLUIDD_DIR && cd $FLUIDD_DIR
|
mkdir "$FLUIDD_DIR" && cd $FLUIDD_DIR
|
||||||
status_msg "Downloading Fluidd $FLUIDD_VERSION ..."
|
status_msg "Downloading Fluidd $FLUIDD_VERSION ..."
|
||||||
wget $FLUIDD_DL_URL && ok_msg "Download complete!"
|
wget "$FLUIDD_DL_URL" && ok_msg "Download complete!"
|
||||||
|
|
||||||
### extract archive
|
### extract archive
|
||||||
status_msg "Extracting archive ..."
|
status_msg "Extracting archive ..."
|
||||||
@@ -374,7 +374,7 @@ set_upstream_nginx_cfg(){
|
|||||||
[ -f "$NGINX_CONFD/common_vars.conf" ] && sudo mv "$NGINX_CONFD/common_vars.conf" "$BACKUP_DIR/nginx_cfg/${current_date}_common_vars.conf"
|
[ -f "$NGINX_CONFD/common_vars.conf" ] && sudo mv "$NGINX_CONFD/common_vars.conf" "$BACKUP_DIR/nginx_cfg/${current_date}_common_vars.conf"
|
||||||
### transfer ownership of backed up files from root to ${USER}
|
### transfer ownership of backed up files from root to ${USER}
|
||||||
for log in $(ls "$BACKUP_DIR/nginx_cfg"); do
|
for log in $(ls "$BACKUP_DIR/nginx_cfg"); do
|
||||||
sudo chown ${USER} "$BACKUP_DIR/nginx_cfg/$log"
|
sudo chown "${USER}" "$BACKUP_DIR/nginx_cfg/$log"
|
||||||
done
|
done
|
||||||
### copy nginx configs to target destination
|
### copy nginx configs to target destination
|
||||||
if [ ! -f "$NGINX_CONFD/upstreams.conf" ]; then
|
if [ ! -f "$NGINX_CONFD/upstreams.conf" ]; then
|
||||||
@@ -391,15 +391,15 @@ fetch_webui_ports(){
|
|||||||
WEBIFS=(mainsail fluidd octoprint dwc2)
|
WEBIFS=(mainsail fluidd octoprint dwc2)
|
||||||
for interface in "${WEBIFS[@]}"; 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 [ ! -n "$(grep -E "${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"
|
||||||
sed -i '$a'"${interface}_port=${port}" $INI_FILE
|
sed -i '$a'"${interface}_port=${port}" "$INI_FILE"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
sed -i "/^${interface}_port/d" $INI_FILE
|
sed -i "/^${interface}_port/d" "$INI_FILE"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user