[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-07-15 21:03:11 +00:00
parent fb1c3f4805
commit a3ed167291
4 changed files with 1265 additions and 1273 deletions

View File

@ -44,15 +44,12 @@ else
fi
if [ -z "${FREERDP_COMMAND}" ]; then
if command -v xfreerdp &> /dev/null
then
if command -v xfreerdp &>/dev/null; then
FREERDP_COMMAND="xfreerdp"
elif command -v xfreerdp3 &> /dev/null
then
elif command -v xfreerdp3 &>/dev/null; then
FREERDP_COMMAND="xfreerdp3"
fi
elif command -v "$FREERDP_COMMAND" &> /dev/null
then
elif command -v "$FREERDP_COMMAND" &>/dev/null; then
dprint "Using custom freerdp command $FREERDP_COMMAND"
else
echo "You have supplied a custom FreeRDP command, but the command is not available."
@ -86,7 +83,7 @@ if [ "$MULTIMON" = "true" ]; then
fi
# Append additional flags or parameters to FreeRDP
if [[ -n "$RDP_FLAGS" ]]; then
if [[ -n $RDP_FLAGS ]]; then
FREERDP_COMMAND="$FREERDP_COMMAND $RDP_FLAGS"
fi
@ -120,7 +117,7 @@ elif [ "$1" = "windows" ]; then
"+dynamic-resolution"
"+auto-reconnect"
"+home-drive"
"/wm-class:\"Microsoft Windows\""
'/wm-class:"Microsoft Windows"'
"/v:${RDP_IP}"
)
# Run the command in the background, redirecting both stdout and stderr to /dev/null

View File

