-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·385 lines (341 loc) · 13.1 KB
/
install
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
373
374
375
376
377
378
379
380
381
382
383
384
385
#!/bin/bash
###############################################################################
# PHANTOMPHP #
# #
# Author: Uthman Oladele #
# GitHub Repo: https://github.com/codetesla51/phantomphp#
# Personal Website: https://dev-uthman.vercel.app #
# #
# ─────────────────────────────────────────────────────────────────────────── #
# A versatile and efficient PHP server for Termux, designed to empower #
# developers with features that streamline PHP app development. #
# #
# Features: #
# • Port Forwarding: Effortlessly forward ports for external access. #
# • Port Selection: Flexible port assignment, including auto-configuration.#
# • phpMyAdmin Integration: Easy database management from Termux. #
# • Direct PHP Execution: Instantly run PHP files from the terminal. #
# #
# ─────────────────────────────────────────────────────────────────────────── #
# Licensed under the MIT License: #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
# to deal in the Software without restriction, including without limitation #
# the rights to use, copy, modify, merge, publish, distribute, sublicense, #
# and/or sell copies of the Software, and to permit persons to whom the #
# Software is furnished to do so, subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be included in #
# all copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
# DEALINGS IN THE SOFTWARE. #
###############################################################################
# Define color codes for text formatting
RED='\033[1;91m'
GREEN='\033[1;92m'
YELLOW='\033[1;93m'
BLUE='\033[1;94m'
CYAN='\033[1;96m'
MAGENTA='\033[1;95m'
GREY='\033[1;90m'
BOLD='\033[1m' # Bold text
NC='\033[0m' # Reset to no color
# Function to print text in red
red() {
echo -e "${RED}$1${NC}"
}
# Function to print text in green
green() {
echo -e "${GREEN}$1${NC}"
}
# Function to print text in yellow
yellow() {
echo -e "${YELLOW}$1${NC}"
}
# Function to print text in blue
blue() {
echo -e "${BLUE}$1${NC}"
}
# Function to print text in cyan
cyan() {
echo -e "${CYAN}$1${NC}"
}
# Function to print text in magenta
magenta() {
echo -e "${MAGENTA}$1${NC}"
}
# Function to print text in grey
grey() {
echo -e "${GREY}$1${NC}"
}
space(){
echo -e "\n";
}
# Function to install the server
install_server() {
clear
sleep 2
echo -e "${GREEN}
▄▄▄▄▄▄▄▄▄▄▄▄
▄█▀▀▀▀▀▀▀▀▀▀▀▀▀█▄
▄█▀ ▄▄▄▄▄▄ ▀█▄
██ ██████████ ██
██ ██████████ ██
██ ██████████ ██
▀█▄ ▀████▀ ▄█▀u
▀▀▀▄▄▄▄▄▄▄▀▀▀
PhantomPHP Server
Fast and Reliable.
Made by Uthman Dev
${NC}"
echo -e "\n"
set -e
green "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
green " 🌟 Installing Phantom-PHP 🌟 "
green "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
space
green "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
blue " Checking Dependencies..."
green "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
sleep 1
# Check PHP installation
blue "➔ Checking if PHP is installed..."
space
sleep 1
if command -v php >/dev/null 2>&1; then
green "✔ PHP is installed\n"
else
red "✘ PHP is not installed!"
read -p "👉 Would you like to install PHP now? (y/n): " choice
if [[ "$choice" =~ ^[yY]$ ]]; then
yellow "🚀 Installing PHP..."
apt install php -y
until command -v php >/dev/null 2>&1; do
sleep 1
done
green "✔ PHP installed successfully!\n"
else
red "⚠ PHP is required to proceed. Exiting..."
exit 1
fi
fi
sleep 1
# Check MySQL installation
blue "➔ Checking if MySQL is installed..."
space
sleep 1
if command -v mysql >/dev/null 2>&1; then
green "✔ MySQL is installed\n"
else
red "✘ MySQL is not installed!"
read -p "👉 Would you like to install MySQL now? (y/n): " choice
if [[ "$choice" =~ ^[yY]$ ]]; then
yellow "🚀 Installing MySQL..."
apt install phpmyadmin -y
until command -v mysql >/dev/null 2>&1; do
sleep 1
done
green "✔ MySQL installed successfully!\n"
else
red "⚠ MySQL is required to proceed. Exiting..."
exit 1
fi
fi
sleep 1
# Check MariaDB installation
blue "➔ Checking if MariaDB is installed..."
space
sleep 1
if command -v mariadb >/dev/null 2>&1; then
green "✔ MariaDB is installed\n"
else
red "✘ MariaDB is not installed!"
read -p "👉 Would you like to install MariaDB now? (y/n): " choice
if [[ "$choice" =~ ^[yY]$ ]]; then
yellow "🚀 Installing MariaDB..."
apt install mariadb -y
until command -v mariadb >/dev/null 2>&1; do
sleep 1
done
green "✔ MariaDB installed successfully!\n"
else
red "⚠ MariaDB is required to proceed. Exiting..."
exit 1
fi
fi
sleep 1
green "🎉 All dependencies are installed! Preparing Phantom-PHP...\n"
sleep 1
yellow "🚀 Setting up Phantom-PHP...\n"
sleep 1
createSymlink
sleep 1
blue "🛠 Initializing phpMyAdmin server...\n"
sleep 1
cd || exit
mysql_install_db &>/dev/null
mariadbd-safe -u root &>/dev/null &
if cd ../usr/share/phpmyadmin &>/dev/null; then
green "✔ Navigated to phpMyAdmin directory"
else
red "✘ phpMyAdmin directory not found!"
exit 1
fi
if [ -f "config.inc.php" ]; then
yellow "⚠ config.inc.php file already exists. Replacing..."
rm config.inc.php &>/dev/null
fi
yellow "📄 Creating a new config.inc.php file..."
cat <<EOF > config.inc.php
<?php
/**
* phpMyAdmin sample configuration, you can use it as base for
* manual configuration. For easier setup you can use setup/
*
* All directives are explained in documentation in the doc/ folder
* or at <https://docs.phpmyadmin.net/>.
*/
declare(strict_types=1);
/**
* This is needed for cookie-based authentication to encrypt the cookie.
* Needs to be a 32-bytes long string of random bytes. See FAQ 2.10.
*/
\$cfg['blowfish_secret'] = 'YOUR_RANDOM_32_BYTE_STRING_HERE'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/**
* Servers configuration
*/
\$i = 0;
/**
* First server
*/
\$i++;
/* Authentication type */
\$cfg['Servers'][\$i]['auth_type'] = 'cookie';
/* Server parameters */
\$cfg['Servers'][\$i]['host'] = '127.0.0.1';
\$cfg['Servers'][\$i]['compress'] = false;
\$cfg['Servers'][\$i]['AllowNoPassword'] = true;
/**
* phpMyAdmin configuration storage settings.
*/
/* User used to manipulate with storage */
// \$cfg['Servers'][\$i]['controlhost'] = '';
// \$cfg['Servers'][\$i]['controlport'] = '';
// \$cfg['Servers'][\$i]['controluser'] = 'pma';
// \$cfg['Servers'][\$i]['controlpass'] = 'pmapass';
/* Storage database and tables */
// \$cfg['Servers'][\$i]['pmadb'] = 'phpmyadmin';
// \$cfg['Servers'][\$i]['bookmarktable'] = 'pma__bookmark';
// \$cfg['Servers'][\$i]['relation'] = 'pma__relation';
// \$cfg['Servers'][\$i]['table_info'] = 'pma__table_info';
// \$cfg['Servers'][\$i]['table_coords'] = 'pma__table_coords';
// \$cfg['Servers'][\$i]['pdf_pages'] = 'pma__pdf_pages';
// \$cfg['Servers'][\$i]['column_info'] = 'pma__column_info';
// \$cfg['Servers'][\$i]['history'] = 'pma__history';
// \$cfg['Servers'][\$i]['table_uiprefs'] = 'pma__table_uiprefs';
// \$cfg['Servers'][\$i]['tracking'] = 'pma__tracking';
// \$cfg['Servers'][\$i]['userconfig'] = 'pma__userconfig';
// \$cfg['Servers'][\$i]['recent'] = 'pma__recent';
// \$cfg['Servers'][\$i]['favorite'] = 'pma__favorite';
// \$cfg['Servers'][\$i]['users'] = 'pma__users';
// \$cfg['Servers'][\$i]['usergroups'] = 'pma__usergroups';
// \$cfg['Servers'][\$i]['navigationhiding'] = 'pma__navigationhiding';
// \$cfg['Servers'][\$i]['savedsearches'] = 'pma__savedsearches';
// \$cfg['Servers'][\$i]['central_columns'] = 'pma__central_columns';
// \$cfg['Servers'][\$i]['designer_settings'] = 'pma__designer_settings';
// \$cfg['Servers'][\$i]['export_templates'] = 'pma__export_templates';
/**
* End of servers configuration
*/
/**
* Directories for saving/loading files from server
*/
\$cfg['UploadDir'] = '';
\$cfg['SaveDir'] = '';
EOF
if [ $? -eq 0 ]; then
green "✔ phpMyAdmin setup completed successfully!"
else
red "✘ Failed to create config.inc.php file."
exit 1
fi
green "🎉 Phantom-PHP installation complete! Ready to use!"
}
createSymlink() {
green "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
green " Setting up PhantomPHP "
green "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
space
blue "➔ Checking if 'phantomphp' folder exists..."
sleep 1
if [[ ! -d "$HOME/phantomphp" ]]; then
red "✘ Error: 'phantomphp' folder not found in the home directory."
return 1
fi
green "✔ Found 'phantomphp' folder."
space
# Check if PhantomPHP script is executable
blue "➔ Verifying 'PhantomPHP' script permissions..."
sleep 1
if [[ ! -x "$HOME/phantomphp/bin/phantom" ]]; then
yellow "⚠ 'PhantomPHP' is not executable. Fixing permissions..."
chmod +x "$HOME/phantomphp/bin/phantom"
if [[ $? -ne 0 ]]; then
red "✘ Error: Failed to make 'PhantomPHP' executable."
return 1
fi
green "✔ 'PhantomPHP' is now executable."
else
green "✔ 'PhantomPHP' is already executable."
fi
space
# Check or create the symlink
blue "➔ Checking if symlink exists in '$HOME/bin'..."
sleep 1
if [[ ! -L "$HOME/bin/phantom" ]]; then
yellow "⚠ Symlink not found. Creating symlink for 'PhantomPHP'..."
ln -s "$HOME/phantomphp/bin/phantom" "$HOME/bin/phantom"
if [[ $? -eq 0 ]]; then
green "✔ Symlink created: $HOME/bin/phantom"
else
red "✘ Error: Failed to create symlink."
return 1
fi
else
yellow "⚠ Symlink already exists: $HOME/bin/phantom"
fi
space
# Add alias to ~/.bashrc
blue "➔ Checking for alias in '.bashrc'..."
sleep 1
if ! grep -q 'alias phantom=' ~/.bashrc; then
yellow "⚠ Alias for 'phantomphp' not found. Adding alias..."
echo 'alias sgit="$HOME/bin/phantomphp"' >> ~/.bashrc
green "✔ Alias added to '.bashrc'."
else
yellow "⚠ Alias for 'phantom' already exists in '.bashrc'."
fi
space
# Reload bash configuration
blue "➔ Applying changes to shell..."
sleep 1
source ~/.bashrc
if [[ $? -eq 0 ]]; then
green "✔ All changes applied successfully. PhantomPHP is ready to use!"
else
red "✘ Error: Failed to reload '.bashrc'."
fi
space
green "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
green " PhantomPHP setup complete! "
green "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
space
}
install_server