-
Notifications
You must be signed in to change notification settings - Fork 14
/
repost.sh
66 lines (47 loc) · 1.64 KB
/
repost.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
61
62
63
64
65
#!/bin/bash
# Sync with configs
source bot-mega.conf
#source build/envsetup.sh
sendMessage() {
MESSAGE=$1
curl -s "https://api.telegram.org/bot${BOT_API_KEY}/sendmessage" --data "text=$MESSAGE&chat_id=$CHAT_ID" 1> /dev/null
echo -e;
}
if [ $? -eq 0 ]
then
# Grab full file output
FILE_OUTPUT=$(grep -Po 'Package Complete: \K[^ ]+' build.log)
echo $FILE_OUTPUT
ZIP_NAME=$(grep -Po 'Package Complete: \K[^ ]+' build.log | sed 's#.*/##')
echo $ZIP_NAME
# Create Dir according to $DEVICE & $ROM (disable this after successfully executing script for first time)
megadf --reload 2>&1 >/dev/null && megamkdir /Root/$DEVICE_DIR 2>&1 >/dev/null
megadf --reload 2>&1 >/dev/null && megamkdir /Root/$DEVICE_DIR/$ROM_DIR 2>&1 >/dev/null
# Upload to MEGA
megadf -h --reload
megaput --path /Root/$DEVICE_DIR/$ROM_DIR/ $FILE_OUTPUT
# Fetch URL
megals -e /Root/$DEVICE_DIR/$ROM_DIR/$ZIP_NAME >> url.log
URL=$(grep https url.log | awk '{ print $1 }')
echo $URL
else
sendMessage "Build Failed!"
echo "Build Failed!"
fi
rm url.log
# Some Extra Summary to share
MD5=`md5sum $FILE_OUTPUT | awk '{ print $1 }'`
SIZE=`ls -sh $FILE_OUTPUT | awk '{ print $1 }'`
read -r -d '' SUMMARY << EOM
$FULL_ROM_NAME $A_VERSION for $FULL_DEVICE_NAME
Author: $TG_NAME
Build Date: $BUILD_DATE
Build Type: $BUILD_TYPE
MEGA LINK: $URL
SIZE: $SIZE
MD5: $MD5
NOTES: $NOTES
EOM
curl -s "https://api.telegram.org/bot${BOT_API_KEY}/sendPhoto" -d parse_mode="Markdown" --data "photo=$PHOTO_LINK&caption=$SUMMARY&chat_id=$CHAT_ID" 1> /dev/null
curl -s "https://api.telegram.org/bot${BOT_API_KEY}/sendSticker?chat_id=$CHAT_ID&sticker=$STICKER_ID" 1> /dev/null
exit 1