@ -83,7 +83,7 @@ function inqMenu() {
2>&1 >/dev/tty) || exit 0
# Remove white space added previously.
RETURN_STRING=$(echo "$SELECTED_OPTIONS_STRING" | \
RETURN_STRING=$(echo "$SELECTED_OPTIONS_STRING" |
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
# Remove escapes (introduced by 'dialog' if options have parentheses).
@ -168,8 +168,8 @@ function inqChkBx() {
# Convert the output string into an array.
# shellcheck disable=SC2001
while IFS= read -r LINE; do
LINE="${LINE/#\"}" # Remove leading double quote.
LINE="${LINE/%\"}" # Remove trailing double quote.
LINE="${LINE/#\"/}" # Remove leading double quote.
LINE="${LINE/%\"/}" # Remove trailing double quote.
RETURN_ARRAY+=("$LINE") # Add to array.
done < <(echo "$SELECTED_OPTIONS_STRING" | sed 's/\" \"/\"\n\"/g')
@ -177,7 +177,7 @@ function inqChkBx() {
for ((i = 0; i < ${#RETURN_ARRAY[@]}; i++)); do
# Remove white space added previously.
# shellcheck disable=SC2001
RETURN_ARRAY[i]=$(echo "${RETURN_ARRAY[i]}" | \
RETURN_ARRAY[i]=$(echo "${RETURN_ARRAY[i]}" |
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
# Remove escapes (introduced by 'dialog' if options have parentheses).

View File

@ -33,15 +33,15 @@ readonly EC_APPQUERY_FAIL="14" # Failed to query the Windows VM for in
# 'BIN'
readonly SYS_BIN_PATH="/usr/local/bin" # UNIX path to 'bin' directory for a '--system' WinApps installation.
readonly USER_BIN_PATH="${HOME}/.local/bin" # UNIX path to 'bin' directory for a '--user' WinApps installation.
readonly USER_BIN_PATH_WIN="\\\\tsclient\\home\\.local\\bin" # WINDOWS path to 'bin' directory for a '--user' WinApps installation.
readonly USER_BIN_PATH_WIN='\\tsclient\home\.local\bin' # WINDOWS path to 'bin' directory for a '--user' WinApps installation.
# 'APP'
readonly SYS_APP_PATH="/usr/share/applications" # UNIX path to 'applications' directory for a '--system' WinApps installation.
readonly USER_APP_PATH="${HOME}/.local/share/applications" # UNIX path to 'applications' directory for a '--user' WinApps installation.
readonly USER_APP_PATH_WIN="\\\\tsclient\\home\\.local\\share\\applications" # WINDOWS oath to 'applications' directory for a '--user' WinApps installation.
readonly USER_APP_PATH_WIN='\\tsclient\home\.local\share\applications' # WINDOWS oath to 'applications' directory for a '--user' WinApps installation.
# 'APPDATA'
readonly SYS_APPDATA_PATH="/usr/local/share/winapps" # UNIX path to 'application data' directory for a '--system' WinApps installation.
readonly USER_APPDATA_PATH="${HOME}/.local/share/winapps" # UNIX path to 'application data' directory for a '--user' WinApps installation.
readonly USER_APPDATA_PATH_WIN="\\\\tsclient\\home\\.local\\share\\winapps" # WINDOWS path to 'application data' directory for a '--user' WinApps installation.
readonly USER_APPDATA_PATH_WIN='\\tsclient\home\.local\share\winapps' # WINDOWS path to 'application data' directory for a '--user' WinApps installation.
# 'Installed Batch Script'
readonly BATCH_SCRIPT_PATH="${USER_APPDATA_PATH}/installed.bat" # UNIX path to a batch script used to search the Windows VM for applications.
readonly BATCH_SCRIPT_PATH_WIN="${USER_APPDATA_PATH_WIN}\\installed.bat" # WINDOWS path to a batch script used to search the Windows VM for applications.
@ -68,16 +68,15 @@ readonly INQUIRER_PATH="./install/inquirer.sh"
# REMOTE DESKTOP CONFIGURATION
readonly VM_NAME="RDPWindows" # Name of the Windows VM.
readonly RDP_PORT=3389 # Port used for RDP on the Windows VM.
readonly WINAPPS_CONFIG="\
RDP_USER=\"MyWindowsUser\"
RDP_PASS=\"MyWindowsPassword\"
#RDP_DOMAIN=\"MYDOMAIN\"
#RDP_IP=\"192.168.123.111\"
readonly WINAPPS_CONFIG='RDP_USER="MyWindowsUser"
RDP_PASS="MyWindowsPassword"
#RDP_DOMAIN="MYDOMAIN"
#RDP_IP="192.168.123.111"
#RDP_SCALE=100
#RDP_FLAGS=\"\"
#MULTIMON=\"true\"
#DEBUG=\"true\"
#FREERDP_COMMAND=\"xfreerdp\"" # Default WinApps configuration file content.
#RDP_FLAGS=""
#MULTIMON="true"
#DEBUG="true"
#FREERDP_COMMAND="xfreerdp"' # Default WinApps configuration file content.
### GLOBAL VARIABLES ###
# USER INPUT
@ -219,7 +218,7 @@ function waCheckInput() {
inqMenu "Install or uninstall WinApps?" OPTIONS SELECTED_OPTION
# Set flags.
if [[ "$SELECTED_OPTION" == "Uninstall" ]]; then
if [[ $SELECTED_OPTION == "Uninstall" ]]; then
OPT_UNINSTALL=1
fi
@ -228,9 +227,9 @@ function waCheckInput() {
inqMenu "Configure WinApps for the current user '$(whoami)' or the whole system?" OPTIONS SELECTED_OPTION
# Set flags.
if [[ "$SELECTED_OPTION" == "Current User" ]]; then
if [[ $SELECTED_OPTION == "Current User" ]]; then
OPT_USER=1
elif [[ "$SELECTED_OPTION" == "System" ]]; then
elif [[ $SELECTED_OPTION == "System" ]]; then
OPT_SYSTEM=1
fi
@ -240,7 +239,7 @@ function waCheckInput() {
inqMenu "Automatically install supported applications or choose manually?" OPTIONS SELECTED_OPTION
# Set flags.
if [[ "$SELECTED_OPTION" == "Automatic" ]]; then
if [[ $SELECTED_OPTION == "Automatic" ]]; then
OPT_AOSA=1
fi
fi
@ -571,7 +570,7 @@ function waCheckVMRunning() {
# Obtain VM Status
VM_STATE=$(virsh list --all | grep -w "$VM_NAME")
if [[ "$VM_STATE" == *"shut off"* ]]; then
if [[ $VM_STATE == *"shut off"* ]]; then
# Complete the previous line.
echo -e "${FAIL_TEXT}Failed!${CLEAR_TEXT}\n"
@ -589,7 +588,7 @@ function waCheckVMRunning() {
# Terminate the script.
return "$EC_VM_OFF"
elif [[ "$VM_STATE" == *"paused"* ]]; then
elif [[ $VM_STATE == *"paused"* ]]; then
# Complete the previous line.
echo -e "${FAIL_TEXT}Failed!${CLEAR_TEXT}\n"
@ -607,7 +606,7 @@ function waCheckVMRunning() {
# Terminate the script.
return "$EC_VM_PAUSED"
elif [[ "$VM_STATE" != *"running"* ]]; then
elif [[ $VM_STATE != *"running"* ]]; then
# Complete the previous line.
echo -e "${FAIL_TEXT}Failed!${CLEAR_TEXT}\n"
@ -723,9 +722,7 @@ function waCheckRDPAccess() {
+home-drive \
-wallpaper \
+dynamic-resolution \
/app:\
program:"C:\Windows\System32\cmd.exe",\
cmd:"/C type NUL > "$TEST_PATH_WIN" && tsdiscon" \
/app:program:"C:\Windows\System32\cmd.exe",cmd:"/C type NUL > "$TEST_PATH_WIN" && tsdiscon" \
/v:"$RDP_IP" &>"$FREERDP_LOG" &
# Store the FreeRDP process ID.
@ -853,9 +850,7 @@ function waFindInstalled() {
+home-drive \
-wallpaper \
+dynamic-resolution \
/app:\
program:"C:\Windows\System32\cmd.exe",\
cmd:"/C "$BATCH_SCRIPT_PATH_WIN"" \
/app:program:"C:\Windows\System32\cmd.exe",cmd:"/C "$BATCH_SCRIPT_PATH_WIN"" \
/v:"$RDP_IP" &>"$FREERDP_LOG" &
# Store the FreeRDP process ID.
@ -1080,7 +1075,7 @@ function waConfigureApps() {
inqMenu "How would you like to handle officially supported applications?" OPTIONS APP_INSTALL
# Remove unselected officially supported applications from the 'install' file.
if [[ "$APP_INSTALL" == "Choose specific officially supported applications to set up" ]]; then
if [[ $APP_INSTALL == "Choose specific officially supported applications to set up" ]]; then
inqChkBx "Which officially supported applications would you like to set up?" APPS SELECTED_APPS
# Clear/create the 'install' file.
@ -1099,7 +1094,7 @@ function waConfigureApps() {
fi
# Configure selected (or all) officially supported applications.
if [[ "$APP_INSTALL" != "Skip setting up any officially supported applications" ]]; then
if [[ $APP_INSTALL != "Skip setting up any officially supported applications" ]]; then
waConfigureOfficiallySupported
fi
}
@ -1143,7 +1138,7 @@ function waConfigureDetectedApps() {
EXE_FILENAME_NOEXT="${EXE_FILENAME%.*}"
# Check if the executable was previously configured as part of setting up officially supported applications.
if [[ ! " ${INSTALLED_EXES[*]} " == *" ${EXE_FILENAME_LOWERCASE} "* ]]; then
if [[ " ${INSTALLED_EXES[*]} " != *" ${EXE_FILENAME_LOWERCASE} "* ]]; then
# If not previously configured, add the application to the list of detected applications.
APPS+=("${NAMES[$INDEX]} (${EXE_FILENAME_NOEXT})")
fi
@ -1165,9 +1160,9 @@ function waConfigureDetectedApps() {
inqMenu "How would you like to handle other detected applications?" OPTIONS APP_INSTALL
# Store selected detected applications.
if [[ "$APP_INSTALL" == "Select which applications to set up" ]]; then
if [[ $APP_INSTALL == "Select which applications to set up" ]]; then
inqChkBx "Which other applications would you like to set up?" APPS SELECTED_APPS
elif [[ "$APP_INSTALL" == "Set up all detected applications" ]]; then
elif [[ $APP_INSTALL == "Set up all detected applications" ]]; then
readarray -t SELECTED_APPS <<<"${APPS[@]}"
fi
@ -1184,7 +1179,7 @@ function waConfigureDetectedApps() {
# Loop through all detected applications to find the detected application being processed.
for INDEX in "${!NAMES[@]}"; do
# Check for a matching detected application entry.
if [[ "${NAMES[$INDEX]}" == "$PROGRAM_NAME" ]] && [[ "${EXES[$INDEX]}" == *"\\$EXE_FILENAME_NOEXT"* ]]; then
if [[ ${NAMES[$INDEX]} == "$PROGRAM_NAME" ]] && [[ ${EXES[$INDEX]} == *"\\$EXE_FILENAME_NOEXT"* ]]; then
# Print feedback.
echo -n "Creating an application entry for ${PROGRAM_NAME}... "
@ -1237,14 +1232,14 @@ function waInstall() {
waCheckDependencies
# Update $MULTI_FLAG.
if [[ "$MULTIMON" == "true" ]]; then
if [[ $MULTIMON == "true" ]]; then
MULTI_FLAG="/multimon"
else
MULTI_FLAG="+span"
fi
# Append additional FreeRDP flags if required.
if [[ -n "$RDP_FLAGS" ]]; then
if [[ -n $RDP_FLAGS ]]; then
FREERDP_COMMAND="${FREERDP_COMMAND} ${RDP_FLAGS}"
fi