/
complex-install.sh
229 lines (180 loc) · 4.95 KB
/
complex-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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#!/bin/sh
# This is the complex install script for PageKicker.
#
# NOT YET WORKING, USE simple-install.sh INSTEAD!!
###########
BLACK='\033[30;1m'
RED='\033[91;1m'
GREEN='\033[32;1m'
CYAN='\033[36;1m'
RESET='\033[0m'
print_step() {
printf "$BLACK$1$RESET\n"
}
print_error() {
printf "$RED$1$RESET\n"
}
print_warning() {
printf "$CYAN$1$RESET\n"
}
print_good() {
printf "$GREEN$1$RESET\n"
}
program_exists() {
if ! type "$1" > /dev/null 2>&1; then
return 1
else
return 0
fi
}
pip3_package_exists() {
python3 -c "import $1" 2> /dev/null && return 0 || return 1
}
spinner() {
while true; do
printf '\\\b'
sleep 0.1
printf 'l\b'
sleep 0.1
printf '/\b'
sleep 0.1
printf -- '-\b'
sleep 0.1
done
}
print_and_run(){
case "$1" in
*sudo*) sudo -l > /dev/null ;;
esac
print_step "$1"
spinner &
spinner_pid=$!
$1
kill $spinner_pid
wait $spinner_pid 2> /dev/null
printf ' ' # clear spinner
printf '\n'
}
systemctl_or_service(){
if program_exists "systemctl"; then
print_and_run "sudo systemctl ${1} ${2}.service"
else
print_and_run "sudo service ${2} ${1}"
fi
}
install_dependencies_debian_linux(){
print_step "Installing PageKicker and its dependencies on your Debian/Ubuntu Linux..."
APT_FLAG=0
arch=$(uname -m)
if ! program_exists "sudo"; then
apt-get install -q -y sudo
fi
# check for /usr/bin/pip3
if [ "$(which pip3)" = "" ]; then
# pip3 incompleteread fix
sudo apt-get remove -y python3-requests python3-pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
sudo rm get-pip.py
fi
if [ "$(which pip3)" = "/usr/bin/pip3" ]; then
# pip3 incompleteread fix
sudo apt-get remove -y python3-requests python3-pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
sudo rm get-pip.py
fi
if pip3_package_exists "setuptools"; then
sudo pip3 uninstall -y setuptools
fi
if [ "$APT_FLAG" = "0" ]; then
print_and_run "sudo apt-get -q update"
fi
# install fonts
# need /usr/share/fonts/truetype/ttf-dejavu
# create directory structure
mkdir -m 755 ~/.pagekicker
mkdir -m -p /tmp/pagekicker
# create local-data directory structure
# get master repository
cd ~
git clone https://github.com/fredzannarbor/pagekicker-community.git
# install python dependencies
cd ~/pagekicker-community
pip install -r requirements.txt
# installs ubuntu dependencies
. apt-install.sh
# get lib programs
. get-lib.sh # fetches third party apps stored in PageKicker scripts/lib
# set up imagemagick configuration
. magick-setup.sh
}
install_optional_dependencies(){
# Magento if needed
# wget bitnami magento stack
# sudo apt-get install xmlstarlet
# Social media connectivity
sudo apt-get install ruby-dev
sudo gem install t
sudo gem install facebook-cli
# see https://github.com/specious/facebook-cli for info on how to authorize
# mysql-client & mysql-server needed in future but not right now
}
verify_installation(){
printf "Verifying $1..."
if ! program_exists $1; then
print_error "[FAIL]"
fail="y"
else
print_good "[PASS]"
fi
}
verify_installation_all(){
print_step "Verifying installation"
fail=
verify_installation "python3"
verify_installation "pip3"
if [ -z $fail ]; then
print_good "You have successfully installed PageKicker!"
print_step ""
print_step ""
exit 0
else
print_error "Installation failed. Please contact support at support@pagekicker.com"
exit 1
fi
}
suggest_locale(){
print_warning "Warning: If your computer's locale is not US based"
print_warning "Please set the following environment variables:"
print_step "\texport LC_ALL=C.UTF-8"
print_step "\texport LANG=C.UTF-8"
}
API_warning(){
print_warning "To test the default system, you will need a Wikipedia API key."
print_step "Go to https://www.mediawiki.org/wiki/API:Login."
}
main() {
trap 'kill $spinner_pid; printf "\n"; verify_installation_all; exit 1' 2
# checks the system type and calls system specific install functions
UNAME=$(uname)
case "${UNAME:-nil}" in
Linux)
if program_exists "apt-get"; then
install_dependencies_debian_linux
else
print_error "Sorry, your system does not have either apt-get or yum package manager."
exit 1
fi
*)
print_error "Sorry, $UNAME is currently not supported via this installer."
exit 1
;;
esac
# test whether to install optional dependencies for Magento & social networking
# install_optional_dependencies
suggest_locale
verify_installation_all
api_warning
}
main