diff options
author | nachoparker <nacho@ownyourbits.com> | 2017-11-23 16:42:32 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2017-11-23 16:42:32 +0300 |
commit | 56c900948da662faf6c5a45ebca4d2a0e33b9170 (patch) | |
tree | 488845eaeb0056114315141f304e8d13254b2b70 /buildlib.sh | |
parent | 6883aa2da7cd91df8eb849170fa3125b60c27a70 (diff) |
build: improve create_torrent
Diffstat (limited to 'buildlib.sh')
-rw-r--r-- | buildlib.sh | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/buildlib.sh b/buildlib.sh index f8eab0c4..ec494d46 100644 --- a/buildlib.sh +++ b/buildlib.sh @@ -191,12 +191,14 @@ function pack_image() function create_torrent() { - [[ "$1" == "" ]] && { echo "No directory specified"; exit 1; } - test -d "$1" || { echo "$1 not found or is not a directory" ; exit 1; } - - md5sum "$1"/*.bz2 > "$1"/md5sum - - createtorrent -a udp://tracker.opentrackr.org -p 1337 -c "NextCloudPi. Nextcloud for Raspberry Pi image" "$1" "$1".torrent + local IMG="$1" + [[ -f "$IMG" ]] || { echo "image $IMG not found"; return 1; } + local IMGNAME="$( basename "$IMG" .tar.bz2 )" + local DIR="torrent/$IMGNAME" + [[ -d "$DIR" ]] && { echo "dir $DIR already exists"; return 1; } + mkdir -p torrent/"$IMGNAME" && cp "$IMG" torrent/"$IMGNAME" + md5sum "$DIR"/*.bz2 > "$DIR"/md5sum + createtorrent -a udp://tracker.opentrackr.org -p 1337 -c "NextCloudPi. Nextcloud for Raspberry Pi image" "$DIR" "$DIR".torrent } function generate_changelog() |