Skip to content
Snippets Groups Projects
Unverified Commit 091584f1 authored by Niels Abspoel's avatar Niels Abspoel Committed by GitHub
Browse files

Merge pull request #200 from noelmcloughlin/master

Fix MacOS desktop shortcuts
parents ac35742f d20ce192
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env bash
CMD='/usr/bin/osascript -e'
if [[ -f "{{ home }}/{{ user }}/Desktop/{{ app }}" ]] && [[ "${1}" -eq "remove" ]]
if [[ -e "{{ home }}/{{ user }}/Desktop/{{ app }}" ]] && [[ "${1}" -eq "remove" ]]
then
${CMD} "tell application \"Finder\" to delete file \"{{home}}/{{user}}/Desktop/{{ app }}\""
elif [[ -d "{{ dir }}/{{ app }}" ]] && [[ "${1}" -eq "add" ]]
$CMD "tell application \"Finder\" to delete POSIX file \"{{home}}/{{user}}/Desktop/{{ app }}\""
elif [[ -e "{{ dir }}/{{ app ~ '.app' if suffix else app }}" ]] && [[ "${1}" -eq "add" ]]
then
${CMD} "tell application \"Finder\" to make new Alias at (path to desktop folder) to POSIX file \"{{ dir }}/{{ app }}\""
$CMD "tell application \"Finder\" to delete POSIX file \"{{home}}/{{user}}/Desktop/{{ app }}\"" >/dev/null 2>&1
$CMD "tell application \"Finder\" to make new Alias at (path to desktop folder) to POSIX file \"{{ dir }}/{{ app }}{{ suffix or '' }}\""
fi
......@@ -90,8 +90,9 @@ mysql-macos-{{ product }}-desktop-shortcut-add:
- context:
user: {{ mysql.macos.user }}
home: {{ mysql.macos.userhomes }}
dir: {{'/Applications/' ~ data.app ~ '.app' if "isapp" in data and data.isapp else dl.prefix ~ '/' ~ archivename ~ '/bin'}}
app: {{ data.app }}
dir: {{ '/Applications' if "isapp" in data and data.isapp else dl.prefix ~ '/' ~ archivename ~ '/bin' }}
suffix: {{ '.app' if "isapp" in data and data.isapp else '' }}
cmd.run:
- name: /tmp/mac_shortcut.sh add
- runas: {{ mysql.macos.user }}
......
......@@ -4,13 +4,13 @@
{%- from salt.file.dirname(tpldir) ~ "/map.jinja" import mysql with context -%}
{%- set dl = mysql.macos.dl %}
{%- for product, data in mysql.macos.products.items() if "enabled" in data and data.enabled %}
{%- for product, data in mysql.macos.products.items() if "app" in data and data.app and "url" in data and data.url %}
{%- set archivename = data.url.split('/')[-1]|replace('.dmg', '')|replace('.tar.gz', '')|replace('.zip', '') %}
mysql-macos-{{ product }}-remove-destdir:
file.absent:
- names:
- {{ data.path }}
- {{ '/Applications' ~ data.app ~ '.app' if "isapp" in data and data.isapp else dl.prefix ~ '/' ~ archivename }}
mysql-macos-{{ product }}-desktop-shortcut-remove:
file.managed:
......@@ -21,8 +21,9 @@ mysql-macos-{{ product }}-desktop-shortcut-remove:
- context:
user: {{ mysql.macos.user }}
home: {{ mysql.macos.userhomes }}
dir: {{'/Applications/' ~ data.app ~ '.app' if "isapp" in data and data.isapp else dl.prefix ~ '/' ~ archivename ~ '/bin'}}
app: {{ data.app }}
dir: {{ '/Applications' if "isapp" in data and data.isapp else dl.prefix ~ '/' ~ archivename ~ '/bin' }}
suffix: {{ '.app' if "isapp" in data and data.isapp else '' }}
cmd.run:
- name: /tmp/mac_shortcut.sh remove
- runas: {{ mysql.macos.user }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment