forked from brainfucksec/kalitorify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
114 lines (95 loc) · 3.34 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
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
#!/bin/bash
# install.sh - kalitorify installer
# Copyright (C) 2015, 2017 Brainfuck
#
# This file is part of kalitorify
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# program informations
PROGRAM="install.sh"
VERSION="0.3.0"
AUTHOR="Brainfuck"
# define colors
export red=$'\e[0;91m'
export green=$'\e[0;92m'
export blue=$'\e[0;94m'
export cyan=$'\e[0;96m'
export white=$'\e[0;97m'
export endc=$'\e[0m'
# banner
banner() {
printf "${red}
####################################
#
# :: "$PROGRAM"
# :: Version: "$VERSION"
# :: Installer script for kalitorify
# :: Author: "$AUTHOR"
#
####################################${endc}\n\n"
}
# check if the program run as a root
check_root() {
if [[ "$(id -u)" -ne 0 ]]; then
printf "\n${red}%s${endc}\n" "[ FAILED ] Please run this program as a root!" 2>&-
exit 1
fi
}
## Check dependencies
# only tor is required, but use this function for future additions
check_required() {
printf "\n${blue}%s${endc} ${green}%s${endc}\n" "==>" "Check dependencies"
declare -a dependencies=("tor");
for package in "${dependencies[@]}"; do
if ! hash "$package" 2>/dev/null; then
printf "${blue}%s${endc} ${green}%s${endc}\n" "==>" "Installing "$package" ..."
apt-get update && apt-get install -y "$package"
printf "${cyan}%s${endc} ${green}%s${endc}\n" "[ OK ]" ""$package" installed"
else
printf "${cyan}%s${endc} ${green}%s${endc}\n" \
"[ OK ]" ""$package" already installed"
fi
done
}
## Install program files
# with 'install' command create directories and copy files
install_program() {
printf "${blue}%s${endc} ${green}%s${endc}\n" "==>" "Install kalitorify..."
# copy program files on /usr/share/*
install -Dm644 "LICENSE" "/usr/share/license/kalitorify/LICENSE"
install -Dm644 "README.md" "/usr/share/doc/kalitorify/README.md"
# copy executable file on /usr/local/bin
install -Dm755 "kalitorify.sh" "/usr/local/bin/kalitorify"
# check if program run correctly
if hash kalitorify 2>/dev/null; then
printf "${cyan}%s${endc} ${green}%s${endc}\n" \
"[ OK ]" "kalitorify succesfully installed"
printf "${green}%s${endc}\n" "run command 'kalitorify --start for start program"
else
printf "${red}%s${endc}\n" "[ FAILED ] kalitorify cannot start :("
printf "${green}%s${endc}\n" "If you are in trouble read NOTES on file README"
printf "${green}%s${endc}\n" \
"Report issues at: https://github.com/brainfucksec/kalitorify/issues"
fi
}
# Main function
main() {
banner
check_root
printf "${blue}%s${endc}" "==> "
read -n 1 -s -p "${green}Press any key to install kalitorify${endc} "
check_required
install_program
}
main