-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraspi-setup.sh
52 lines (45 loc) · 2.29 KB
/
raspi-setup.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
#!/usr/bin/env bash
# Ensure that PHP is installed
which php >/dev/null || {
echo "PHP is not currently installed."
echo "Do you want to install the 'php5-cli' package and continue?"
warnNoPhpResult=""
while [[ ! $warnNoPhpResult =~ ^[YNyn]$ ]]; do
# Wait until we have a Y/N answer...
read -p "Install and continue? [Y/N] " warnNoPhpResult
done
if [[ $warnNoPhpResult =~ ^[Nn]$ ]]; then
echo "Unable to continue without PHP installed. Exiting."
exit 1
else
echo "Attempting to install 'php-cli'... You may receive a 'sudo' password prompt or two."
sudo apt-get update; sudo apt-get -y install php5-cli
which php >/dev/null || {
echo "PHP still doesn't appear to be installed. Please install it manually (probably via the 'php5-cli' package, or similar, so that a 'php' command is in the PATH) and then re-run this script."
exit 2
}
fi
}
# PHP is installed (either it was always installed, or it's NOW installed thanks to the above code) so we can fetch and execute our PHAR archive...
echo "The main setup script and sample config file will now be downloaded from Hex over SFTP."
echo "YOU WILL BE PROMPTED FOR YOUR SSH PASSWORD TO HEX:"
scp [email protected]:"/mnt/backups/RPi/_setup/raspi-setup{.phar.gz,-config-sample.json}" . || {
echo "Failed to download required files from Hex. Please investigate the problem and try again."
exit 3
}
echo "Do you want to edit and use a configuration file? This is recommended, as it results in faster and more unattended-suitable installations, but may not be suitable if you are unfamiliar with the installer."
useConfigResult=""
while [[ ! $useConfigResult =~ ^[YNyn]$ ]]; do
# Wait until we have a Y/N answer...
read -p "Edit and use configuration file? [Y/N] " useConfigResult
done
if [[ $useConfigResult =~ ^[Nn]$ ]]; then
echo "Not using configuration file."
rm ./raspi-setup-config-sample.json
php raspi-setup.phar.gz && rm raspi-setup.phar.gz
else
echo "Using configuration file."
read -p "Press ENTER to edit the configuration file and continue..." dummy
nano ./raspi-setup-config-sample.json
php raspi-setup.phar.gz --config=raspi-setup-config-sample.json && rm raspi-setup.phar.gz raspi-setup-config-sample.json
fi