#!/bin/sh # Grunden for Word, Excel and PowerPoint on a Mac: puts each app's add-in manifest where the app looks for it. # # curl -fsSL https://office.grunden.ai/install-mac.sh | sh # # What it does, and all it does: for Word, for Excel and for PowerPoint, if the app has been opened once (its # folder under ~/Library/Containers exists), it downloads that app's manifest from office.grunden.ai # into the app's add-in folder (wef), creating that folder if needed. No sudo, nothing else is # touched, and running it again just replaces the same three files. # Det här skriptet gör bara detta: laddar ner Grundens tillägg till Words, Excels och PowerPoints egna # tilläggsmappar. Inget sudo, inget annat rörs, och det går bra att köra igen. # # Everything is inside main, called on the very last line: read from a pipe, a download cut off # half way then runs nothing at all, not the half that arrived. # install_app NAME BUNDLE MANIFEST: one app, independent of the others. install_app() { name="$1" container="$HOME/Library/Containers/$2" manifest="$3" if [ ! -d "$container" ]; then echo "$name: not set up yet. Open $name once, then run this line again." echo "$name: inte klart än. Öppna $name en gång och kör sedan raden igen." return 0 fi folder="$container/Data/Documents/wef" mkdir -p "$folder" # A hard-killed earlier run (no trap) can leave its temporary file behind: clear those, only those. rm -f "$folder"/.grunden-download.* # Downloaded beside its final place, then moved: a failed download never leaves a half file. tmp="$(mktemp "$folder/.grunden-download.XXXXXX")" if curl -fsSL -o "$tmp" "$BASE/manifests/$manifest.xml"; then mv "$tmp" "$folder/grunden-$manifest.xml" tmp="" installed=$((installed + 1)) echo "$name: added Grunden ($folder/grunden-$manifest.xml)." echo "$name: la till Grunden ($folder/grunden-$manifest.xml)." else rm -f "$tmp" tmp="" failed=1 echo "$name: could not download Grunden from $BASE. Check your connection and run this line again." >&2 echo "$name: kunde inte ladda ner Grunden från $BASE. Kontrollera nätverket och kör raden igen." >&2 fi } main() { set -eu # GRUNDEN_BASE_URL is for tests; people never set it. BASE="${GRUNDEN_BASE_URL:-https://office.grunden.ai}" if [ "$(uname)" != "Darwin" ]; then echo "This line is for a Mac. On Windows, ask your IT to install Grunden for everyone," echo "or use the web route on office.grunden.ai." echo "Den här raden är för Mac. På Windows: be din IT installera Grunden för alla," echo "eller använd webbvägen på office.grunden.ai." exit 1 fi tmp="" # A download interrupted half way must not leave its temporary file in the app's folder. trap '[ -z "$tmp" ] || rm -f "$tmp"' EXIT INT TERM failed=0 installed=0 # macOS guards other apps' folders and asks once; the script waits on that question. echo "macOS may ask whether Terminal may access data from other apps: click Allow." echo "macOS kan fråga om Terminal får komma åt data från andra appar: klicka Tillåt." echo install_app Word com.microsoft.Word word install_app Excel com.microsoft.Excel excel install_app PowerPoint com.microsoft.Powerpoint powerpoint if [ "$installed" -gt 0 ]; then echo echo "Next: quit Word, Excel and PowerPoint completely (Cmd+Q), open them again, then" echo "Insert > My Add-ins > Developer Add-ins > Grunden." echo "Nästa steg: avsluta Word, Excel och PowerPoint helt (Cmd+Q), öppna dem igen, och välj sedan" echo "Infoga > Mina tillägg > Utvecklartillägg > Grunden." fi exit "$failed" } main "$@"