-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
brew
executable file
·136 lines (128 loc) · 3.95 KB
/
brew
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
#!/bin/bash
#
# Fully automated LAMP installation and configuration using Trusted localhost
# SSL Certificates
#
# Copyright: Copyright 2018-2020 Justin Hartman (https://justinhartman.co)
# Author : Justin Hartman <[email protected]> (https://justinhartman.co)
# License : https://opensource.org/licenses/AGPL-3.0 AGPL-3.0
# Version : 1.2.2
# Link : https://github.com/justinhartman/lamp-ssl
# Since : 0.5.0
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#######################################
# Includes the colour palette and
# other global variables
# Globals:
# None
# Arguments:
# None
# Returns:
# Variables
#######################################
global_includes() {
source ./scripts/globals.sh
source ./scripts/colour_palette.sh
}
#######################################
# This asks the user if they have
# Homebrew or not and waits for a Y or
# N answer.
# Globals:
# None
# Arguments:
# None
# Returns:
# Void
#######################################
brew_start() {
printf "${BLU}%s\\n" "${TOP}"
printf '* %-76s %s\n' "Do you want to install Homebrew on your computer? (Y/n)" "*"
printf "%s${NOC}\\n\\n" "${BOTTOM}"
echo -n ""
read -r answer
}
#######################################
# This installs Homebrew (`brew`) but
# only if the user hasn't got it and
# wants to install it via the script.
# Globals:
# None
# Arguments:
# None
# Returns:
# Void
#######################################
brew_install() {
printf "${LGY}%s\\n" "${TOP}"
printf '* %-76s %s\n' "Installing Homebrew..." "*"
printf "%s${NOC}\\n\\n" "${BOTTOM}"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
echo -e "\\n${GRN}\\xE2\\x9C\\x94${NOC} ${CYA}Successfully installed Homebrew.${NOC}\\n"
}
#######################################
# Installs the packages required from
# `brew` running `brew install`.
# Globals:
# None
# Arguments:
# None
# Returns:
# Void
#######################################
brew_packages() {
printf "${GRY}%s\\n" "${TOP}"
printf '* %-76s %s\n' "Installing Apache 2, MySQL and PHP..." "*"
printf "%s${NOC}\\n\\n" "${BOTTOM}"
brew install wget httpd mysql php
echo -e "\\n${GRN}\\xE2\\x9C\\x94${NOC} ${CYA}Successfully installed Apache 2, MySQL and PHP.${NOC}\\n"
}
#######################################
# Starts up background processes which
# run at boot time.
# Globals:
# None
# Arguments:
# None
# Returns:
# Void
#######################################
brew_startup() {
printf "${ORG}%s\\n" "${TOP}"
printf '* %-76s %s\n' "Starting Apache 2, MySQL and PHP..." "*"
printf "%s${NOC}\\n\\n" "${BOTTOM}"
sudo /usr/sbin/apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
brew services start httpd
brew services start mysql
brew services start php
echo -e "\\n${GRN}\\xE2\\x9C\\x94${NOC} ${CYA}Successfully started Apache 2, MySQL and PHP.${NOC}\\n"
}
global_includes
brew_start
if [ "$answer" != "${answer#[Yy]}" ]; then
brew_install
brew_packages
brew_startup
else
printf "${RED}%s\\n" "${TOP}"
printf '* %-76s %s\n' "OK, not installing Homebrew. Proceeding with the installation of the" "*"
printf '* %-76s %s\n' "PHP, MySQL and Apache 2 packages from Homebrew." "*"
printf "%s${NOC}\\n\\n" "${BOTTOM}"
brew_packages
brew_startup
fi
exit 0