-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlamp
executable file
·372 lines (339 loc) · 12.5 KB
/
lamp
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
#!/bin/bash
# Text Reset
RESET='\e[0m'
BLINK='\e[5m'
# Regular Colors
BLACK='\e[0;30m'
RED='\e[0;31m'
GREEN='\e[0;32m'
YELLOW='\e[0;33m'
BLUE='\e[0;34m'
PURPLE='\e[0;35m'
CYAN='\e[0;36m'
WHITE='\e[0;37m'
clear
echo -e "${CYAN}=================================================================${RESET}"
echo -e "${GREEN} Awesome LAMP Installer!! ${RESET}"
echo -e "${CYAN}=================================================================${RESET}"
# Update the machine
echo -e "${GREEN}Updating the system...${RESET}"
sudo apt update
sudo apt -y upgrade
sudo apt -y dist-upgrade
echo -e "${GREEN}Your system is up-to-date${RESET}"
echo "================================================================="
# Install Apache Web Server
echo -e "${GREEN}Instaling Apache...${RESET}"
sudo apt install -y apache2 apache2-utils
echo -e "${GREEN}Apache Successfully Installed${RESET}"
echo "================================================================="
# Install MySQL Database Server
echo -e "${GREEN}Instaling MySQL...${RESET}"
sudo apt install -y mysql-server
sudo apt install -y mysql-client
echo -e "${GREEN}MySQL Successfully Installed${RESET}"
echo "================================================================="
# Install PHP7.2
echo -e "${GREEN}Instaling PHP7.2...${RESET}"
sudo apt install -y php7.2
sudo apt install -y php7.2-mysql
sudo apt install -y php7.2-curl
sudo apt install -y php7.2-json
sudo apt install -y php7.2-cgi
sudo apt install -y php7.2-bz2
sudo apt install -y php7.2-gd
sudo apt install -y php7.2-mbstring
sudo apt install -y php7.2-xml
sudo apt install -y php7.2-xmlrpc
sudo apt install -y php7.2-zip
sudo apt install -y php-curl
sudo apt install -y php-json
sudo apt install -y php-cgi
sudo apt install -y unzip
sudo apt install -y curl
echo -e "${GREEN}PHP7.2 Package Successfully Installed${RESET}"
echo "================================================================="
# Install pip
echo -e "${GREEN}Instaling pip...${RESET}"
sudo apt install -y python-pip
echo -e "${GREEN}pip Installed Successfully${RESET}"
echo "================================================================="
# Update the machine
echo -e "${GREEN}Updating the System...${RESET}"
sudo apt update
sudo apt -y upgrade
sudo apt -y dist-upgrade
echo -e "${GREEN}Your system is up-to-date${RESET}"
echo "================================================================="
# Reset the MySQL Password
echo -e "${GREEN}Reseting the MySQL Passowrd...${RESET}"
sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';"
mysql -u root -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root'; FLUSH privileges;"
echo -e "${GREEN}MySQL Password Reseted.${RESET}"
echo "================================================================="
# Create a folder for PHP error log
sudo mkdir /var/log/php
sudo chown www-data /var/log/php
# Enable Apache Module
echo -e "${GREEN}Enabling Apache Module...${RESET}"
sudo a2enmod deflate expires ext_filter filter headers php7.2 reflector rewrite session_cookie session include
echo -e "${GREEN}Necessary Apache Module Enabled${RESET}"
echo "================================================================="
# Cleanup the System
echo -e "${GREEN}Update & Cleanup the System...${RESET}"
sudo apt update
sudo apt -y upgrade
sudo apt -y autoremove
sudo apt -y autoclean
sudo apt -y remove
sudo apt -y clean
echo -e "${GREEN}Done${RESET}"
echo "================================================================="
# Install phpMyAdmin
if [[ $(dpkg-query -W -f='${Status}' phpmyadmin 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then
echo -e "${GREEN}Instaling phpMyAdmin...${RESET}"
sudo apt install -y phpmyadmin
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin
echo -e "${GREEN}Done${RESET}"
else
echo -e "${GREEN}phpMyAdmin already Installed${RESET}"
fi
# Restart the Apache
echo -e "${GREEN}Restarting Apache...${RESET}"
sudo systemctl restart apache2.service
echo -e "${GREEN}Done${RESET}"
echo "================================================================="
# Output success message
echo -e "\nYour machine has been setup"
echo "---------------------------------"
echo -e "MySQL is available on port ${YELLOW}3609${RESET} with username '${YELLOW}root${RESET}' and password '${YELLOW}root${RESET}'"
echo " (you have to use 127.0.0.1 as opposed to 'localhost')"
echo "Apache is available on port 80"
echo -e "Head over to${BLUE}${BLINK} http://localhost${RESET} to get started"
echo -e "${PURPLE}Choose your below options to install additional package${RESET}"
# ----------------------------------
# Step #1: User defined function
# ----------------------------------
pause() {
read -p "Press [Enter] key to continue..." fackEnterKey
}
# Install Google Chrome
chrome() {
if [[ $(dpkg-query -W -f='${Status}' google-chrome-stable 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then
echo -e "${GREEN}Installing Google Chrome...${RESET}"
rm -rf ~/Downloads/google-chrome-stable_current_amd64.deb
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -P ~/Downloads/
sudo dpkg -i ~/Downloads/google-chrome-stable_current_amd64.deb
sudo apt -f install
rm -rf ~/Downloads/google-chrome-stable_current_amd64.deb
echo -e "${GREEN}Done...${RESET}"
echo "================================================================="
else
echo -e "${GREEN}Google Chrome already Installed${RESET}"
fi
}
# Install ATOM Editor
atom() {
if [[ $(dpkg-query -W -f='${Status}' atom 2>/dev/null | grep -c "ok installed") -eq 0 ]]; then
echo -e "${GREEN}Installing ATOM Editor...${RESET}"
curl -sL https://packagecloud.io/AtomEditor/atom/gpgkey | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main" > /etc/apt/sources.list.d/atom.list'
sudo apt update
sudo apt install -y atom
# Sync Setting ATOM Package
apm install sync-settings
# Beautysh
pip install beautysh
# PHP-CS-FIXER
sudo wget https://cs.symfony.com/download/php-cs-fixer-v2.phar -O /usr/local/bin/php-cs-fixer
sudo chmod a+x /usr/local/bin/php-cs-fixer
echo -e "${GREEN}Done...${RESET}"
echo "================================================================="
else
echo -e "${GREEN}ATOM already Installed${RESET}"
fi
}
# Install GIMP
gimp() {
echo -e "${GREEN}Installing GIMP...${RESET}"
sudo apt install -y gimp
echo -e "${GREEN}Done...${RESET}"
echo "================================================================="
}
# Install FileZilla
filezilla() {
echo -e "${GREEN}Installing FileZilla...${RESET}"
sudo apt install -y filezilla
echo -e "${GREEN}Done...${RESET}"
echo "================================================================="
}
# Install VLC Player
vlc() {
echo -e "${GREEN}Installing VLC Player...${RESET}"
sudo apt install -y vlc
echo -e "${GREEN}Done...${RESET}"
echo "================================================================="
# Install full multimedia support
echo -e "${GREEN}Installong full multimedia support...${RESET}"
sudo apt install -y ubuntu-restricted-extras
sudo apt install -y libavcodec-extra
echo -e "${GREEN}Done...${RESET}"
echo "================================================================="
}
# Install VIM Editor
vim() {
echo -e "${GREEN}Installing VIM Editor...${RESET}"
sudo apt install -y vim
echo -e "${GREEN}Done...${RESET}"
echo "================================================================="
}
# Install YouTube Downloader
youtube_dl() {
echo -e "${GREEN}Installing YouTube Downloader...${RESET}"
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
echo -e "${GREEN}Done...${RESET}"
echo "================================================================="
}
# Install Composer
install_composer() {
echo -e "${GREEN}Installing Composer...${RESET}"
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >>~/.bash_profile
source ~/.bash_profile
composer --version
echo -e "${GREEN}Done...${RESET}"
echo "================================================================="
}
# Install Drush
drush() {
echo -e "${GREEN}Installing Drush...${RESET}"
sudo wget https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar -O /usr/local/bin/drush
sudo chmod +x /usr/local/bin/drush
composer clearcache
composer global require drush/drush
echo -e "${GREEN}Done...${RESET}"
echo "================================================================="
}
# Install WP-CLI
wp_cli() {
echo -e "${GREEN}Installing WP-CLI...${RESET}"
sudo wget --no-check-certificate --content-disposition https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
sudo chmod +x /usr/local/bin/wp
wget --no-check-certificate --content-disposition https://github.com/wp-cli/wp-cli/raw/master/utils/wp-completion.bash -O ~/wp-completion.bash
echo 'source /home/$USER/wp-completion.bash' >>~/.bashrc
source ~/.bashrc
echo -e "${GREEN}Done...${RESET}"
echo "================================================================="
}
# Install Clam AntiVirus
clam() {
echo -e "${GREEN}Installing Clam AntiVirus...${RESET}"
sudo apt install -y clamav
sudo sed -i -e "s/^NotifyClamd/#NotifyClamd/g" /etc/clamav/freshclam.conf
sudo systemctl stop clamav-freshclam
sudo freshclam
sudo systemctl start clamav-freshclam
echo -e "${GREEN}Done...${RESET}"
echo -e "Run Scan: ${YELLOW}clamscan --infected --remove --recursive /home${RESET}"
echo "================================================================="
}
# Install Postfix
postfix() {
echo -e "${GREEN}Installing Postfix...${RESET}"
sudo apt-get update
sudo apt-get install -y postfix
sudo apt-get install -y mailutils
sudo systemctl restart postfix.service
echo -e "${GREEN}Done...${RESET}"
echo "================================================================="
}
# Install Additional Packages
tweak_tool() {
echo -e "${GREEN}Installing Additional Packages...${RESET}"
sudo apt install -y gnome-tweak-tool
sudo apt install -y dos2unix
sudo apt install -y apcalc
sudo apt install -y putty-tools
# Installing Latest Git
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install -y git
# Instaling MELD
sudo apt install -y meld
echo -e "${GREEN}Done...${RESET}"
echo "================================================================="
}
all() {
chrome
atom
gimp
filezilla
vlc
vim
youtube_dl
install_composer
drush
wp_cli
clam
postfix
tweak_tool
}
# function to display menus
show_menus() {
# clear
echo "~~~~~~~~~~~~~~~~~~~~~"
echo -e ${GREEN}" MAIN MENU "${RESET}
echo "~~~~~~~~~~~~~~~~~~~~~"
echo -e ${CYAN}"1. Google Chrome"${RESET}
echo -e ${CYAN}"2. ATOM"${RESET}
echo -e ${CYAN}"3. GIMP"${RESET}
echo -e ${CYAN}"4. FileZilla"${RESET}
echo -e ${CYAN}"5. VLC"${RESET}
echo -e ${CYAN}"6. VIM"${RESET}
echo -e ${CYAN}"7. YouTube dl"${RESET}
echo -e ${CYAN}"8. Composer"${RESET}
echo -e ${CYAN}"9. Drush"${RESET}
echo -e ${CYAN}"10. WP CLI"${RESET}
echo -e ${CYAN}"11. Install Clam AntiVirus"${RESET}
echo -e ${CYAN}"12. Install Postfix"${RESET}
echo -e ${CYAN}"13. Gnome Tweak Tool"${RESET}
echo -e ${CYAN}"14. Install all the above Packages"${RESET}
echo -e ${CYAN}"15. Exit"${RESET}
}
# Read input from the keyboard and take a action
read_options() {
local choice
read -p "Enter choice [ 1 - 15] " choice
case $choice in
1) chrome ;;
2) atom ;;
3) gimp ;;
4) filezilla ;;
5) vlc ;;
6) vim ;;
7) youtube_dl ;;
8) install_composer ;;
9) drush ;;
10) wp_cli ;;
11) clam ;;
12) postfix ;;
13) tweak_tool ;;
14) all ;;
15) exit 0 ;;
*) echo -e "${RED}Error...${RESET}" && sleep 2 ;;
esac
}
# ----------------------------------------------
# Step #2: Trap CTRL+C, CTRL+Z and quit singles
# ----------------------------------------------
trap '' SIGINT SIGQUIT SIGTSTP
# -----------------------------------
# Step #3: Main logic - infinite loop
# ------------------------------------
while true; do
show_menus
read_options
done