-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathupdate.sh
executable file
·61 lines (55 loc) · 1.48 KB
/
update.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
#!/bin/bash
# Libernet Updater
# by Lutfa Ilham
# v1.0.0
HOME="/root"
DOWNLOADS_DIR="${HOME}/Downloads"
LIBERNET_TMP="${DOWNLOADS_DIR}/libernet"
REPOSITORY_URL="git://github.com/lutfailham96/libernet.git"
function update_libernet() {
if [[ ! -d "${LIBERNET_TMP}" ]]; then
echo -e "There's no Libernet installer on ~/Downloads directory, please clone it first!"
exit 1
fi
# change working dir to Libernet installer
cd "${LIBERNET_TMP}"
# verify Libernet installer
if git branch > /dev/null 2>&1; then
update_libernet_cli
else
echo -e "This is not Libernet installer directory, please use installer directory to update Libernet!"
exit 1
fi
}
function update_libernet_cli() {
echo -e "Updating Libernet ..." \
&& git fetch origin main \
&& git reset --hard FETCH_HEAD \
&& bash install.sh \
&& echo -e "\nLibernet successfully updated!"
}
function update_libernet_web() {
# create downloads directory if not exist
if [[ ! -d "${DOWNLOADS_DIR}" ]]; then
mkdir -p "${DOWNLOADS_DIR}"
fi
# update Libernet
"${LIBERNET_DIR}/bin/log.sh" -u 1
if [[ -d "${LIBERNET_TMP}" ]]; then
update_libernet
else
git clone --depth 1 "${REPOSITORY_URL}" "${LIBERNET_TMP}" \
&& cd "${LIBERNET_TMP}" \
&& bash install.sh \
&& echo -e "\nLibernet successfully updated!"
fi
"${LIBERNET_DIR}/bin/log.sh" -u 2
}
case $1 in
-web)
update_libernet_web || "${LIBERNET_DIR}/bin/log.sh" -u 3
;;
*)
update_libernet
;;
esac