-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathfunctions.sh
More file actions
97 lines (82 loc) · 1.78 KB
/
functions.sh
File metadata and controls
97 lines (82 loc) · 1.78 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
# ==============
# Functions
# ==============
# Telegram functions
# upload_file
upload_file() {
local FILE="$1"
local CAPTION="${2:-}"
if ! [[ -f $FILE ]]; then
error "file $FILE doesn't exist"
fi
chmod 777 "$FILE"
curl -s -F "document=@${FILE}" \
-F "chat_id=${TG_CHAT_ID}" \
-F "caption=${CAPTION}" \
-F "parse_mode=markdown" \
-F "disable_web_page_preview=true" \
"https://api.telegram.org/bot${TG_BOT_TOKEN}/sendDocument"
}
# send_msg
send_msg() {
local MESSAGE="$1"
curl -s -X POST "https://api.telegram.org/bot$TG_BOT_TOKEN/sendMessage" \
-d "chat_id=$TG_CHAT_ID" \
-d "disable_web_page_preview=true" \
-d "parse_mode=markdown" \
-d "text=$MESSAGE"
}
# KernelSU-related functions
install_ksu() {
local REPO="$1"
local REF="$2"
local URL
if [[ -z "$REPO" ]] || [[ -z "$REF" ]]; then
echo "Usage: install_ksu <user/repo> <ref>"
exit 1
fi
URL="https://raw.githubusercontent.com/$REPO/$REF/kernel/setup.sh"
log "Installing KernelSU from $REPO | $REF"
curl -LSs "$URL" | bash -s "$REF"
}
# ksu_included() function
# Type: bool
ksu_included() {
# if variant is not VNL then
# kernelsu is included!
[[ $VARIANT != "VNL" ]]
return $?
}
# susfs_included() function
# Type: bool
susfs_included() {
[[ $KSU_SUSFS == "true" ]]
return $?
}
# simplify_gh_url <github-repository-url>
simplify_gh_url() {
local URL="$1"
echo "$URL" | sed "s|https://github.com/||g" | sed "s|.git||g"
}
# Kernel scripts function
config() {
$KSRC/scripts/config --file $DEFCONFIG_FILE $@
}
# Logging function
log() {
echo -e "[LOG] $*"
}
error() {
local err_txt
err_txt=$(
cat << EOF
*Kernel CI*
ERROR: $*
EOF
)
echo -e "[ERROR] $*"
send_msg "$err_txt"
upload_file "$WORKDIR/build.log"
exit 1
}