From 8f0021d01691a261d2e4055bdc46e43e0a696889 Mon Sep 17 00:00:00 2001 From: Fmstrat Date: Fri, 13 Nov 2020 13:13:32 -0500 Subject: [PATCH] Updated installer for user vs system mode --- README.md | 29 +++++++++++--- install.sh => installer.sh | 77 ++++++++++++++++++++++++++++++++++---- 2 files changed, 92 insertions(+), 14 deletions(-) rename install.sh => installer.sh (68%) diff --git a/README.md b/README.md index b0b9759..2fad1f9 100644 --- a/README.md +++ b/README.md @@ -157,10 +157,10 @@ You will see output from FreeRDP, as well as potentially have to accept the init Then the final step is to run the installer: ``` bash -$ ./install.sh -[sudo] password for fmstrat: +$ ./installer.sh --user +Removing any old configurations... Installing... - Checking for installed apps in RDP machine... + Checking for installed apps in RDP machine (this may take a while)... Finished. Configuring Excel... Finished. Configuring PowerPoint... Finished. Configuring Word... Finished. @@ -209,10 +209,18 @@ WinApps offers a manual mode for running applications that are not configured. T The installer can be run multiple times, so simply run: ``` bash $ git pull -$ ./install.sh -[sudo] password for fmstrat: +$ ./installer.sh --user +Removing any old configurations... + Removing /home/fmstrat/.local/share/applications/excel.desktop... Finished. + Removing /home/fmstrat/.local/share/applications/powerpoint.desktop... Finished. + Removing /home/fmstrat/.local/share/applications/windows.desktop... Finished. + Removing /home/fmstrat/.local/share/applications/word.desktop... Finished. + Removing /home/fmstrat/.local/bin/excel... Finished. + Removing /home/fmstrat/.local/bin/powerpoint... Finished. + Removing /home/fmstrat/.local/bin/windows... Finished. + Removing /home/fmstrat/.local/bin/word... Finished. Installing... - Checking for installed apps in RDP machine... + Checking for installed apps in RDP machine (this may take a while)... Finished. Configuring Excel... Finished. Configuring PowerPoint... Finished. Configuring Word... Finished. @@ -220,6 +228,15 @@ Installing... Installation complete. ``` +## Installer usage +The following commands can be used to manage your application configurations: +``` bash +./installer.sh --user # Configure applications for the current user +./installer.sh --system # Configure applications for the entire system +./installer.sh --user --uninstall # Remove all configured applications for the current user +./installer.sh --system --uninstall # Remove all configured applications for the entire system +``` + ## Shout outs - Some icons pulled from - Fluent UI React - Icons under [MIT License](https://github.com/Fmstrat/fluent-ui-react/blob/master/LICENSE.md) diff --git a/install.sh b/installer.sh similarity index 68% rename from install.sh rename to installer.sh index 9dd8cb8..0a2c3ff 100755 --- a/install.sh +++ b/installer.sh @@ -2,11 +2,16 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - function waUsage() { echo 'Usage: - ./install.sh --user # Install everything in ${HOME} - ./install.sh --system # Install everything in /usr' + ./installer.sh --user # Install everything in ${HOME} + ./installer.sh --system # Install everything in /usr' + exit +} + +function waNoSudo() { + echo 'You are attempting to switch from a --system install to a --user install. +Please run "./installer.sh --system --uninstall" first.' exit } @@ -15,7 +20,7 @@ function waInstall() { } function waFindInstalled() { - echo -n " Checking for installed apps in RDP machine..." + echo -n " Checking for installed apps in RDP machine (this may take a while)..." rm -f ${HOME}/.local/share/winapps/installed.bat rm -f ${HOME}/.local/share/winapps/installed for F in $(ls "${DIR}/apps"); do @@ -25,13 +30,13 @@ function waFindInstalled() { echo "ECHO DONE >> \\\\tsclient\\home\\.local\\share\\winapps\\installed" >> ${HOME}/.local/share/winapps/installed.bat touch ${HOME}/.local/share/winapps/installed LAST_RAN=$(stat -t -c %Y ${HOME}/.local/share/winapps/installed) - sleep 6 + sleep 15 xfreerdp /d:"${RDP_DOMAIN}" /u:"${RDP_USER}" /p:"${RDP_PASS}" /v:${RDP_IP} +auto-reconnect +home-drive -wallpaper /span /wm-class:"RDPInstaller" /app:"C:\Windows\System32\cmd.exe" /app-icon:"${DIR}/../icons/windows.svg" /app-cmd:"/C \\\\tsclient\\home\\.local\\share\\winapps\\installed.bat" 1> /dev/null 2>&1 & - sleep 6 + sleep 15 COUNT=0 THIS_RUN=$(stat -t -c %Y ${HOME}/.local/share/winapps/installed) while (( $THIS_RUN - $LAST_RAN < 5 )); do - sleep 5 + sleep 15 THIS_RUN=$(stat -t -c %Y ${HOME}/.local/share/winapps/installed) COUNT=$((COUNT + 1)) if (( COUNT == 5 )); then @@ -65,7 +70,7 @@ MimeType=${MIME_TYPES} ${SUDO} rm -f "${BIN_PATH}/${F}" echo "#!/usr/bin/env bash ${DIR}/bin/winapps ${F} $@ -" |${SUDO} tee "/usr/local/bin/${F}" > /dev/null +" |${SUDO} tee "${BIN_PATH}/${F}" > /dev/null ${SUDO} chmod a+x "${BIN_PATH}/${F}" echo " Finished." fi @@ -98,21 +103,77 @@ ${DIR}/bin/winapps windows echo " Finished." } +function waUninstallUser() { + for F in $(grep -l -d skip "bin/winapps" "${HOME}/.local/share/applications/"*); do + echo -n " Removing ${F}..." + ${SUDO} rm ${F} + echo " Finished." + done + for F in $(grep -l -d skip "bin/winapps" "${HOME}/.local/bin/"*); do + echo -n " Removing ${F}..." + ${SUDO} rm ${F} + echo " Finished." + done +} + +function waUninstallSystem() { + for F in $(grep -l -d skip "bin/winapps" "/usr/share/applications/"*); do + if [ -z "${SUDO}" ]; then + waNoSudo + fi + echo -n " Removing ${F}..." + ${SUDO} rm ${F} + echo " Finished." + done + for F in $(grep -l -d skip "bin/winapps" "/usr/local/bin/"*); do + if [ -z "${SUDO}" ]; then + waNoSudo + fi + echo -n " Removing ${F}..." + ${SUDO} rm ${F} + echo " Finished." + done +} + if [ -z "${1}" ]; then waUsage elif [ "${1}" = '--user' ]; then SUDO="" BIN_PATH="${HOME}/.local/bin" APP_PATH="${HOME}/.local/share/applications" + if [ -n "${2}" ]; then + if [ "${2}" = '--uninstall' ]; then + # Uninstall + echo "Uninstalling..." + waUninstallUser + exit + else + usage + fi + fi elif [ "${1}" = '--system' ]; then SUDO="sudo" sudo ls > /dev/null BIN_PATH="/usr/local/bin" APP_PATH="/usr/share/applications" + if [ -n "${2}" ]; then + if [ "${2}" = '--uninstall' ]; then + # Uninstall + echo "Uninstalling..." + waUninstallSystem + exit + else + usage + fi + fi else waUsage fi +echo "Removing any old configurations..." +waUninstallUser +waUninstallSystem + echo "Installing..." # Inititialize