moved firefox addon to interactive script

This commit is contained in:
Jonas Forsberg 2020-08-03 10:19:23 +02:00
parent 6540462723
commit 5b063c09c1
No known key found for this signature in database
GPG Key ID: F2E9818C70350CC9
3 changed files with 22 additions and 17 deletions

View File

@ -93,6 +93,17 @@ function do_salt_call(){
$salt state.apply pillar="{username: $USER}"
}
function firefox_addons(){
new_log "Installing firefox addons"
if [[ ! -f "$HOME/bin/install_firefox_addon" ]];then
printf "install firefox addon script not found, run dotfile sync first"
fi
if asktobreak;then
return
fi
exec $HOME/bin/install_firefox_addon
}
setup_dotfiles
do_salt_call
gnome_key_bindings

View File

@ -2,15 +2,16 @@
set -aeo pipefail
filename="$1"
url="$2"
tmpfile=$(mktemp /tmp/install_firefox_addon.XXXXXX)
tmpfile=$(mktemp /tmp/install_firefox_addon.XXXXXX.xpi)
readarray -t profiles <<<"$(sed -n 's/^Path=\(.*\)$/\1/p' $HOME/.mozilla/firefox/profiles.ini)"
{% for name, args in pillar['firefox']['addons'].items() %}
if [[ $(grep -oP '(?<=\},\"name\":\"){{ name }}' {{ salt['user.info']( pillar['username'] ).home }}/.mozilla/firefox/*.default*/addons.json) ]]; then
printf "{{ name }} is already installed\n"
else
printf "installing {{ name }}\n"
curl -sLo "$tmpfile" "$url"
firefox "$tmpfile"
fi
{% endfor %}
curl -sLo "$tmpfile" "$url"
for p in $(sed -n 's/^Path=\(.*\)$/\1/p' $HOME/.mozilla/firefox/profiles.ini);do
echo "Installing in profile $p"
cp "$tmpfile" "$HOME/.mozilla/firefox/$p/extensions/$filename"
done
rm "$tmpfile"

View File

@ -2,14 +2,7 @@ copy the install addon script:
file.managed:
- name: {{ salt['user.info']( pillar['username'] ).home }}/bin/install_firefox_addon
- source: salt://files/install_firefox_addon
- template: jinja
- user: {{ pillar['username'] }}
- group: users
- mode: "0755"
{% for name, args in pillar['firefox']['addons'].items() %}
Downloading {{ name }} Firefox xpi:
cmd.run:
- 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
- runas: {{ pillar['username'] }}
{% endfor %}