-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·258 lines (224 loc) · 8.1 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
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/bin/bash
# Easy Install script for Recalboy
# kjbstar - https://github.com/kjbstar/recalboy
# Create Apache vhost from : https://github.com/RoverWire/virtualhost/blob/master/virtualhost.sh
LATEST_RELEASE="0.3.0.1"
IP="$(hostname -I)"
ANSWER_DEFAULT="y"
RECALBOY_DEFAULT_PATH="/var/www/html"
RED=`tput setaf 1`
GREEN=`tput setaf 2`
BLUE=`tput setaf 4`
MAGENTA=`tput setaf 5`
YELLOW=`tput setaf 3`
RESET=`tput sgr0`
echo ""
echo ""
echo "${YELLOW}####################################################################"
echo "################### RECALBOY EASY INSTALL WIZARD ###################"
echo "####################################################################${RESET}"
echo ""
echo ""
echo "${MAGENTA}############################"
echo "PART 1 : Server requirements"
echo "############################${RESET}"
echo "${GREEN}We will now install, if necessary, Apache 2, PHP, Curl, Unzip, and php-mbstring, php-xml, for PHP 7 compatibility${RESET}"
read -p "${RED}Are you ready to proceed ?${RESET} [$ANSWER_DEFAULT/N]: " START_WIZARD
START_WIZARD="${START_WIZARD:-$ANSWER_DEFAULT}"
echo ""
echo ""
if [[ $START_WIZARD =~ ^([yY][eE][sS]|[yY])+$ ]] ; then
sudo apt-get update
echo ""
echo ""
read -p "${RED}Are you on Ubuntu ? (PHP 7)${RESET} ${YELLOW}Raspbian, Debian: answer No${RESET} [$ANSWER_DEFAULT/N]: " UBUNTU
UBUNTU="${UBUNTU:-$ANSWER_DEFAULT}"
if [[ $UBUNTU =~ ^([yY][eE][sS]|[yY])+$ ]] ; then
sudo apt-get install apache2 php php-curl php-mbstring php-xml curl unzip
else
sudo apt-get install apache2 php5 php5-curl curl unzip
fi
echo ""
echo ""
a2enmod rewrite
service apache2 restart
else
exit;
fi
echo ""
echo ""
echo ""
echo "${MAGENTA}#########################################"
echo "PART 2 : Setting up Recalboy VirtualHost"
echo "#########################################${RESET}"
echo "${GREEN}Do you already have any other websites configured with Apache on this machine ?"
echo "If yes, don't worry the path is customisable."
echo "If no or if you don't understand, don't think, press enter to all questions, and let the magic happen :)${RESET}"
echo ""
echo ""
read -p "${RED}Do you want me to auto-configure Recalboy's VirtualHost in Apache ?${RESET} [$ANSWER_DEFAULT/N]: " CONFIG_APACHE
CONFIG_APACHE="${CONFIG_APACHE:-$ANSWER_DEFAULT}"
if [[ $CONFIG_APACHE =~ ^([yY][eE][sS]|[yY])+$ ]] ; then
echo ""
echo ""
echo "${GREEN}Choose Recalboy's files location. ${RESET}"
read -p "${RED}If you don't know and/or don't already have any VirtualHost configured here, just press enter${RESET} [$RECALBOY_DEFAULT_PATH]: " RECALBOY_PATH
RECALBOY_FINAL_PATH="${RECALBOY_PATH:-$RECALBOY_DEFAULT_PATH}/public"
if [[ $RECALBOY_FINAL_PATH = "/var/www/html/public" ]] ; then
sudo rm /etc/apache2/sites-enabled/000-default.conf
APACHE_CONF="000-default.conf"
else
if ! [ -d $RECALBOY_PATH ]; then
### create the directory
sudo mkdir $RECALBOY_PATH
### give permission to root dir
sudo chmod 755 $RECALBOY_PATH
echo "${RED}Sorry, there's a bug at the end of the script. My bad, I don't know how to take a value outside the 'if loop'. So you must use default path to continue."
fi
APACHE_CONF="recalboy.conf"
fi
FILE="/etc/apache2/sites-enabled/${APACHE_CONF}"
sudo touch ${FILE}
sudo chmod 775 ${FILE}
if ! echo "#### Generated by Recalboy Easy Install Script
<VirtualHost *:80>
ServerName recalboy.local
ServerAdmin [email protected]
DocumentRoot ${RECALBOY_FINAL_PATH}
<Directory \"${RECALBOY_FINAL_PATH}\">
AllowOverride All
Order allow,deny
Allow from all
Options FollowSymlinks
</Directory>
ErrorLog /var/log/apache2/recalboy.error.log
CustomLog /var/log/apache2/recalboy.access.log combined
</VirtualHost>" > ${FILE}
then
echo ""
echo "Error creating virtual host !"
exit;
else
echo ""
echo "Virtual Host created !"
fi
if ! echo "127.0.0.1 recalboy.local" >> /etc/hosts
then
echo ""
echo "Not able to write in /etc/hosts, please run this script as sudo"
exit;
else
echo ""
echo "Host added to /etc/hosts file"
fi
echo ""
echo ""
/etc/init.d/apache2 reload
echo ""
echo ""
echo "${GREEN}Virtual Host fully configured, you can access on${RESET} http://recalboy.local ${GREEN}or${RESET} http://${IP} ${GREEN}in your browser.${RESET}"
echo "${GREEN}If you have customised the VirtualHost path, to access from another machine, add${RESET} ${IP} recalboy.local ${GREEN} to your hosts file.${RESET}"
echo ""
echo ""
else
echo ""
echo "Ok, you're an adult, I let you do this by yourself."
fi
echo ""
echo ""
echo ""
echo "${MAGENTA}#########################################"
echo "PART 3 : Get Composer"
echo "#########################################${RESET}"
echo "${GREEN}If you don't have Composer, I will install it for you"
echo ""
echo ""
read -p "${RED}Do you want to install Composer ?${RESET} [$ANSWER_DEFAULT/N]: " INSTALL_COMPOSER
INSTALL_COMPOSER="${INSTALL_COMPOSER:-$ANSWER_DEFAULT}"
if [[ $INSTALL_COMPOSER =~ ^([yY][eE][sS]|[yY])+$ ]] ; then
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
echo ""
echo "${GREEN}Hooray! Composer has been installed and moved to /usr/local/bin."
echo "Use it from anywhere with: composer${RESET}"
fi
echo ""
echo ""
echo ""
echo "${MAGENTA}#########################################"
echo "PART 4 : Install Recalboy !"
echo "#########################################${RESET}"
echo "${GREEN}Time to install latest release of Recalboy !"
echo ""
read -p "${RED}Ready to install Recalboy v${LATEST_RELEASE} ?${RESET} [$ANSWER_DEFAULT/N]: " INSTALL_RECALBOY
INSTALL_RECALBOY="${INSTALL_RECALBOY:-$ANSWER_DEFAULT}"
if [[ $INSTALL_RECALBOY =~ ^([yY][eE][sS]|[yY])+$ ]] ; then
echo ""
echo "${YELLOW}Downloading latest release...${RESET}"
wget "https://github.com/kjbstar/recalboy/archive/v${LATEST_RELEASE}.zip"
echo ""
echo "${YELLOW}Unzipping...${RESET}"
unzip v${LATEST_RELEASE}.zip -d ${RECALBOY_DEFAULT_PATH}
echo ""
echo "${YELLOW}Moving files into Virtual Host${RESET}"
mv ${RECALBOY_DEFAULT_PATH}/recalboy-${LATEST_RELEASE}/* ${RECALBOY_DEFAULT_PATH}/
mv ${RECALBOY_DEFAULT_PATH}/recalboy-${LATEST_RELEASE}/.[!.]* ${RECALBOY_DEFAULT_PATH}/
echo ""
echo "${YELLOW}Deleting Zip file...${RESET}"
rmdir ${RECALBOY_DEFAULT_PATH}/recalboy-${LATEST_RELEASE}
rm v${LATEST_RELEASE}.zip
echo "."
echo "."
echo "."
echo "."
echo "."
echo "."
echo "${MAGENTA}Launching Installation of Recalboy. It may take some time, so please be patient.${RESET}"
echo "."
echo "."
echo "."
echo "."
echo "."
echo "."
composer install -d ${RECALBOY_DEFAULT_PATH}
composer update -d ${RECALBOY_DEFAULT_PATH} --no-scripts
echo ""
echo ""
echo ""
echo "${GREEN}BRAVO ! Recalboy has been installed."
fi
echo "Last but not least, I must activate the Retroarch Network Commands on your Recalbox."
echo "${MAGENTA}Stop this script and activate this option by yourself in Retroarch menu if your Recalbox is a fresh install"
echo "or if you have a very customised retroarchcustom.cfg . Because this process may fail, and you would have to"
echo "delete retroarchcustom.cfg , and let Recalbox generate a new one.${RESET} Coming soon : better management of this activation."
echo ""
echo ""
read -p "Please turn on your Recalbox, and enter its IP (192.168.X.X):${RESET} " IP_RECALBOX
sed -i "s/\(RECALBOX_IP *= *\).*/\1${IP_RECALBOX}/" ${RECALBOY_DEFAULT_PATH}/.env
curl -L http://recalboy.local/config/check/retroarch/networkcommands
echo ""
echo ""
echo ""
echo "${GREEN}All done ! You can now use Recalboy.${RESET}"
echo "http://${IP}"
echo "${GREEN}or${RESET}"
echo "http://recalboy.local"
echo ""
echo "${GREEN}Configuration URL is here:${RESET}"
echo "http://${IP}/config"
echo "${GREEN}or here:${RESET}"
echo "http://recalboy.local/config"
echo ""
echo "${GREEN}Useful to setup Demo Mode, Upload, etc...${RESET}"
echo ""