Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install PWA app on MACOS thru a script (final use on intune) #274

Closed
adminsoho opened this issue Aug 19, 2024 · 3 comments
Closed

Install PWA app on MACOS thru a script (final use on intune) #274

adminsoho opened this issue Aug 19, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@adminsoho
Copy link

adminsoho commented Aug 19, 2024

I am trying to run this script with no success to install on MACOS a PWA app for Microsoft Edge. The final use is for Intune to push PWA apps to end macos users on company.

Objective is that this PWA appears on MS Edge as an installed app and execute as such (an PWA app). I added some extras, as create dock shortcut, install brew if not exists and logs.

Problem: This script does not achieve to install a PWA on MS Edge, I have been searching a lot and not found info on installing PWA somehow to endusers on a company using intune.

Please see examples below of what this script is acheaving and a real installed PWA app.

Properly installed:
Captura de pantalla 2024-08-18 a la(s) 9 35 36 p  m

This script (opening tab as new tab):
Captura de pantalla 2024-08-18 a la(s) 9 35 51 p  m

Extras on my script:

  • Dockutil to make shortcut
  • Homebrew if dockutil is not installed
  • Log to intune default folder
  • Yummly as url to install PWA (no relation to that business, just an example)

The script:
`#!/bin/bash

Define variables

PWA_URL="https://www.yummly.com"
EDGE_PATH="/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
INSTALL_BASE_DIR="/Users/$USER/Applications/Edge Apps.localized"
LOG_DIR="/var/log"
LOG_FILE="$LOG_DIR/pwa_installation.log"

Function to get the PWA app name from the Edge window title

get_app_name() {
osascript <<EOF
tell application "Microsoft Edge"
activate
set windowTitle to name of front window
end tell
return windowTitle
EOF
}

Start logging

echo "Iniciando el script de instalación..." | tee -a "$LOG_FILE"

Check if Microsoft Edge is installed

if [ ! -f "$EDGE_PATH" ]; then
echo "Error: Microsoft Edge no está instalado en $EDGE_PATH." | tee -a "$LOG_FILE"
exit 1
fi

Create the installation directory if it does not exist

mkdir -p "$INSTALL_BASE_DIR"

Open the PWA URL in Edge

echo "Abriendo el PWA en Microsoft Edge..." | tee -a "$LOG_FILE"
"$EDGE_PATH" --app="$PWA_URL" --no-first-run --no-default-browser-check

Wait for a bit to allow Edge to open and load the PWA

sleep 20

Get the app name from Edge window title

APP_NAME=$(get_app_name)
if [ -z "$APP_NAME" ]; then
echo "Error: No se pudo obtener el nombre de la aplicación." | tee -a "$LOG_FILE"
exit 1
fi

echo "Nombre de la aplicación obtenido: $APP_NAME" | tee -a "$LOG_FILE"

Wait to allow PWA installation to complete

echo "Esperando a que se complete la instalación de la PWA..." | tee -a "$LOG_FILE"
sleep 60

Log the content of the installation directory

echo "Contenido del directorio de instalación:" | tee -a "$LOG_FILE"
ls -la "$INSTALL_BASE_DIR" | tee -a "$LOG_FILE"

Determine the location of the installed .app

APP_PATH=$(find "$INSTALL_BASE_DIR" -name "$APP_NAME.app" -print -quit)

Check if the PWA was installed successfully

if [ -z "$APP_PATH" ]; then
echo "Error: La instalación de la PWA falló o $APP_NAME no se encontró en $INSTALL_BASE_DIR." | tee -a "$LOG_FILE"
exit 1
else
echo "$APP_NAME se instaló correctamente en $APP_PATH." | tee -a "$LOG_FILE"
fi

Check if Homebrew is installed

if ! command -v brew &> /dev/null; then
echo "Homebrew no está instalado. Intentando instalar Homebrew..." | tee -a "$LOG_FILE"

# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Verify Homebrew installation
if ! command -v brew &> /dev/null; then
    echo "Error: No se pudo instalar Homebrew." | tee -a "$LOG_FILE"
    exit 1
else
    echo "Homebrew se instaló correctamente." | tee -a "$LOG_FILE"
fi

else
echo "Homebrew ya está instalado." | tee -a "$LOG_FILE"
fi

Check if dockutil is installed

if ! command -v dockutil &> /dev/null; then
echo "dockutil no está instalado. Intentando instalar dockutil..." | tee -a "$LOG_FILE"

# Install dockutil using Homebrew
brew install dockutil
if [ $? -ne 0 ]; then
    echo "Error: No se pudo instalar dockutil." | tee -a "$LOG_FILE"
    exit 1
else
    echo "dockutil se instaló correctamente." | tee -a "$LOG_FILE"
fi

else
echo "dockutil ya está instalado." | tee -a "$LOG_FILE"
fi

Add the application to the Dock if it's not already present

if ! dockutil --find "$APP_PATH" &> /dev/null; then
echo "Añadiendo $APP_NAME al Dock..." | tee -a "$LOG_FILE"
dockutil --add "$APP_PATH" --no-restart
killall Dock
else
echo "$APP_NAME ya está en el Dock." | tee -a "$LOG_FILE"
fi

echo "Instalación completada." | tee -a "$LOG_FILE"`

@adminsoho adminsoho added the bug Something isn't working label Aug 19, 2024
@captainbrosset
Copy link
Contributor

Thanks for filing and providing these details. However this repository is specific to DevTools. DevTools is a developer feature in Edge which is unrelated to PWAs and how they get installed via Edge.

Can you please send your feedback again by using the browser's feedback mechanism? Here's how:

  1. Click Settings and more (the ... button in the top-right corner of the browser).
  2. Click Help and feedback.
  3. Click Send feedback.

I'll also ping some folks internally who might be able to help.

Thank you for your understanding.

@captainbrosset
Copy link
Contributor

After talking with the team, they mentioned the following couple of leads you could look into @adminsoho:

  1. Using policy-install if this is an IT admin use case. This policy should work: https://learn.microsoft.com/en-us/deployedge/microsoft-edge-policies#webappinstallforcelist
  2. We do have the --install-webapp param, but that's used by WebDriver automation, not something that is used for Intune.

Hope this helps a little bit.

@adminsoho
Copy link
Author

adminsoho commented Aug 25, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants