forked from azrim/script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.sh
executable file
·74 lines (58 loc) · 1.64 KB
/
sync.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
66
67
68
69
70
71
72
73
74
#!/bin/bash
#
# Copyright (c) 2020 azrim
# Init
ROM=havoc
MANIFEST="https://github.com/Havoc-OS/android_manifest.git"
BRANCH=ten
LOC_MANIFEST="https://github.com/azrim/local_manifests.git"
LOC_BRANCH=ginkgo
TOKEN=""
CHAT_ID=""
# workdir
FOLDER=$HOME/$ROM
if ! [ -d "$FOLDER" ]; then
mkdir "$FOLDER"
fi
cd "$FOLDER"
# Check if already init before
if ! [ -f "$FOLDER"/.repo/manifest.xml ]; then
repo init -u "$MANIFEST" -b "$BRANCH"
fi
# cloning local manifest
if [ -f "$FOLDER"/.repo/local_manifests/local_manifest.xml ]; then
rm -rf "$FOLDER"/.repo/local_manifests
fi
cd "$FOLDER"/.repo
git clone "$LOC_MANIFEST" -b "$LOC_BRANCH"
cd "$FOLDER"
# Finnaly start syncing
SYNC_START=$(date +"%s")
if [ -f "$FOLDER"/Makefile ]; then
rm -rf "$FOLDER"/Makefile
fi
msg=$(mktemp)
{
echo "*Syncing $ROM*"
echo "Start Time: $(date +"%Y-%m-%d"-%H%M)"
} > "${msg}"
MESSAGE=$(cat "$msg")
curl -s -X POST -d chat_id=$CHAT_ID -d parse_mode=markdown -d text="$MESSAGE" https://api.telegram.org/bot${TOKEN}/sendMessage
repo sync -c -j$(nproc --all) --force-sync --no-clone-bundle --no-tags
if ! [ -f "$FOLDER"/Makefile ]; then
curl -s -X POST -d chat_id=$CHAT_ID -d parse_mode=markdown -d text="Failed sync $ROM" https://api.telegram.org/bot${TOKEN}/sendMessage
exit 1
fi
SYNC_END=$(date +"%s")
DIFF=$(($SYNC_END - $SYNC_START))
msg1=$(mktemp)
{
echo "*Sync Finished*"
echo ""
echo "*Time:* $(($DIFF / 60)) minutes and $(($DIFF % 60)) seconds"
echo "Ready to cook"
} > "${msg1}"
MESSAGE1=$(cat "$msg1")
curl -s -X POST -d chat_id=$CHAT_ID -d parse_mode=markdown -d text="$MESSAGE1" https://api.telegram.org/bot${TOKEN}/sendMessage
exit 1
#END