mirror of
https://github.com/winapps-org/winapps.git
synced 2025-06-02 13:17:19 +02:00
Updated .pre-commit-config.yaml
This commit is contained in:
parent
e13b9e24a2
commit
38d5874d64
@ -12,7 +12,7 @@ repos:
|
|||||||
- id: remove-crlf
|
- id: remove-crlf
|
||||||
- id: forbid-tabs
|
- id: forbid-tabs
|
||||||
- id: remove-tabs
|
- id: remove-tabs
|
||||||
args: [ --whitespaces-count, "2" ]
|
args: [ --whitespaces-count, "4" ]
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.6.0
|
rev: v4.6.0
|
||||||
@ -44,6 +44,7 @@ repos:
|
|||||||
rev: v3.8.0-1
|
rev: v3.8.0-1
|
||||||
hooks:
|
hooks:
|
||||||
- id: shfmt
|
- id: shfmt
|
||||||
|
args: ["-i", "4", "-ci", "-s"]
|
||||||
|
|
||||||
- repo: https://github.com/shellcheck-py/shellcheck-py
|
- repo: https://github.com/shellcheck-py/shellcheck-py
|
||||||
rev: v0.10.0.1
|
rev: v0.10.0.1
|
||||||
|
426
bin/winapps
426
bin/winapps
@ -46,270 +46,270 @@ MULTI_FLAG=""
|
|||||||
# Name: 'waThrowExit'
|
# Name: 'waThrowExit'
|
||||||
# Role: Throw an error message and exit the script.
|
# Role: Throw an error message and exit the script.
|
||||||
function waThrowExit() {
|
function waThrowExit() {
|
||||||
# Declare variables.
|
# Declare variables.
|
||||||
local ERR_CODE="$1"
|
local ERR_CODE="$1"
|
||||||
|
|
||||||
# Throw error.
|
# Throw error.
|
||||||
case "$ERR_CODE" in
|
case "$ERR_CODE" in
|
||||||
"$EC_MISSING_CONFIG")
|
"$EC_MISSING_CONFIG")
|
||||||
# Missing WinApps configuration file.
|
# Missing WinApps configuration file.
|
||||||
dprint "ERROR: MISSING WINAPPS CONFIGURATION FILE. EXITING."
|
dprint "ERROR: MISSING WINAPPS CONFIGURATION FILE. EXITING."
|
||||||
echo -e "${ERROR_TEXT}ERROR: MISSING WINAPPS CONFIGURATION FILE.${CLEAR_TEXT}"
|
echo -e "${ERROR_TEXT}ERROR: MISSING WINAPPS CONFIGURATION FILE.${CLEAR_TEXT}"
|
||||||
echo "Please create a WinApps configuration file at '${CONFIG_PATH}'".
|
echo "Please create a WinApps configuration file at '${CONFIG_PATH}'".
|
||||||
;;
|
;;
|
||||||
"$EC_MISSING_FREERDP")
|
"$EC_MISSING_FREERDP")
|
||||||
dprint "ERROR: FREERDP VERSION 3 IS NOT INSTALLED. EXITING."
|
dprint "ERROR: FREERDP VERSION 3 IS NOT INSTALLED. EXITING."
|
||||||
echo -e "${ERROR_TEXT}ERROR: FREERDP VERSION 3 IS NOT INSTALLED.${CLEAR_TEXT}"
|
echo -e "${ERROR_TEXT}ERROR: FREERDP VERSION 3 IS NOT INSTALLED.${CLEAR_TEXT}"
|
||||||
;;
|
;;
|
||||||
"$EC_NOT_IN_GROUP")
|
"$EC_NOT_IN_GROUP")
|
||||||
dprint "ERROR: USER NOT PART OF REQUIRED GROUPS. EXITING."
|
dprint "ERROR: USER NOT PART OF REQUIRED GROUPS. EXITING."
|
||||||
echo -e "${ERROR_TEXT}ERROR: USER NOT PART OF REQUIRED GROUPS.${CLEAR_TEXT}"
|
echo -e "${ERROR_TEXT}ERROR: USER NOT PART OF REQUIRED GROUPS.${CLEAR_TEXT}"
|
||||||
echo "Please run:"
|
echo "Please run:"
|
||||||
echo " sudo usermod -a -G libvirt $(whoami)"
|
echo " sudo usermod -a -G libvirt $(whoami)"
|
||||||
echo " sudo usermod -a -G kvm $(whoami)"
|
echo " sudo usermod -a -G kvm $(whoami)"
|
||||||
;;
|
;;
|
||||||
"$EC_VM_NOT_RUNNING")
|
"$EC_VM_NOT_RUNNING")
|
||||||
dprint "ERROR: VM NOT RUNNING. EXITING."
|
dprint "ERROR: VM NOT RUNNING. EXITING."
|
||||||
echo -e "${ERROR_TEXT}ERROR: VM NOT RUNNING.${CLEAR_TEXT}"
|
echo -e "${ERROR_TEXT}ERROR: VM NOT RUNNING.${CLEAR_TEXT}"
|
||||||
echo "Please ensure the Windows VM is powered on."
|
echo "Please ensure the Windows VM is powered on."
|
||||||
;;
|
;;
|
||||||
"$EC_VM_NO_IP")
|
"$EC_VM_NO_IP")
|
||||||
dprint "ERROR: VM UNREACHABLE. EXITING."
|
dprint "ERROR: VM UNREACHABLE. EXITING."
|
||||||
echo -e "${ERROR_TEXT}ERROR: VM UNREACHABLE.${CLEAR_TEXT}"
|
echo -e "${ERROR_TEXT}ERROR: VM UNREACHABLE.${CLEAR_TEXT}"
|
||||||
echo "Please ensure the Windows VM is assigned an IP address."
|
echo "Please ensure the Windows VM is assigned an IP address."
|
||||||
;;
|
;;
|
||||||
"$EC_VM_BAD_PORT")
|
"$EC_VM_BAD_PORT")
|
||||||
dprint "ERROR: RDP PORT CLOSED. EXITING."
|
dprint "ERROR: RDP PORT CLOSED. EXITING."
|
||||||
echo -e "${ERROR_TEXT}ERROR: RDP PORT CLOSED.${CLEAR_TEXT}"
|
echo -e "${ERROR_TEXT}ERROR: RDP PORT CLOSED.${CLEAR_TEXT}"
|
||||||
echo "Please ensure Remote Desktop is correctly configured on the Windows VM."
|
echo "Please ensure Remote Desktop is correctly configured on the Windows VM."
|
||||||
;;
|
;;
|
||||||
"$EC_UNSUPPORTED_APP")
|
"$EC_UNSUPPORTED_APP")
|
||||||
dprint "ERROR: APPLICATION NOT FOUND. EXITING."
|
dprint "ERROR: APPLICATION NOT FOUND. EXITING."
|
||||||
echo -e "${ERROR_TEXT}ERROR: APPLICATION NOT FOUND.${CLEAR_TEXT}"
|
echo -e "${ERROR_TEXT}ERROR: APPLICATION NOT FOUND.${CLEAR_TEXT}"
|
||||||
echo "Please ensure the program is correctly configured as an officially supported application."
|
echo "Please ensure the program is correctly configured as an officially supported application."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Provide generic advice.
|
# Provide generic advice.
|
||||||
echo "Check the WinApps project README for more information."
|
echo "Check the WinApps project README for more information."
|
||||||
|
|
||||||
# Terminate the script.
|
# Terminate the script.
|
||||||
echo "Exiting with status '${ERR_CODE}'."
|
echo "Exiting with status '${ERR_CODE}'."
|
||||||
exit "$ERR_CODE"
|
exit "$ERR_CODE"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Name: 'dprint'
|
# Name: 'dprint'
|
||||||
# Role: Conditionally print debug messages to a log file, creating it if it does not exist.
|
# Role: Conditionally print debug messages to a log file, creating it if it does not exist.
|
||||||
function dprint() {
|
function dprint() {
|
||||||
[ "$DEBUG" = "true" ] && echo "[$RUN] $1" >>"$LOG_PATH"
|
[ "$DEBUG" = "true" ] && echo "[$RUN] $1" >>"$LOG_PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Name: 'waLoadConfig'
|
# Name: 'waLoadConfig'
|
||||||
# Role: Load the variables within the WinApps configuration file.
|
# Role: Load the variables within the WinApps configuration file.
|
||||||
function waLoadConfig() {
|
function waLoadConfig() {
|
||||||
# Load WinApps configuration file.
|
# Load WinApps configuration file.
|
||||||
if [ -f "$CONFIG_PATH" ]; then
|
if [ -f "$CONFIG_PATH" ]; then
|
||||||
# shellcheck source=/dev/null # Exclude WinApps configuration file from being checked by ShellCheck.
|
# shellcheck source=/dev/null # Exclude WinApps configuration file from being checked by ShellCheck.
|
||||||
source "$CONFIG_PATH"
|
source "$CONFIG_PATH"
|
||||||
else
|
else
|
||||||
waThrowExit $EC_MISSING_CONFIG
|
waThrowExit $EC_MISSING_CONFIG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update 'MULTI_FLAG' based on 'MULTIMON'.
|
# Update 'MULTI_FLAG' based on 'MULTIMON'.
|
||||||
MULTI_FLAG=$([[ $MULTIMON == "true" ]] && echo "/multimon" || echo "+span")
|
MULTI_FLAG=$([[ $MULTIMON == "true" ]] && echo "/multimon" || echo "+span")
|
||||||
|
|
||||||
# Append additional flags or parameters to FreeRDP.
|
# Append additional flags or parameters to FreeRDP.
|
||||||
[[ -n $RDP_FLAGS ]] && FREERDP_COMMAND="${FREERDP_COMMAND} ${RDP_FLAGS}"
|
[[ -n $RDP_FLAGS ]] && FREERDP_COMMAND="${FREERDP_COMMAND} ${RDP_FLAGS}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Name: 'waLastRun'
|
# Name: 'waLastRun'
|
||||||
# Role: Determine the last time this script was run.
|
# Role: Determine the last time this script was run.
|
||||||
function waLastRun() {
|
function waLastRun() {
|
||||||
# Declare variables.
|
# Declare variables.
|
||||||
local LAST_RUN_UNIX_TIME=0
|
local LAST_RUN_UNIX_TIME=0
|
||||||
local CURR_RUN_UNIX_TIME=0
|
local CURR_RUN_UNIX_TIME=0
|
||||||
|
|
||||||
# Store the time this script was run last as a unix timestamp.
|
# Store the time this script was run last as a unix timestamp.
|
||||||
if [ -f "$LASTRUN_PATH" ]; then
|
if [ -f "$LASTRUN_PATH" ]; then
|
||||||
LAST_RUN_UNIX_TIME=$(stat -t -c %Y "$LASTRUN_PATH")
|
LAST_RUN_UNIX_TIME=$(stat -t -c %Y "$LASTRUN_PATH")
|
||||||
dprint "LAST_RUN: ${LAST_RUN_UNIX_TIME}"
|
dprint "LAST_RUN: ${LAST_RUN_UNIX_TIME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update the file modification time with the current time.
|
# Update the file modification time with the current time.
|
||||||
touch "$LASTRUN_PATH"
|
touch "$LASTRUN_PATH"
|
||||||
CURR_RUN_UNIX_TIME=$(stat -t -c %Y "$LASTRUN_PATH")
|
CURR_RUN_UNIX_TIME=$(stat -t -c %Y "$LASTRUN_PATH")
|
||||||
dprint "THIS_RUN: ${CURR_RUN_UNIX_TIME}"
|
dprint "THIS_RUN: ${CURR_RUN_UNIX_TIME}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function waGetFreeRDPCommand() {
|
function waGetFreeRDPCommand() {
|
||||||
# Attempt to set a FreeRDP command if the command variable is empty.
|
# Attempt to set a FreeRDP command if the command variable is empty.
|
||||||
if [ -z "$FREERDP_COMMAND" ]; then
|
if [ -z "$FREERDP_COMMAND" ]; then
|
||||||
# Check for 'xfreerdp'.
|
# Check for 'xfreerdp'.
|
||||||
if command -v xfreerdp &>/dev/null; then
|
if command -v xfreerdp &>/dev/null; then
|
||||||
# Check FreeRDP major version is 3 or greater.
|
# Check FreeRDP major version is 3 or greater.
|
||||||
FREERDP_MAJOR_VERSION=$(xfreerdp --version | head -n 1 | grep -o -m 1 '\b[0-9]\S*' | cut -d'.' -f1)
|
FREERDP_MAJOR_VERSION=$(xfreerdp --version | head -n 1 | grep -o -m 1 '\b[0-9]\S*' | cut -d'.' -f1)
|
||||||
if [[ $FREERDP_MAJOR_VERSION =~ ^[0-9]+$ ]] && ((FREERDP_MAJOR_VERSION >= 3)); then
|
if [[ $FREERDP_MAJOR_VERSION =~ ^[0-9]+$ ]] && ((FREERDP_MAJOR_VERSION >= 3)); then
|
||||||
FREERDP_COMMAND="xfreerdp"
|
FREERDP_COMMAND="xfreerdp"
|
||||||
fi
|
fi
|
||||||
# Check for 'xfreerdp3'.
|
# Check for 'xfreerdp3'.
|
||||||
elif command -v xfreerdp3 &>/dev/null; then
|
elif command -v xfreerdp3 &>/dev/null; then
|
||||||
# Check FreeRDP major version is 3 or greater.
|
# Check FreeRDP major version is 3 or greater.
|
||||||
FREERDP_MAJOR_VERSION=$(xfreerdp3 --version | head -n 1 | grep -o -m 1 '\b[0-9]\S*' | cut -d'.' -f1)
|
FREERDP_MAJOR_VERSION=$(xfreerdp3 --version | head -n 1 | grep -o -m 1 '\b[0-9]\S*' | cut -d'.' -f1)
|
||||||
if [[ $FREERDP_MAJOR_VERSION =~ ^[0-9]+$ ]] && ((FREERDP_MAJOR_VERSION >= 3)); then
|
if [[ $FREERDP_MAJOR_VERSION =~ ^[0-9]+$ ]] && ((FREERDP_MAJOR_VERSION >= 3)); then
|
||||||
FREERDP_COMMAND="xfreerdp3"
|
FREERDP_COMMAND="xfreerdp3"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for FreeRDP Flatpak (fallback option).
|
# Check for FreeRDP Flatpak (fallback option).
|
||||||
if [ -z "$FREERDP_COMMAND" ]; then
|
if [ -z "$FREERDP_COMMAND" ]; then
|
||||||
if command -v flatpak &>/dev/null; then
|
if command -v flatpak &>/dev/null; then
|
||||||
if flatpak list --columns=application | grep -q "^com.freerdp.FreeRDP$"; then
|
if flatpak list --columns=application | grep -q "^com.freerdp.FreeRDP$"; then
|
||||||
# Check FreeRDP major version is 3 or greater.
|
# Check FreeRDP major version is 3 or greater.
|
||||||
FREERDP_MAJOR_VERSION=$(flatpak list --columns=application,version | grep "^com.freerdp.FreeRDP" | awk '{print $2}' | cut -d'.' -f1)
|
FREERDP_MAJOR_VERSION=$(flatpak list --columns=application,version | grep "^com.freerdp.FreeRDP" | awk '{print $2}' | cut -d'.' -f1)
|
||||||
if [[ $FREERDP_MAJOR_VERSION =~ ^[0-9]+$ ]] && ((FREERDP_MAJOR_VERSION >= 3)); then
|
if [[ $FREERDP_MAJOR_VERSION =~ ^[0-9]+$ ]] && ((FREERDP_MAJOR_VERSION >= 3)); then
|
||||||
FREERDP_COMMAND="flatpak run --command=xfreerdp com.freerdp.FreeRDP"
|
FREERDP_COMMAND="flatpak run --command=xfreerdp com.freerdp.FreeRDP"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v "$FREERDP_COMMAND" &>/dev/null || [ "$FREERDP_COMMAND" = "flatpak run --command=xfreerdp com.freerdp.FreeRDP" ]; then
|
if command -v "$FREERDP_COMMAND" &>/dev/null || [ "$FREERDP_COMMAND" = "flatpak run --command=xfreerdp com.freerdp.FreeRDP" ]; then
|
||||||
dprint "Using FreeRDP command '${FREERDP_COMMAND}'."
|
dprint "Using FreeRDP command '${FREERDP_COMMAND}'."
|
||||||
else
|
else
|
||||||
waThrowExit "$EC_MISSING_FREERDP"
|
waThrowExit "$EC_MISSING_FREERDP"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Name: 'waCheckGroupMembership'
|
# Name: 'waCheckGroupMembership'
|
||||||
# Role: Ensures the current user is part of the required groups.
|
# Role: Ensures the current user is part of the required groups.
|
||||||
function waCheckGroupMembership() {
|
function waCheckGroupMembership() {
|
||||||
# Identify groups the current user belongs to.
|
# Identify groups the current user belongs to.
|
||||||
# shellcheck disable=SC2155 # Silence warnings regarding masking return values through simultaneous declaration and assignment.
|
# shellcheck disable=SC2155 # Silence warnings regarding masking return values through simultaneous declaration and assignment.
|
||||||
local USER_GROUPS=$(groups "$(whoami)")
|
local USER_GROUPS=$(groups "$(whoami)")
|
||||||
|
|
||||||
if ! (echo "$USER_GROUPS" | grep -q -E "\blibvirt\b") || ! (echo "$USER_GROUPS" | grep -q -E "\bkvm\b"); then
|
if ! (echo "$USER_GROUPS" | grep -q -E "\blibvirt\b") || ! (echo "$USER_GROUPS" | grep -q -E "\bkvm\b"); then
|
||||||
waThrowExit "$EC_NOT_IN_GROUP"
|
waThrowExit "$EC_NOT_IN_GROUP"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Name: 'waCheckVMRunning'
|
# Name: 'waCheckVMRunning'
|
||||||
# Role: Throw an error if the Windows VM is not running.
|
# Role: Throw an error if the Windows VM is not running.
|
||||||
function waCheckVMRunning() {
|
function waCheckVMRunning() {
|
||||||
! virsh list --state-running --name | grep -q "^${VM_NAME}$" && waThrowExit "$EC_VM_NOT_RUNNING"
|
! virsh list --state-running --name | grep -q "^${VM_NAME}$" && waThrowExit "$EC_VM_NOT_RUNNING"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Name: 'waCheckVMContactable'
|
# Name: 'waCheckVMContactable'
|
||||||
# Role: Assesses whether the Windows VM can be contacted.
|
# Role: Assesses whether the Windows VM can be contacted.
|
||||||
function waCheckVMContactable() {
|
function waCheckVMContactable() {
|
||||||
# Declare variables.
|
# Declare variables.
|
||||||
local VM_MAC="" # Stores the MAC address of the Windows VM.
|
local VM_MAC="" # Stores the MAC address of the Windows VM.
|
||||||
|
|
||||||
# Obtain Windows VM IP Address
|
# Obtain Windows VM IP Address
|
||||||
if [ -z "$RDP_IP" ]; then
|
if [ -z "$RDP_IP" ]; then
|
||||||
VM_MAC=$(virsh domiflist "$VM_NAME" | grep -oE "([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})") # VM MAC address.
|
VM_MAC=$(virsh domiflist "$VM_NAME" | grep -oE "([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})") # VM MAC address.
|
||||||
RDP_IP=$(arp -n | grep "$VM_MAC" | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") # VM IP address.
|
RDP_IP=$(arp -n | grep "$VM_MAC" | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}") # VM IP address.
|
||||||
[ -z "$RDP_IP" ] && waThrowExit "$EC_VM_NO_IP"
|
[ -z "$RDP_IP" ] && waThrowExit "$EC_VM_NO_IP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for an open RDP port.
|
# Check for an open RDP port.
|
||||||
timeout 5 nc -z "$RDP_IP" "$RDP_PORT" &>/dev/null || waThrowExit "$EC_VM_BAD_PORT"
|
timeout 5 nc -z "$RDP_IP" "$RDP_PORT" &>/dev/null || waThrowExit "$EC_VM_BAD_PORT"
|
||||||
}
|
}
|
||||||
|
|
||||||
function waRunCommand() {
|
function waRunCommand() {
|
||||||
# Declare variables.
|
# Declare variables.
|
||||||
local ICON=""
|
local ICON=""
|
||||||
local FILE_PATH=""
|
local FILE_PATH=""
|
||||||
|
|
||||||
# Run option.
|
# Run option.
|
||||||
if [ "$1" = "windows" ]; then
|
if [ "$1" = "windows" ]; then
|
||||||
# Open Windows VM.
|
# Open Windows VM.
|
||||||
dprint "WINDOWS"
|
dprint "WINDOWS"
|
||||||
$FREERDP_COMMAND \
|
$FREERDP_COMMAND \
|
||||||
/d:"$RDP_DOMAIN" \
|
/d:"$RDP_DOMAIN" \
|
||||||
/u:"$RDP_USER" \
|
/u:"$RDP_USER" \
|
||||||
/p:"$RDP_PASS" \
|
/p:"$RDP_PASS" \
|
||||||
/scale:"$RDP_SCALE" \
|
/scale:"$RDP_SCALE" \
|
||||||
+dynamic-resolution \
|
+dynamic-resolution \
|
||||||
+auto-reconnect \
|
+auto-reconnect \
|
||||||
+home-drive \
|
+home-drive \
|
||||||
/wm-class:"Microsoft Windows" \
|
/wm-class:"Microsoft Windows" \
|
||||||
/v:"$RDP_IP" &>/dev/null &
|
/v:"$RDP_IP" &>/dev/null &
|
||||||
elif [ "$1" = "manual" ]; then
|
elif [ "$1" = "manual" ]; then
|
||||||
# Open specified application.
|
# Open specified application.
|
||||||
dprint "MANUAL: ${2}"
|
dprint "MANUAL: ${2}"
|
||||||
$FREERDP_COMMAND \
|
$FREERDP_COMMAND \
|
||||||
/cert:tofu \
|
/cert:tofu \
|
||||||
/d:"$RDP_DOMAIN" \
|
/d:"$RDP_DOMAIN" \
|
||||||
/u:"$RDP_USER" \
|
/u:"$RDP_USER" \
|
||||||
/p:"$RDP_PASS" \
|
/p:"$RDP_PASS" \
|
||||||
/scale:"$RDP_SCALE" \
|
/scale:"$RDP_SCALE" \
|
||||||
+auto-reconnect \
|
+auto-reconnect \
|
||||||
+clipboard \
|
+clipboard \
|
||||||
+home-drive \
|
+home-drive \
|
||||||
-wallpaper \
|
-wallpaper \
|
||||||
+dynamic-resolution \
|
+dynamic-resolution \
|
||||||
"$MULTI_FLAG" \
|
"$MULTI_FLAG" \
|
||||||
/app:program:"$2" \
|
/app:program:"$2" \
|
||||||
/v:"$RDP_IP" &>/dev/null &
|
/v:"$RDP_IP" &>/dev/null &
|
||||||
else
|
else
|
||||||
# Script summoned from right-click menu with officially supported application name plus/minus a file path.
|
# Script summoned from right-click menu with officially supported application name plus/minus a file path.
|
||||||
if [ -e "${SCRIPT_DIR_PATH}/../apps/${1}/info" ]; then
|
if [ -e "${SCRIPT_DIR_PATH}/../apps/${1}/info" ]; then
|
||||||
# shellcheck source=/dev/null # Exclude this file from being checked by ShellCheck.
|
# shellcheck source=/dev/null # Exclude this file from being checked by ShellCheck.
|
||||||
source "${SCRIPT_DIR_PATH}/../apps/${1}/info"
|
source "${SCRIPT_DIR_PATH}/../apps/${1}/info"
|
||||||
ICON="${SCRIPT_DIR_PATH}/../apps/${1}/icon.svg"
|
ICON="${SCRIPT_DIR_PATH}/../apps/${1}/icon.svg"
|
||||||
elif [ -e "${APPDATA_PATH}/apps/${1}/info" ]; then
|
elif [ -e "${APPDATA_PATH}/apps/${1}/info" ]; then
|
||||||
# shellcheck source=/dev/null # Exclude this file from being checked by ShellCheck.
|
# shellcheck source=/dev/null # Exclude this file from being checked by ShellCheck.
|
||||||
source "${APPDATA_PATH}/apps/${1}/info"
|
source "${APPDATA_PATH}/apps/${1}/info"
|
||||||
ICON="${APPDATA_PATH}/apps/${1}/icon.svg"
|
ICON="${APPDATA_PATH}/apps/${1}/icon.svg"
|
||||||
elif [ -e "${SYS_APP_PATH}/apps/${1}/info" ]; then
|
elif [ -e "${SYS_APP_PATH}/apps/${1}/info" ]; then
|
||||||
# shellcheck source=/dev/null # Exclude this file from being checked by ShellCheck.
|
# shellcheck source=/dev/null # Exclude this file from being checked by ShellCheck.
|
||||||
source "${SYS_APP_PATH}/apps/${1}/info"
|
source "${SYS_APP_PATH}/apps/${1}/info"
|
||||||
ICON="${SYS_APP_PATH}/apps/${1}/icon.svg"
|
ICON="${SYS_APP_PATH}/apps/${1}/icon.svg"
|
||||||
else
|
else
|
||||||
waThrowExit "$EC_UNSUPPORTED_APP"
|
waThrowExit "$EC_UNSUPPORTED_APP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if a file path was specified, and pass this to the application.
|
# Check if a file path was specified, and pass this to the application.
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
# No file path specified.
|
# No file path specified.
|
||||||
$FREERDP_COMMAND \
|
$FREERDP_COMMAND \
|
||||||
/d:"$RDP_DOMAIN" \
|
/d:"$RDP_DOMAIN" \
|
||||||
/u:"$RDP_USER" \
|
/u:"$RDP_USER" \
|
||||||
/p:"$RDP_PASS" \
|
/p:"$RDP_PASS" \
|
||||||
/scale:"$RDP_SCALE" \
|
/scale:"$RDP_SCALE" \
|
||||||
+auto-reconnect \
|
+auto-reconnect \
|
||||||
+clipboard \
|
+clipboard \
|
||||||
+home-drive \
|
+home-drive \
|
||||||
-wallpaper \
|
-wallpaper \
|
||||||
+dynamic-resolution \
|
+dynamic-resolution \
|
||||||
"$MULTI_FLAG" \
|
"$MULTI_FLAG" \
|
||||||
/wm-class:"$FULL_NAME" \
|
/wm-class:"$FULL_NAME" \
|
||||||
/app:program:"$WIN_EXECUTABLE",icon:"$ICON",name:"$FULL_NAME" \
|
/app:program:"$WIN_EXECUTABLE",icon:"$ICON",name:"$FULL_NAME" \
|
||||||
/v:"$RDP_IP" &>/dev/null &
|
/v:"$RDP_IP" &>/dev/null &
|
||||||
else
|
else
|
||||||
# Convert path from UNIX to Windows style.
|
# Convert path from UNIX to Windows style.
|
||||||
FILE_PATH=$(echo "$2" | sed 's|'"${HOME}"'|\\\\tsclient\\home|;s|/|\\|g;s|\\|\\\\|g')
|
FILE_PATH=$(echo "$2" | sed 's|'"${HOME}"'|\\\\tsclient\\home|;s|/|\\|g;s|\\|\\\\|g')
|
||||||
dprint "UNIX_FILE_PATH: ${2}"
|
dprint "UNIX_FILE_PATH: ${2}"
|
||||||
dprint "WINDOWS_FILE_PATH: ${FILE_PATH}"
|
dprint "WINDOWS_FILE_PATH: ${FILE_PATH}"
|
||||||
|
|
||||||
$FREERDP_COMMAND \
|
$FREERDP_COMMAND \
|
||||||
/cert:tofu \
|
/cert:tofu \
|
||||||
/d:"$RDP_DOMAIN" \
|
/d:"$RDP_DOMAIN" \
|
||||||
/u:"$RDP_USER" \
|
/u:"$RDP_USER" \
|
||||||
/p:"$RDP_PASS" \
|
/p:"$RDP_PASS" \
|
||||||
/scale:"$RDP_SCALE" \
|
/scale:"$RDP_SCALE" \
|
||||||
+auto-reconnect \
|
+auto-reconnect \
|
||||||
+clipboard \
|
+clipboard \
|
||||||
+home-drive \
|
+home-drive \
|
||||||
-wallpaper \
|
-wallpaper \
|
||||||
+dynamic-resolution \
|
+dynamic-resolution \
|
||||||
"$MULTI_FLAG" \
|
"$MULTI_FLAG" \
|
||||||
/wm-class:"$FULL_NAME" \
|
/wm-class:"$FULL_NAME" \
|
||||||
/app:program:"$WIN_EXECUTABLE",icon:"$ICON",name:$"FULL_NAME",cmd:\""$FILE_PATH"\" \
|
/app:program:"$WIN_EXECUTABLE",icon:"$ICON",name:$"FULL_NAME",cmd:\""$FILE_PATH"\" \
|
||||||
/v:"$RDP_IP" &>/dev/null &
|
/v:"$RDP_IP" &>/dev/null &
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
### MAIN LOGIC ###
|
### MAIN LOGIC ###
|
||||||
|
@ -11,176 +11,176 @@ declare -r MNU_OPTION_WIDTH_OFFSET=7 # Offset for fitting options.
|
|||||||
|
|
||||||
### FUNCTIONS ###
|
### FUNCTIONS ###
|
||||||
function inqMenu() {
|
function inqMenu() {
|
||||||
# DECLARE VARIABLES.
|
# DECLARE VARIABLES.
|
||||||
# Variables created from function arguments:
|
# Variables created from function arguments:
|
||||||
declare DIALOG_TEXT="$1" # Dialog heading.
|
declare DIALOG_TEXT="$1" # Dialog heading.
|
||||||
declare INPUT_OPTIONS_VAR="$2" # Input variable name.
|
declare INPUT_OPTIONS_VAR="$2" # Input variable name.
|
||||||
declare RETURN_STRING_VAR="$3" # Output variable name.
|
declare RETURN_STRING_VAR="$3" # Output variable name.
|
||||||
declare -n INPUT_OPTIONS="$INPUT_OPTIONS_VAR" # Input array nameref.
|
declare -n INPUT_OPTIONS="$INPUT_OPTIONS_VAR" # Input array nameref.
|
||||||
declare -n RETURN_STRING="$RETURN_STRING_VAR" # Output string nameref.
|
declare -n RETURN_STRING="$RETURN_STRING_VAR" # Output string nameref.
|
||||||
# Note: namerefs allow changes made through the nameref to affect the
|
# Note: namerefs allow changes made through the nameref to affect the
|
||||||
# referenced variable, even across different scopes like function calls.
|
# referenced variable, even across different scopes like function calls.
|
||||||
|
|
||||||
# Other variables:
|
# Other variables:
|
||||||
declare TRIMMED_OPTIONS=() # Input array post-trimming.
|
declare TRIMMED_OPTIONS=() # Input array post-trimming.
|
||||||
declare PADDED_OPTIONS=() # Input array with extra white space.
|
declare PADDED_OPTIONS=() # Input array with extra white space.
|
||||||
declare DIALOG_OPTIONS=() # Input array for options dialog.
|
declare DIALOG_OPTIONS=() # Input array for options dialog.
|
||||||
declare DIALOG_WIDTH=0 # Width of dialog window.
|
declare DIALOG_WIDTH=0 # Width of dialog window.
|
||||||
declare OPTION_NUMBER=0 # Number of options in dialog window.
|
declare OPTION_NUMBER=0 # Number of options in dialog window.
|
||||||
declare SELECTED_OPTIONS_STRING="" # Output value from dialog window.
|
declare SELECTED_OPTIONS_STRING="" # Output value from dialog window.
|
||||||
|
|
||||||
# MAIN LOGIC.
|
# MAIN LOGIC.
|
||||||
# Trim leading and trailing white space for each option.
|
# Trim leading and trailing white space for each option.
|
||||||
for OPTION in "${INPUT_OPTIONS[@]}"; do
|
for OPTION in "${INPUT_OPTIONS[@]}"; do
|
||||||
TRIMMED_OPTIONS+=("$(echo "$OPTION" | sed 's/^[ \t]*//;s/[ \t]*$//')")
|
TRIMMED_OPTIONS+=("$(echo "$OPTION" | sed 's/^[ \t]*//;s/[ \t]*$//')")
|
||||||
done
|
done
|
||||||
|
|
||||||
# Find the length of the longest option to set the dialog width.
|
# Find the length of the longest option to set the dialog width.
|
||||||
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
||||||
if [ "${#OPTION}" -gt "$DIALOG_WIDTH" ]; then
|
if [ "${#OPTION}" -gt "$DIALOG_WIDTH" ]; then
|
||||||
DIALOG_WIDTH=${#OPTION}
|
DIALOG_WIDTH=${#OPTION}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Apply the offset value to the dialog width.
|
# Apply the offset value to the dialog width.
|
||||||
DIALOG_WIDTH=$((DIALOG_WIDTH + MNU_OPTION_WIDTH_OFFSET))
|
DIALOG_WIDTH=$((DIALOG_WIDTH + MNU_OPTION_WIDTH_OFFSET))
|
||||||
|
|
||||||
# Adjust the dialog width again if the dialog text is longer.
|
# Adjust the dialog width again if the dialog text is longer.
|
||||||
if [ "$DIALOG_WIDTH" -lt $((${#DIALOG_TEXT} + TEXT_WIDTH_OFFSET)) ]; then
|
if [ "$DIALOG_WIDTH" -lt $((${#DIALOG_TEXT} + TEXT_WIDTH_OFFSET)) ]; then
|
||||||
DIALOG_WIDTH="$((${#DIALOG_TEXT} + TEXT_WIDTH_OFFSET))"
|
DIALOG_WIDTH="$((${#DIALOG_TEXT} + TEXT_WIDTH_OFFSET))"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Pad option text with trailing white space to left-align all options.
|
# Pad option text with trailing white space to left-align all options.
|
||||||
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
||||||
local PAD_LENGTH=$((DIALOG_WIDTH - MNU_OPTION_WIDTH_OFFSET - ${#OPTION}))
|
local PAD_LENGTH=$((DIALOG_WIDTH - MNU_OPTION_WIDTH_OFFSET - ${#OPTION}))
|
||||||
# shellcheck disable=SC2155
|
# shellcheck disable=SC2155
|
||||||
local PADDED_OPTION="${OPTION}$(printf '%*s' $PAD_LENGTH)"
|
local PADDED_OPTION="${OPTION}$(printf '%*s' $PAD_LENGTH)"
|
||||||
PADDED_OPTIONS+=("$PADDED_OPTION")
|
PADDED_OPTIONS+=("$PADDED_OPTION")
|
||||||
done
|
done
|
||||||
|
|
||||||
# Convert options into the appropriate format for a 'dialog' menu.
|
# Convert options into the appropriate format for a 'dialog' menu.
|
||||||
for PADDED_OPTION in "${PADDED_OPTIONS[@]}"; do
|
for PADDED_OPTION in "${PADDED_OPTIONS[@]}"; do
|
||||||
DIALOG_OPTIONS+=("$PADDED_OPTION" "")
|
DIALOG_OPTIONS+=("$PADDED_OPTION" "")
|
||||||
done
|
done
|
||||||
|
|
||||||
# Store the number of options.
|
# Store the number of options.
|
||||||
OPTION_NUMBER="${#INPUT_OPTIONS[@]}"
|
OPTION_NUMBER="${#INPUT_OPTIONS[@]}"
|
||||||
|
|
||||||
# Produce checkbox.
|
# Produce checkbox.
|
||||||
# The output string contains options delimited by spaces.
|
# The output string contains options delimited by spaces.
|
||||||
# Each option is enclosed in double quotes within the output string.
|
# Each option is enclosed in double quotes within the output string.
|
||||||
# For example: '"Option 1 " "The Second Option " " Option Number 3 "'
|
# For example: '"Option 1 " "The Second Option " " Option Number 3 "'
|
||||||
SELECTED_OPTIONS_STRING=$(dialog \
|
SELECTED_OPTIONS_STRING=$(dialog \
|
||||||
--keep-tite \
|
--keep-tite \
|
||||||
--clear \
|
--clear \
|
||||||
--no-shadow \
|
--no-shadow \
|
||||||
--menu \
|
--menu \
|
||||||
"$DIALOG_TEXT" \
|
"$DIALOG_TEXT" \
|
||||||
"$DIALOG_HEIGHT" \
|
"$DIALOG_HEIGHT" \
|
||||||
"$DIALOG_WIDTH" \
|
"$DIALOG_WIDTH" \
|
||||||
"$OPTION_NUMBER" \
|
"$OPTION_NUMBER" \
|
||||||
"${DIALOG_OPTIONS[@]}" \
|
"${DIALOG_OPTIONS[@]}" \
|
||||||
2>&1 >/dev/tty) || exit 0
|
2>&1 >/dev/tty) || exit 0
|
||||||
|
|
||||||
# Remove white space added previously.
|
# Remove white space added previously.
|
||||||
RETURN_STRING=$(echo "$SELECTED_OPTIONS_STRING" |
|
RETURN_STRING=$(echo "$SELECTED_OPTIONS_STRING" |
|
||||||
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||||
|
|
||||||
# Remove escapes (introduced by 'dialog' if options have parentheses).
|
# Remove escapes (introduced by 'dialog' if options have parentheses).
|
||||||
RETURN_STRING="${RETURN_STRING//\\/}" # ${variable//search/replace}
|
RETURN_STRING="${RETURN_STRING//\\/}" # ${variable//search/replace}
|
||||||
|
|
||||||
# Display question and response.
|
# Display question and response.
|
||||||
echo -e "${ANSI_LIGHT_GREEN}Q) ${ANSI_CLEAR_TEXT}${ANSI_LIGHT_BLUE}${DIALOG_TEXT}${ANSI_CLEAR_TEXT} --> ${ANSI_LIGHT_GREEN}${RETURN_STRING}${ANSI_CLEAR_TEXT}"
|
echo -e "${ANSI_LIGHT_GREEN}Q) ${ANSI_CLEAR_TEXT}${ANSI_LIGHT_BLUE}${DIALOG_TEXT}${ANSI_CLEAR_TEXT} --> ${ANSI_LIGHT_GREEN}${RETURN_STRING}${ANSI_CLEAR_TEXT}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function inqChkBx() {
|
function inqChkBx() {
|
||||||
# DECLARE VARIABLES.
|
# DECLARE VARIABLES.
|
||||||
# Variables created from function arguments:
|
# Variables created from function arguments:
|
||||||
declare DIALOG_TEXT="$1" # Dialog heading.
|
declare DIALOG_TEXT="$1" # Dialog heading.
|
||||||
declare INPUT_OPTIONS_VAR="$2" # Input variable name.
|
declare INPUT_OPTIONS_VAR="$2" # Input variable name.
|
||||||
declare RETURN_ARRAY_VAR="$3" # Output variable name.
|
declare RETURN_ARRAY_VAR="$3" # Output variable name.
|
||||||
declare -n INPUT_OPTIONS="$INPUT_OPTIONS_VAR" # Input array nameref.
|
declare -n INPUT_OPTIONS="$INPUT_OPTIONS_VAR" # Input array nameref.
|
||||||
declare -n RETURN_ARRAY="$RETURN_ARRAY_VAR" # Output array nameref.
|
declare -n RETURN_ARRAY="$RETURN_ARRAY_VAR" # Output array nameref.
|
||||||
# Note: namerefs allow changes made through the nameref to affect the
|
# Note: namerefs allow changes made through the nameref to affect the
|
||||||
# referenced variable, even across different scopes like function calls.
|
# referenced variable, even across different scopes like function calls.
|
||||||
|
|
||||||
# Other variables:
|
# Other variables:
|
||||||
declare TRIMMED_OPTIONS=() # Input array post-trimming.
|
declare TRIMMED_OPTIONS=() # Input array post-trimming.
|
||||||
declare PADDED_OPTIONS=() # Input array with extra white space.
|
declare PADDED_OPTIONS=() # Input array with extra white space.
|
||||||
declare DIALOG_OPTIONS=() # Input array for options dialog.
|
declare DIALOG_OPTIONS=() # Input array for options dialog.
|
||||||
declare DIALOG_WIDTH=0 # Width of dialog window.
|
declare DIALOG_WIDTH=0 # Width of dialog window.
|
||||||
declare OPTION_NUMBER=0 # Number of options in dialog window.
|
declare OPTION_NUMBER=0 # Number of options in dialog window.
|
||||||
declare SELECTED_OPTIONS_STRING="" # Output value from dialog window.
|
declare SELECTED_OPTIONS_STRING="" # Output value from dialog window.
|
||||||
|
|
||||||
# MAIN LOGIC.
|
# MAIN LOGIC.
|
||||||
# Trim leading and trailing white space for each option.
|
# Trim leading and trailing white space for each option.
|
||||||
for OPTION in "${INPUT_OPTIONS[@]}"; do
|
for OPTION in "${INPUT_OPTIONS[@]}"; do
|
||||||
TRIMMED_OPTIONS+=("$(echo "$OPTION" | sed 's/^[ \t]*//;s/[ \t]*$//')")
|
TRIMMED_OPTIONS+=("$(echo "$OPTION" | sed 's/^[ \t]*//;s/[ \t]*$//')")
|
||||||
done
|
done
|
||||||
|
|
||||||
# Find the length of the longest option to set the dialog width.
|
# Find the length of the longest option to set the dialog width.
|
||||||
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
||||||
if [ "${#OPTION}" -gt "$DIALOG_WIDTH" ]; then
|
if [ "${#OPTION}" -gt "$DIALOG_WIDTH" ]; then
|
||||||
DIALOG_WIDTH=${#OPTION}
|
DIALOG_WIDTH=${#OPTION}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Apply the offset value to the dialog width.
|
# Apply the offset value to the dialog width.
|
||||||
DIALOG_WIDTH=$((DIALOG_WIDTH + CHK_OPTION_WIDTH_OFFSET))
|
DIALOG_WIDTH=$((DIALOG_WIDTH + CHK_OPTION_WIDTH_OFFSET))
|
||||||
|
|
||||||
# Adjust the dialog width again if the dialog text is longer.
|
# Adjust the dialog width again if the dialog text is longer.
|
||||||
if [ "$DIALOG_WIDTH" -lt $((${#DIALOG_TEXT} + TEXT_WIDTH_OFFSET)) ]; then
|
if [ "$DIALOG_WIDTH" -lt $((${#DIALOG_TEXT} + TEXT_WIDTH_OFFSET)) ]; then
|
||||||
DIALOG_WIDTH="$((${#DIALOG_TEXT} + TEXT_WIDTH_OFFSET))"
|
DIALOG_WIDTH="$((${#DIALOG_TEXT} + TEXT_WIDTH_OFFSET))"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Pad option text with trailing white space to left-align all options.
|
# Pad option text with trailing white space to left-align all options.
|
||||||
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
||||||
local PAD_LENGTH=$((DIALOG_WIDTH - CHK_OPTION_WIDTH_OFFSET - ${#OPTION}))
|
local PAD_LENGTH=$((DIALOG_WIDTH - CHK_OPTION_WIDTH_OFFSET - ${#OPTION}))
|
||||||
# shellcheck disable=SC2155
|
# shellcheck disable=SC2155
|
||||||
local PADDED_OPTION="${OPTION}$(printf '%*s' $PAD_LENGTH)"
|
local PADDED_OPTION="${OPTION}$(printf '%*s' $PAD_LENGTH)"
|
||||||
PADDED_OPTIONS+=("$PADDED_OPTION")
|
PADDED_OPTIONS+=("$PADDED_OPTION")
|
||||||
done
|
done
|
||||||
|
|
||||||
# Convert options into the appropriate format for a 'dialog' checkbox.
|
# Convert options into the appropriate format for a 'dialog' checkbox.
|
||||||
for PADDED_OPTION in "${PADDED_OPTIONS[@]}"; do
|
for PADDED_OPTION in "${PADDED_OPTIONS[@]}"; do
|
||||||
DIALOG_OPTIONS+=("$PADDED_OPTION" "" off)
|
DIALOG_OPTIONS+=("$PADDED_OPTION" "" off)
|
||||||
done
|
done
|
||||||
|
|
||||||
# Store the number of options.
|
# Store the number of options.
|
||||||
OPTION_NUMBER="${#INPUT_OPTIONS[@]}"
|
OPTION_NUMBER="${#INPUT_OPTIONS[@]}"
|
||||||
|
|
||||||
# Produce checkbox.
|
# Produce checkbox.
|
||||||
# The output string contains options delimited by spaces.
|
# The output string contains options delimited by spaces.
|
||||||
# Each option is enclosed in double quotes within the output string.
|
# Each option is enclosed in double quotes within the output string.
|
||||||
# For example: '"Option 1 " "The Second Option " " Option Number 3 "'
|
# For example: '"Option 1 " "The Second Option " " Option Number 3 "'
|
||||||
SELECTED_OPTIONS_STRING=$(dialog \
|
SELECTED_OPTIONS_STRING=$(dialog \
|
||||||
--keep-tite \
|
--keep-tite \
|
||||||
--clear \
|
--clear \
|
||||||
--no-shadow \
|
--no-shadow \
|
||||||
--checklist \
|
--checklist \
|
||||||
"$DIALOG_TEXT" \
|
"$DIALOG_TEXT" \
|
||||||
"$DIALOG_HEIGHT" \
|
"$DIALOG_HEIGHT" \
|
||||||
"$DIALOG_WIDTH" \
|
"$DIALOG_WIDTH" \
|
||||||
"$OPTION_NUMBER" \
|
"$OPTION_NUMBER" \
|
||||||
"${DIALOG_OPTIONS[@]}" \
|
"${DIALOG_OPTIONS[@]}" \
|
||||||
2>&1 >/dev/tty) || exit 0
|
2>&1 >/dev/tty) || exit 0
|
||||||
|
|
||||||
# Convert the output string into an array.
|
# Convert the output string into an array.
|
||||||
# shellcheck disable=SC2001
|
# shellcheck disable=SC2001
|
||||||
while IFS= read -r LINE; do
|
while IFS= read -r LINE; do
|
||||||
LINE="${LINE/#\"/}" # Remove leading double quote.
|
LINE="${LINE/#\"/}" # Remove leading double quote.
|
||||||
LINE="${LINE/%\"/}" # Remove trailing double quote.
|
LINE="${LINE/%\"/}" # Remove trailing double quote.
|
||||||
RETURN_ARRAY+=("$LINE") # Add to array.
|
RETURN_ARRAY+=("$LINE") # Add to array.
|
||||||
done < <(echo "$SELECTED_OPTIONS_STRING" | sed 's/\" \"/\"\n\"/g')
|
done < <(echo "$SELECTED_OPTIONS_STRING" | sed 's/\" \"/\"\n\"/g')
|
||||||
|
|
||||||
# Final modifications.
|
# Final modifications.
|
||||||
for ((i = 0; i < ${#RETURN_ARRAY[@]}; i++)); do
|
for ((i = 0; i < ${#RETURN_ARRAY[@]}; i++)); do
|
||||||
# Remove white space added previously.
|
# Remove white space added previously.
|
||||||
# shellcheck disable=SC2001
|
# shellcheck disable=SC2001
|
||||||
RETURN_ARRAY[i]=$(echo "${RETURN_ARRAY[i]}" |
|
RETURN_ARRAY[i]=$(echo "${RETURN_ARRAY[i]}" |
|
||||||
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||||
|
|
||||||
# Remove escapes (introduced by 'dialog' if options have parentheses).
|
# Remove escapes (introduced by 'dialog' if options have parentheses).
|
||||||
RETURN_ARRAY[i]=${RETURN_ARRAY[i]//\\/} # ${variable//search/replace}
|
RETURN_ARRAY[i]=${RETURN_ARRAY[i]//\\/} # ${variable//search/replace}
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
1818
installer.sh
1818
installer.sh
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user