├── README.md ├── bot-mega.conf ├── bot-mega.sh ├── bot.conf ├── bot.sh ├── output.sh └── repost.sh /README.md: -------------------------------------------------------------------------------- 1 | # Buildbot Script(MEGA version) 2 | How to use: 3 | 4 | 1. Get your bot API key from [Telegram's BotFather](https://t.me/BotFather) 5 | 2. Assign BOT API Key in `bot-mega.config` 6 | ```bash 7 | export BOT_API_KEY=ABCD12345:12345AbCDefghIJK 8 | ``` 9 | 3. Create a public group and add your bot there then assign group tag 10 | ```bash 11 | export CHAT_ID=@groupname 12 | ``` 13 | 4. Assign your configs for eg. to build LineageOS for h930(LG v30 h930) 14 | ```bash 15 | # Configs 16 | ROM=lineage 17 | DEVICE=h930 18 | ``` 19 | 5. Assign your Manual Configs (info for Telegram post) 20 | ```bash 21 | # Manual Configs 22 | A_VERSION="Android 10" 23 | 24 | TG_NAME="@N7\_BADA" 25 | FULL_ROM_NAME="Corvus OS" 26 | FULL_DEVICE_NAME="LG v30 H930" 27 | BUILD_DATE=$(date +%Y-%m-%d) 28 | BUILD_TYPE="Bot Build" 29 | NOTES="Not Tested!" 30 | ``` 31 | 6. Assign your # Directories to create on MEGA shows up as /Root/$DEVICE_DIR/$ROM_DIR 32 | ```bash 33 | # Directories 34 | DEVICE_DIR="H930" 35 | ROM_DIR="Corvus" 36 | ``` 37 | 7. After all the above is set, Here's an example of the Output on Telegram after running the `bot-mega.sh`: 38 | 39 | ![Output Example](https://i.imgur.com/XSNIoI4.png) 40 | 41 | 8. Extra 1, `output.sh` posts a test output on Telegram, 42 | ```bash 43 | # Extra 44 | bash output.sh 45 | ``` 46 | 9. Extra 2, `repost.sh` will reupload or fetch the link of the latest build and post it on Telegram. 47 | ```bash 48 | # Extra 49 | bash repost.sh 50 | ``` 51 | 52 | (PS: in some cases like AEX,Corvus,Derpfest build command is `mka aex, make corvus, mka kronic` according to aex, corvus, derpfest build docs, you can change build command from line [18](https://github.com/N7-BADA/buildbot_script/blob/master/bot-mega.sh#L18) and [19](https://github.com/N7-BADA/buildbot_script/blob/master/bot-mega.sh#L19)`) 53 | 54 | ```bash 55 | ------------------------------------------------ 56 | ``` 57 | 58 | # Buildbot Script(GDrive version) 59 | How to use: 60 | 61 | 1. Get your bot API key from [Telegram's BotFather](https://t.me/BotFather) 62 | 2. Assign BOT API Key in `bot.config` 63 | ```bash 64 | export BOT_API_KEY=ABCD12345:12345AbCDefghIJK 65 | ``` 66 | 3. Create a public group and add your bot there then assign group tag 67 | ```bash 68 | export CHAT_ID=@groupname 69 | ``` 70 | 4. Assign your configs for eg. to build LineageOS for mido(Redmi note 4) 71 | ```bash 72 | # Configs 73 | ROMM=lineage 74 | DEBICE=mido 75 | VENDUR=xiaomi 76 | ``` 77 | 5. Misc Changes (these configs will be sent as message and wont affect any change in build) 78 | `ZIPNAM` will send package name to send 79 | `BUILD_TAIP` will set build type for eg. `Test` or `Alpha` 80 | `NOTES` will attach your message or note to send over telegram 81 | 82 | (PS: in some cases like AEX build command is `mka aex` according to aex build docs, you can change build command from [here](https://github.com/N7-BADA/buildbot_script/blob/master/bot.sh#L25)`) 83 | -------------------------------------------------------------------------------- /bot-mega.conf: -------------------------------------------------------------------------------- 1 | export CHAT_ID= 2 | export BOT_API_KEY= 3 | 4 | # Configs according to du_h930.mk 5 | ROM=du 6 | DEVICE=h930 7 | THREAD="-j$(grep -c ^processor /proc/cpuinfo)" 8 | 9 | # Manual Configs (info for telegram post) 10 | A_VERSION="Android 10" 11 | 12 | TG_NAME="@N7\_BADA" 13 | FULL_ROM_NAME="#Corvus OS v6.5" 14 | FULL_DEVICE_NAME="#LG #v30 #H930" 15 | BUILD_DATE=$(date +%Y-%m-%d) 16 | BUILD_TYPE="Test Build" 17 | NOTES="#FLASH\_AT\_OWN\_RISK!!" 18 | 19 | # Send ROM photo with ROM release as caption (copy photo link that has been posted on telegram) 20 | PHOTO_LINK="https://t.me/rom_banners/37" 21 | 22 | # Send seperator after posting ROM, Get your sticker ID (file_id) from @getidsbot on Telegram 23 | STICKER_ID="CAACAgQAAxkBAAEUOQJe9sS8NqmmZu8Jo7WbBKAF2i_3RQACPgADJ9JVJbjTCPq8VigVGgQ" 24 | 25 | # Directories to create on MEGA shows up as /Root/$DEVICE_DIR/$ROM_DIR 26 | DEVICE_DIR="H930" 27 | ROM_DIR="Corvus" 28 | -------------------------------------------------------------------------------- /bot-mega.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Sync with configs 4 | source bot-mega.conf 5 | source build/envsetup.sh 6 | 7 | sendMessage() { 8 | MESSAGE=$1 9 | 10 | curl -s "https://api.telegram.org/bot${BOT_API_KEY}/sendmessage" --data "text=$MESSAGE&chat_id=$CHAT_ID" 1> /dev/null 11 | 12 | echo -e; 13 | } 14 | 15 | sendMessage "Starting build $FULL_ROM_NAME for $FULL_DEVICE_NAME" 16 | 17 | # Start Build 18 | #lunch $ROM\_$DEVICE-userdebug && mka bacon | tee build.log # Enable this for standard "mka bacon" 19 | lunch $ROM\_$DEVICE-userdebug && make corvus | tee build.log # Enable and edit this if ROM has specific "make command" (make corvus, mka aex, etc) 20 | # catch lunch error 21 | if [ $? -eq 0 ] 22 | then 23 | 24 | echo "Build Completed! Uploading to MEGA.." 25 | sendMessage "Build Completed! Uploading to MEGA.." 26 | 27 | # Grab full file output 28 | FILE_OUTPUT=$(grep -Po 'Package Complete: \K[^ ]+' build.log) 29 | echo $FILE_OUTPUT 30 | 31 | ZIP_NAME=$(grep -Po 'Package Complete: \K[^ ]+' build.log | sed 's#.*/##') 32 | echo $ZIP_NAME 33 | 34 | # Create Dir according to $DEVICE & $ROM (disable this after successfully executing script for first time) 35 | megadf --reload 2>&1 >/dev/null && megamkdir /Root/$DEVICE_DIR 2>&1 >/dev/null 36 | megadf --reload 2>&1 >/dev/null && megamkdir /Root/$DEVICE_DIR/$ROM_DIR 2>&1 >/dev/null 37 | 38 | # Upload to MEGA 39 | megadf -h --reload 40 | megaput --path /Root/$DEVICE_DIR/$ROM_DIR/ $FILE_OUTPUT 41 | 42 | # Fetch URL 43 | megals -e /Root/$DEVICE_DIR/$ROM_DIR/$ZIP_NAME >> url.log 44 | URL=$(grep https url.log | awk '{ print $1 }') 45 | echo $URL 46 | 47 | else 48 | sendMessage "Build Failed!" 49 | echo "Build Failed!" 50 | fi 51 | 52 | rm url.log 53 | 54 | # Some Extra Summary to share 55 | MD5=`md5sum $FILE_OUTPUT | awk '{ print $1 }'` 56 | SIZE=`ls -sh $FILE_OUTPUT | awk '{ print $1 }'` 57 | 58 | read -r -d '' SUMMARY << EOM 59 | $FULL_ROM_NAME $A_VERSION for $FULL_DEVICE_NAME 60 | 61 | Author: $TG_NAME 62 | Build Date: $BUILD_DATE 63 | Build Type: $BUILD_TYPE 64 | MEGA LINK: $URL 65 | SIZE: $SIZE 66 | MD5: $MD5 67 | 68 | NOTES: $NOTES 69 | EOM 70 | 71 | 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 72 | 73 | curl -s "https://api.telegram.org/bot${BOT_API_KEY}/sendSticker?chat_id=$CHAT_ID&sticker=$STICKER_ID" 1> /dev/null 74 | 75 | echo -e; 76 | 77 | #fi 78 | 79 | 80 | exit 1 81 | 82 | -------------------------------------------------------------------------------- /bot.conf: -------------------------------------------------------------------------------- 1 | export CHAT_ID= 2 | export BOT_API_KEY= 3 | 4 | # Configs 5 | ROMM=lineage 6 | DEBICE=santoni 7 | VENDUR=xiaomi 8 | THREAD="-j$(grep -c ^processor /proc/cpuinfo)" 9 | 10 | # Manual Configs 11 | ZIPNAAM="LineageOS 16.0 santoni build #910" 12 | BUILD_TAIP="Test" 13 | NOTES="Check if booting or not" 14 | -------------------------------------------------------------------------------- /bot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #sync with configs 4 | source bot.conf 5 | source build/envsetup.sh 6 | 7 | export BUILD_FINISHED=false 8 | 9 | sendMessage() { 10 | MESSAGE=$1 11 | 12 | curl -s "https://api.telegram.org/bot${BOT_API_KEY}/sendmessage" --data "text=$MESSAGE&chat_id=$CHAT_ID" 1> /dev/null 13 | 14 | echo -e; 15 | } 16 | 17 | sendMessage "Starting build $ROMM for $DEBICE" 18 | 19 | #start build 20 | lunch $ROMM\_$DEBICE-userdebug | tee lunch.log 21 | # catch lunch error 22 | if [ $? -eq 0 ] 23 | then 24 | echo "Bringup Done... Starting Build\(brunch\)" 25 | sendMessage "Bringup Done... Starting build." 26 | brunch $DEBICE | tee build.log 27 | # mka aex | tee build.log 28 | #catch brunch error 29 | if [ $? -eq 0 ] 30 | then 31 | echo "build DONEEE" 32 | sendMessage "build DONE!" 33 | 34 | BUILD_FINISHED=true 35 | if [ $BUILD_FINISHED = true ] ; then 36 | 37 | #since build iz done lets upload 38 | OUTPUT_FILE=$(grep -o -P '(?<=Package\ Complete).*(?=.zip)' build.log)'.zip' 39 | # OUTPUT_FILE=$(grep -o -P '(?<=Zip: ).*(?=.zip)' build.log)'.zip' 40 | OUTPUT_LOC=$(echo $OUTPUT_FILE | cut -f2 -d":") 41 | echo $OUTPUT_LOC 42 | 43 | #upload to gdrive 44 | sendMessage "Uploading to Gdrive..." 45 | gdrive upload $OUTPUT_LOC | tee upload.log 46 | 47 | #get file id 48 | sed -e 's/.*Uploaded\(.*\)at.*/\1/' upload.log >> id.txt 49 | sendMessage "Upload Finished." 50 | sed -e '1d' id.txt >> final.txt 51 | FILE_ID=$(cat final.txt) 52 | 53 | #set permission to sharing 54 | gdrive share $FILE_ID 55 | 56 | #finally output the sharing url 57 | URL='https://drive.google.com/open?id='$FILE_ID 58 | SHARE="$(echo -e "${URL}" | tr -d '[:space:]')" 59 | echo $SHARE >> url.txt 60 | 61 | #MESSAGE=$(cat url.txt) 62 | echo $SHARE 63 | sendMessage $SHARE 64 | 65 | BEELD_FINISHED=true 66 | #clean up 67 | rm upload.log final.txt id.txt url.txt 68 | fi 69 | else 70 | sendMessage "beeld phel nibba" 71 | echo "brunch phel" 72 | fi 73 | else 74 | echo "Bringup PHEL..." 75 | sendMessage "Bringup PHEL... sad" 76 | fi 77 | 78 | rm lunch.log 79 | 80 | if [ $BUILD_FINISHED = true ] ; then 81 | 82 | # Some Extra Summary to share 83 | MD5=`md5sum ${OUTPUT_LOC} | awk '{ print $1 }'` 84 | 85 | read -r -d '' SUMMARY << EOM 86 | ROM: $ZIPNAAM 87 | Build: $BUILD_TAIP 88 | LINK: $SHARE 89 | NOTES: $NOTES 90 | MD5: $MD5 91 | EOM 92 | 93 | curl -s "https://api.telegram.org/bot${BOT_API_KEY}/sendmessage" --data "text=$SUMMARY&chat_id=$CHAT_ID" 1> /dev/null 94 | echo -e; 95 | 96 | fi 97 | 98 | 99 | exit 1 100 | -------------------------------------------------------------------------------- /output.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Sync with configs 4 | source bot-mega.conf 5 | 6 | read -r -d '' SUMMARY << EOM 7 | $FULL_ROM_NAME $A_VERSION for $FULL_DEVICE_NAME 8 | 9 | Author: $TG_NAME 10 | Build Date: $BUILD_DATE 11 | Build Type: $BUILD_TYPE 12 | MEGA LINK: $URL 13 | SIZE: $SIZE 14 | MD5: $MD5 15 | 16 | NOTES: $NOTES 17 | EOM 18 | 19 | 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 20 | 21 | curl -s "https://api.telegram.org/bot${BOT_API_KEY}/sendSticker?chat_id=$CHAT_ID&sticker=$STICKER_ID" 1> /dev/null 22 | 23 | exit 1 24 | 25 | -------------------------------------------------------------------------------- /repost.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Sync with configs 4 | source bot-mega.conf 5 | #source build/envsetup.sh 6 | 7 | sendMessage() { 8 | MESSAGE=$1 9 | 10 | curl -s "https://api.telegram.org/bot${BOT_API_KEY}/sendmessage" --data "text=$MESSAGE&chat_id=$CHAT_ID" 1> /dev/null 11 | 12 | echo -e; 13 | } 14 | 15 | if [ $? -eq 0 ] 16 | then 17 | # Grab full file output 18 | FILE_OUTPUT=$(grep -Po 'Package Complete: \K[^ ]+' build.log) 19 | echo $FILE_OUTPUT 20 | 21 | ZIP_NAME=$(grep -Po 'Package Complete: \K[^ ]+' build.log | sed 's#.*/##') 22 | echo $ZIP_NAME 23 | 24 | # Create Dir according to $DEVICE & $ROM (disable this after successfully executing script for first time) 25 | megadf --reload 2>&1 >/dev/null && megamkdir /Root/$DEVICE_DIR 2>&1 >/dev/null 26 | megadf --reload 2>&1 >/dev/null && megamkdir /Root/$DEVICE_DIR/$ROM_DIR 2>&1 >/dev/null 27 | 28 | # Upload to MEGA 29 | megadf -h --reload 30 | megaput --path /Root/$DEVICE_DIR/$ROM_DIR/ $FILE_OUTPUT 31 | 32 | # Fetch URL 33 | megals -e /Root/$DEVICE_DIR/$ROM_DIR/$ZIP_NAME >> url.log 34 | URL=$(grep https url.log | awk '{ print $1 }') 35 | echo $URL 36 | 37 | else 38 | sendMessage "Build Failed!" 39 | echo "Build Failed!" 40 | fi 41 | 42 | rm url.log 43 | 44 | # Some Extra Summary to share 45 | MD5=`md5sum $FILE_OUTPUT | awk '{ print $1 }'` 46 | SIZE=`ls -sh $FILE_OUTPUT | awk '{ print $1 }'` 47 | 48 | read -r -d '' SUMMARY << EOM 49 | $FULL_ROM_NAME $A_VERSION for $FULL_DEVICE_NAME 50 | 51 | Author: $TG_NAME 52 | Build Date: $BUILD_DATE 53 | Build Type: $BUILD_TYPE 54 | MEGA LINK: $URL 55 | SIZE: $SIZE 56 | MD5: $MD5 57 | 58 | NOTES: $NOTES 59 | EOM 60 | 61 | 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 62 | 63 | curl -s "https://api.telegram.org/bot${BOT_API_KEY}/sendSticker?chat_id=$CHAT_ID&sticker=$STICKER_ID" 1> /dev/null 64 | 65 | exit 1 66 | 67 | --------------------------------------------------------------------------------