Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·103 lines (91 loc) · 2.5 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·103 lines (91 loc) · 2.5 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
98
99
100
101
102
103
#!/usr/bin/env bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )";
LOG_DIR="${SRC_DIR}/log"
LOG_FILE="${LOG_DIR}/build.log";
mkdir -p "${LOG_DIR}"
if [[ -f "${LOG_FILE}" ]]; then
echo '' >> "${LOG_FILE}"
echo "$(date '+%d/%m/%Y %H:%M:%S')" >> "${LOG_FILE}"
echo '' >> "${LOG_FILE}"
else
touch "${LOG_FILE}"
echo "$(date '+%d/%m/%Y %H:%M:%S')" >> "${LOG_FILE}"
echo '' >> "${LOG_FILE}"
fi
INSTALL_DIR="${HOME}/.local/share/gnome-shell/extensions"
if [[ "$(id -u)" -eq 0 ]]; then
chown "${SUDO_USER}":"${SUDO_USER}" -R "${LOG_DIR}"
INSTALL_DIR="/usr/share/gnome-shell/extensions"
fi
mkdir -p "${INSTALL_DIR}"
# print <arg>
print() {
echo -e "${NC}[+] ${1}${NC}"
echo -e "[+] ${1}" &>> "$LOG_FILE"
}
# print_warning <arg>
print_warning() {
echo -e "${NC}[${YELLOW}!${NC}] ${1}${NC}"
echo -e "[!] ${1}" &>> "$LOG_FILE"
}
# print_failed <arg>
print_failed() {
echo -e "${NC}[${RED}x${NC}] ${1}${NC}"
echo -e "[x] ${1}" &>> "$LOG_FILE"
}
# print_success <arg>
print_success() {
echo -e "${NC}[${GREEN}\xE2\x9C\x94${NC}] ${1}${NC}"
echo -e "[✔] ${1}" &>> "$LOG_FILE"
}
# print_suggestion <arg>
print_suggestion() {
echo -e "${NC}[${BLUE}#${NC}] ${1}${NC}"
echo -e "[#] ${1}" &>> "$LOG_FILE"
}
# is_failed <success_message> <failed_message>
is_failed() {
if [[ "$?" -eq 0 ]]; then
print_success "${1}"
else
print_failed "${2}"
fi
}
# is_warning <success_message> <warning_message>
is_warning() {
if [[ "$?" -eq 0 ]]; then
print_success "${1}"
else
print_warning "${2}"
fi
}
# install extension
install() {
print "Installing to ${INSTALL_DIR}"
rm -rf "${INSTALL_DIR}/InternetSpeedMonitor@Rishu"
cp -rf "${SRC_DIR}/src" "${INSTALL_DIR}/InternetSpeedMonitor@Rishu" &>> "$LOG_FILE"
glib-compile-schemas --strict --targetdir="${INSTALL_DIR}/InternetSpeedMonitor@Rishu/schemas" "${INSTALL_DIR}/InternetSpeedMonitor@Rishu/schemas"
mkdir -p "$HOME/.local/var/log/"
touch "$HOME/.local/var/log/InternetSpeedMonitor.log"
is_failed "Done" "Skipping: Can not install to ${INSTALL_DIR}. See log for more info."
}
# build for release
build() {
print "Creating [email protected]"
mkdir -p "${SRC_DIR}/out"
cd "src"
zip -6rX "$SRC_DIR/out/[email protected]" * &>> "$LOG_FILE"
cd ..
is_failed "Done" "Skipping: Creating zip is failed. See log for more info."
}
# Let's start
if [[ "${1}" == "-b" ]]; then
build
else
install
fi