From 30e0f7d5f5ba8379943699532b1ac13dad60351e Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Sun, 2 Aug 2020 18:08:29 +0200 Subject: [PATCH] created script for adding firefox addons --- salt/states/files/install_firefox_addon | 13 +++++++++++++ salt/states/firefox.sls | 10 +++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 salt/states/files/install_firefox_addon diff --git a/salt/states/files/install_firefox_addon b/salt/states/files/install_firefox_addon new file mode 100755 index 0000000..9fbf372 --- /dev/null +++ b/salt/states/files/install_firefox_addon @@ -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" diff --git a/salt/states/firefox.sls b/salt/states/firefox.sls index 4f19eab..392baff 100644 --- a/salt/states/firefox.sls +++ b/salt/states/firefox.sls @@ -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() %} Downloading {{ name }} Firefox xpi: 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 - user: {{ pillar['username'] }} {% endfor %}