Merge pull request #200 from noelmcloughlin/master

Fix MacOS desktop shortcuts
This commit is contained in:
Niels Abspoel 2018-10-05 10:56:09 +02:00 committed by GitHub
commit 091584f1a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 8 deletions

View file

@ -1,10 +1,12 @@
#!/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

View file

@ -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 }}

View file

@ -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 }}