mirror of
https://github.com/winapps-org/winapps.git
synced 2025-06-03 21:57:18 +02:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
fb1c3f4805
commit
a3ed167291
13
bin/winapps
13
bin/winapps
@ -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
|
||||
|
@ -71,19 +71,19 @@ function inqMenu() {
|
||||
# Each option is enclosed in double quotes within the output string.
|
||||
# For example: '"Option 1 " "The Second Option " " Option Number 3 "'
|
||||
SELECTED_OPTIONS_STRING=$(dialog \
|
||||
--keep-tite \
|
||||
--clear \
|
||||
--no-shadow \
|
||||
--menu \
|
||||
"$DIALOG_TEXT" \
|
||||
"$DIALOG_HEIGHT" \
|
||||
"$DIALOG_WIDTH" \
|
||||
"$OPTION_NUMBER" \
|
||||
"${DIALOG_OPTIONS[@]}" \
|
||||
2>&1 >/dev/tty) || exit 0
|
||||
--keep-tite \
|
||||
--clear \
|
||||
--no-shadow \
|
||||
--menu \
|
||||
"$DIALOG_TEXT" \
|
||||
"$DIALOG_HEIGHT" \
|
||||
"$DIALOG_WIDTH" \
|
||||
"$OPTION_NUMBER" \
|
||||
"${DIALOG_OPTIONS[@]}" \
|
||||
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).
|
||||
@ -154,30 +154,30 @@ function inqChkBx() {
|
||||
# Each option is enclosed in double quotes within the output string.
|
||||
# For example: '"Option 1 " "The Second Option " " Option Number 3 "'
|
||||
SELECTED_OPTIONS_STRING=$(dialog \
|
||||
--keep-tite \
|
||||
--clear \
|
||||
--no-shadow \
|
||||
--checklist \
|
||||
"$DIALOG_TEXT" \
|
||||
"$DIALOG_HEIGHT" \
|
||||
"$DIALOG_WIDTH" \
|
||||
"$OPTION_NUMBER" \
|
||||
"${DIALOG_OPTIONS[@]}" \
|
||||
2>&1 >/dev/tty) || exit 0
|
||||
--keep-tite \
|
||||
--clear \
|
||||
--no-shadow \
|
||||
--checklist \
|
||||
"$DIALOG_TEXT" \
|
||||
"$DIALOG_HEIGHT" \
|
||||
"$DIALOG_WIDTH" \
|
||||
"$OPTION_NUMBER" \
|
||||
"${DIALOG_OPTIONS[@]}" \
|
||||
2>&1 >/dev/tty) || exit 0
|
||||
|
||||
# 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')
|
||||
|
||||
# Final modifications.
|
||||
for (( i=0; i<${#RETURN_ARRAY[@]}; i++ )); do
|
||||
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).
|
||||
|
113
installer.sh
113
installer.sh
@ -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"
|
||||
|
||||
@ -714,19 +713,17 @@ function waCheckRDPAccess() {
|
||||
# [INFO][com.freerdp.core] - [rdp_print_errinfo]: ERRINFO_LOGOFF_BY_USER (0x0000000C):The disconnection was initiated by the user logging off their session on the server.
|
||||
# shellcheck disable=SC2140,SC2027 # Disable warnings regarding unquoted strings.
|
||||
"$FREERDP_COMMAND" \
|
||||
/cert:tofu \
|
||||
/d:"$RDP_DOMAIN" \
|
||||
/u:"$RDP_USER" \
|
||||
/p:"$RDP_PASS" \
|
||||
/scale:"$RDP_SCALE" \
|
||||
+auto-reconnect \
|
||||
+home-drive \
|
||||
-wallpaper \
|
||||
+dynamic-resolution \
|
||||
/app:\
|
||||
program:"C:\Windows\System32\cmd.exe",\
|
||||
cmd:"/C type NUL > "$TEST_PATH_WIN" && tsdiscon" \
|
||||
/v:"$RDP_IP" &>"$FREERDP_LOG" &
|
||||
/cert:tofu \
|
||||
/d:"$RDP_DOMAIN" \
|
||||
/u:"$RDP_USER" \
|
||||
/p:"$RDP_PASS" \
|
||||
/scale:"$RDP_SCALE" \
|
||||
+auto-reconnect \
|
||||
+home-drive \
|
||||
-wallpaper \
|
||||
+dynamic-resolution \
|
||||
/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.
|
||||
FREERDP_PROC=$!
|
||||
@ -826,37 +823,35 @@ function waFindInstalled() {
|
||||
source "./apps/${APPLICATION}/info"
|
||||
|
||||
# Append commands to batch file.
|
||||
echo "IF EXIST \"${WIN_EXECUTABLE}\" ECHO ${APPLICATION} >> ${TMP_INST_FILE_PATH_WIN}" >> "$BATCH_SCRIPT_PATH"
|
||||
echo "IF EXIST \"${WIN_EXECUTABLE}\" ECHO ${APPLICATION} >> ${TMP_INST_FILE_PATH_WIN}" >>"$BATCH_SCRIPT_PATH"
|
||||
done
|
||||
|
||||
# Append a command to the batch script to run the PowerShell script and store it's output in the 'detected' file.
|
||||
# shellcheck disable=SC2129 # Silence warning regarding repeated redirects.
|
||||
echo "powershell.exe -ExecutionPolicy Bypass -File ${PS_SCRIPT_HOME_PATH_WIN} > ${DETECTED_FILE_PATH_WIN}" >> "$BATCH_SCRIPT_PATH"
|
||||
echo "powershell.exe -ExecutionPolicy Bypass -File ${PS_SCRIPT_HOME_PATH_WIN} > ${DETECTED_FILE_PATH_WIN}" >>"$BATCH_SCRIPT_PATH"
|
||||
|
||||
# Append a command to the batch script to rename the temporary file containing the names of all detected officially supported applications.
|
||||
echo "RENAME ${TMP_INST_FILE_PATH_WIN} installed" >> "$BATCH_SCRIPT_PATH"
|
||||
echo "RENAME ${TMP_INST_FILE_PATH_WIN} installed" >>"$BATCH_SCRIPT_PATH"
|
||||
|
||||
# Append a command to the batch script to terminate the remote desktop session once all previous commands are complete.
|
||||
echo "tsdiscon" >> "$BATCH_SCRIPT_PATH"
|
||||
echo "tsdiscon" >>"$BATCH_SCRIPT_PATH"
|
||||
|
||||
# Silently execute the batch script within the Windows VM in the background (Log Output To File)
|
||||
# Note: The following final line is expected within the log, indicating successful execution of the 'tsdiscon' command and termination of the RDP session.
|
||||
# [INFO][com.freerdp.core] - [rdp_print_errinfo]: ERRINFO_LOGOFF_BY_USER (0x0000000C):The disconnection was initiated by the user logging off their session on the server.
|
||||
# shellcheck disable=SC2140,SC2027 # Disable warnings regarding unquoted strings.
|
||||
"$FREERDP_COMMAND" \
|
||||
/cert:tofu \
|
||||
/d:"$RDP_DOMAIN" \
|
||||
/u:"$RDP_USER" \
|
||||
/p:"$RDP_PASS" \
|
||||
/scale:"$RDP_SCALE" \
|
||||
+auto-reconnect \
|
||||
+home-drive \
|
||||
-wallpaper \
|
||||
+dynamic-resolution \
|
||||
/app:\
|
||||
program:"C:\Windows\System32\cmd.exe",\
|
||||
cmd:"/C "$BATCH_SCRIPT_PATH_WIN"" \
|
||||
/v:"$RDP_IP" &>"$FREERDP_LOG" &
|
||||
/cert:tofu \
|
||||
/d:"$RDP_DOMAIN" \
|
||||
/u:"$RDP_USER" \
|
||||
/p:"$RDP_PASS" \
|
||||
/scale:"$RDP_SCALE" \
|
||||
+auto-reconnect \
|
||||
+home-drive \
|
||||
-wallpaper \
|
||||
+dynamic-resolution \
|
||||
/app:program:"C:\Windows\System32\cmd.exe",cmd:"/C "$BATCH_SCRIPT_PATH_WIN"" \
|
||||
/v:"$RDP_IP" &>"$FREERDP_LOG" &
|
||||
|
||||
# Store the FreeRDP process ID.
|
||||
FREERDP_PROC=$!
|
||||
@ -1058,7 +1053,7 @@ function waConfigureApps() {
|
||||
WIN_EXECUTABLE="${WIN_EXECUTABLE##*\\}"
|
||||
|
||||
# Trim any leading or trailing whitespace characters from the executable file name.
|
||||
read -r WIN_EXECUTABLE <<< "$(echo "$WIN_EXECUTABLE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
||||
read -r WIN_EXECUTABLE <<<"$(echo "$WIN_EXECUTABLE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
||||
|
||||
# Add the executable file name (in lowercase) to the array.
|
||||
INSTALLED_EXES+=("${WIN_EXECUTABLE,,}")
|
||||
@ -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.
|
||||
@ -1094,12 +1089,12 @@ function waConfigureApps() {
|
||||
SELECTED_APP="${SELECTED_APP%%)}"
|
||||
|
||||
# Add the substring back to the 'install' file.
|
||||
echo "$SELECTED_APP" >> "$INST_FILE_PATH"
|
||||
echo "$SELECTED_APP" >>"$INST_FILE_PATH"
|
||||
done
|
||||
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user