forked from elementary/os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.sh
executable file
·60 lines (51 loc) · 1.64 KB
/
upload.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
set -e
CONFIG_FILE="$1"
KEY="$2"
SECRET="$3"
ENDPOINT="$4"
BUCKET="$5"
source "$CONFIG_FILE"
echo -e "
#----------------------#
# INSTALL DEPENDENCIES #
#----------------------#
"
apt-get update
apt-get install -y python3 python3-boto3
echo -e "
#------------#
# UPLOAD ISO #
#------------#
"
# get the paths & filenames of the files to upload
ISOPATHS="$(find builds -name "*.iso")"
while IFS= read -r ISOPATH; do
SHAPATH="${ISOPATH%.*}.sha256.txt"
MD5PATH="${ISOPATH%.*}.md5.txt"
ISO="$CHANNEL/$(basename "$ISOPATH")"
SHASUM="$CHANNEL/$(basename "$SHAPATH")"
MD5="$CHANNEL/$(basename "$MD5PATH")"
echo "uploading $ISO..."
python3 upload.py "$KEY" "$SECRET" "$ENDPOINT" "$BUCKET" "$ISOPATH" "$ISO" || exit 1
echo "uploading $SHASUM..."
python3 upload.py "$KEY" "$SECRET" "$ENDPOINT" "$BUCKET" "$SHAPATH" "$SHASUM" || exit 1
echo "uploading $MD5..."
python3 upload.py "$KEY" "$SECRET" "$ENDPOINT" "$BUCKET" "$MD5PATH" "$MD5" || exit 1
if [ "$CHANNEL" == "stable" ]; then
# install transmission
apt-get install -y transmission-cli
cd "$(dirname "$ISOPATH")" || exit 1
# create torrent file
transmission-create "$(basename "$ISOPATH")" \
-t https://ashrise.com:443/phoenix/announce \
-t udp://open.demonii.com:1337/announce \
-t udp://tracker.ccc.de:80/announce \
-t udp://tracker.istole.it:80/announce \
-t udp://tracker.openbittorrent.com:80/announce \
-t udp://tracker.publicbt.com:80/announce
cd ~- || exit 1
echo "uploading $ISO.torrent..."
python3 upload.py "$KEY" "$SECRET" "$ENDPOINT" "$BUCKET" "$ISOPATH.torrent" "$ISO.torrent" || exit 1
fi
done <<< "$ISOPATHS"