removed tempfile usage

This commit is contained in:
Jonas Forsberg 2020-08-03 10:35:16 +02:00
parent d5405d7ad4
commit 375922407e
No known key found for this signature in database
GPG Key ID: F2E9818C70350CC9

View File

@ -1,16 +1,14 @@
#!/bin/bash #!/bin/bash
set -aeo pipefail set -aeo pipefail
filename="$1"
url="$2"
tmpfile=$(mktemp /tmp/install_firefox_addon.XXXXXX.xpi)
{% for name, args in pillar['firefox']['addons'].items() %} {% 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 if [[ $(grep -oP '(?<=\},\"name\":\"){{ name }}' {{ salt['user.info']( pillar['username'] ).home }}/.mozilla/firefox/*.default*/addons.json) ]]; then
printf "{{ name }} is already installed\n" printf "{{ name }} is already installed\n"
else else
printf "installing {{ name }}\n" printf "installing {{ name }}\n"
curl -sLo "$tmpfile" {{ args['url'] }} curl -sLo /tmp/{{ args['name'] }} {{ args['url'] }}
firefox "$tmpfile" firefox /tmp/{{ args['name'] }}
rm /tmp/{{ args['name'] }}
fi fi
{% endfor %} {% endfor %}