-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·45 lines (37 loc) · 1.22 KB
/
install.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
#!/bin/bash
## Author: Dang Thanh Phat
## Email: thanhphatit95@gmail.com
## Web/blogs: www.itblognote.com
## sudo curl -o- https://raw.githubusercontent.com/thanhphatit/k8s-connect/main/install.sh | /bin/bash
## sudo wget -q https://raw.githubusercontent.com/thanhphatit/k8s-connect/main/install.sh -O - | /bin/bash
###### GLOBAL VARIABLES
BIN_NAME="k8s-connect"
REPO_OWNER="thanhphatit"
GIT_BRANCH="main"
GIT_PATH_DOWN_FILE="${BIN_NAME}.deb"
REPO_RELEASE_NAME="${BIN_NAME}"
TMP_INSTALL_ROOT=$(mktemp -dt ${BIN_NAME}-install-XXXXXX)
TMP_INSTALL_FILE="${TMP_INSTALL_ROOT}/${GIT_PATH_DOWN_FILE}"
###### FUNCTIONS
function download_file(){
local _DOWNLOAD_URL="https://raw.githubusercontent.com/${REPO_OWNER}/${REPO_RELEASE_NAME}/${GIT_BRANCH}/${GIT_PATH_DOWN_FILE}"
if [[ $(command -v curl) ]];then
curl -SsL "${_DOWNLOAD_URL}" -o "${TMP_INSTALL_FILE}"
else
wget -q -O "${TMP_INSTALL_FILE}" "${_DOWNLOAD_URL}"
fi
}
###### MAIN
function main(){
download_file
if [[ -f ${TMP_INSTALL_FILE} ]];then
chmod 755 ${TMP_INSTALL_FILE}
dpkg -i ${TMP_INSTALL_FILE}
fi
if [[ -d ${TMP_INSTALL_ROOT} ]];then
rm -rf ${TMP_INSTALL_ROOT}
fi
}
###### START
main "${@}"
exit 0