This repository has been archived by the owner on Jan 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
bhs-repo
executable file
·126 lines (92 loc) · 2.08 KB
/
bhs-repo
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/data/data/com.termux/files/usr/bin/bash
## for enabling https://amaitlab.guthub.io/ repository
## Author : Amsit <dezavue3@gmail.com>
##
set -e
## Ensure PREFIX
test -z $PREFIX && \
PREFIX=/data/data/com.termux/files/usr
## Ensure TMPDIR
test -z $TMPDIR && \
TMPDIR="${PREFIX}/tmp"
## gnupg public key file
PUBKEY="${TMPDIR}/pubkey.gpg"
## user device architecture
ARCHITECTURE=$(uname -m)
## location of sources.list
SOURCES_LIST="${PREFIX}/etc/apt/sources.list"
## main program
main(){
## Displaying help message when args count is 0
if [ $# -eq 0 ]; then
__help
exit
fi
## Filtering allowed arg 1
## Display help message when arg 1 is invalid.
case $1 in
"enable"|"disable")
$@
apt update
;;
"-h"|"help"|*)
__help
;;
esac
}
## help message
__help(){
echo "Usage: "
echo
echo " bhs-repo enable"
echo " enabling repo https://blackholesecurity.github.io"
echo
echo " bhs-repo disable"
echo " disabling repo https://blackholesecurity.github.io"
echo
echo " bhs-repo help"
echo " show this message and exit"
echo
echo
echo "# 2018 (C) Amsit <dezavue3@gmail.com>"
}
## help message
help(){
## redirect
__help
}
## enabling repository
enable(){
apt update
apt upgrade -y
apt install gnupg wget
## Download gnupg public key
wget -O "$PUBKEY" https://blackholesecurity.github.io/pubkey.gpg
apt-key add "$PUBKEY"
rm -fr "$PUBKEY"
## Prevent duplicate entries in sources.list
disable
## Ensure user device architecture
## set as "aarch64" when architecture unknown
if [ -z "$ARCHITECTURE" ]; then
echo "Unknown architecture"
echo "Note:"
echo " Architecture will be set as \"aarch64\""
echo " If this wrong, Please edit file"
echo " ${SOURCES_LIST/$HOME/\~}"
ARCHITECTURE=aarch64
fi
## do not ask me , you known it
case "$ARCHITECTURE" in
armv7*)
ARCHITECTURE=arm
;;
esac
echo "deb [trusted=true,arch=all,${ARCHITECTURE}] https://blackholesecurity.github.io/ termux blackholesecurity" >> "$SOURCES_LIST"
}
## Disabling repo
disable(){
sed -i '/https:\/\/blackholesecurity.github.io\//d' "$SOURCES_LIST"
}
main $@
unset SOURCES_LIST ARCHITECTURE PUBKEY