diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2019-12-23 04:36:48 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2019-12-23 04:36:48 +0300 |
commit | bc6e31d1c362a4be1c5eae8f90d000da28d2ff47 (patch) | |
tree | de711892d858caae316109cf36a156d1fbc65698 | |
parent | a1c58689fce5078732b845a636cb88586a3a2842 (diff) |
more robust cross platform temp directory detection
-rwxr-xr-x | peerflix-deadbeef | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/peerflix-deadbeef b/peerflix-deadbeef index 63901e7..26714b0 100755 --- a/peerflix-deadbeef +++ b/peerflix-deadbeef @@ -18,6 +18,12 @@ get_deadbeef() { fi } +tempdir() { + for TMPDIR in "$TMPDIR" "$TMP" /var/tmp /tmp; do + test -d "$TMPDIR" && echo "$TMPDIR" && break + done +} + download() { local source="$1" local target="$2" @@ -36,11 +42,11 @@ usage() { exit } -mktemp_m3u() { - mktemp $TMPDIR/$(uuidgen).m3u +tempname() { + echo $(tempdir)/$(uuidgen).m3u } -VERSION="0.2" +VERSION="0.3" NAME="peerflix-deadbeef" DEADBEEF="$(get_deadbeef)" @@ -53,7 +59,7 @@ installed curl || installed wget || error "curl or wget is required" if [[ "$1" == "--ready" ]]; then host="$2" port="$3" - file=$(mktemp_m3u) + file=$(tempname) url="http://$host:$port/.m3u" usleep 100000 |