created script for adding firefox addons

This commit is contained in:
Jonas Forsberg 2020-08-02 18:08:29 +02:00
parent afbb5ccfd1
commit 30e0f7d5f5
No known key found for this signature in database
GPG Key ID: F2E9818C70350CC9
2 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,13 @@
#!/bin/bash
set -aeo pipefail
filename="$1"
url="$2"
tmpfile=$(mktemp /tmp/install_firefox_addon.XXXXXX)
curl -sLo "$tmpfile" "$url"
for p in "$(sed -n 's/^Path=\(.*\)$/\1/p' $HOME/.mozilla/firefox/profiles.ini)";do
cp "$tmpfile" "$HOME/.mozilla/firefox/$p/$filename"
done
rm "$tmpfile"

View File

@ -1,7 +1,15 @@
copy the install addon script:
file.managed:
- name: {{ salt['user.info']( pillar['username'] ).home }}/bin/install_firefox_addon
- source: salt://files/install_firefox_addon
- user: {{ pillar['username'] }}
- group: users
- mode: "0755"
{% for name, args in pillar['firefox']['addons'].items() %} {% for name, args in pillar['firefox']['addons'].items() %}
Downloading {{ name }} Firefox xpi: Downloading {{ name }} Firefox xpi:
cmd.run: cmd.run:
- name: curl -sLo {{ salt['user.info']( pillar['username'] ).home }}/.mozilla/firefox/$(sed -n 's/^Path=\(.*\)$/\1/p' {{ salt['user.info']( pillar['username'] ).home }}/.mozilla/firefox/profiles.ini)/{{ args['name'] }} {{ args['url'] }} - name: {{ salt['user.info']( pillar['username'] ).home }}/bin/install_firefox_addon {{ args['name'] }} {{ args['url'] }}
- unless: grep -oP '(?<=\},\"name\":\"){{ name }}' {{ salt['user.info']( pillar['username'] ).home }}/.mozilla/firefox/*.default*/addons.json - unless: grep -oP '(?<=\},\"name\":\"){{ name }}' {{ salt['user.info']( pillar['username'] ).home }}/.mozilla/firefox/*.default*/addons.json
- user: {{ pillar['username'] }} - user: {{ pillar['username'] }}
{% endfor %} {% endfor %}