Skip to content

Commit 968a0c4

Browse files
committed
rename files
1 parent f99d8b0 commit 968a0c4

File tree

4 files changed

+112
-5
lines changed

4 files changed

+112
-5
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/install_one_instance
2+

config

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
domain=dominio.org
2+
title=MyBlog2
3+
mysql_root_pass=biohazard
4+
wp_path=/var/www/$domain
5+
wp_charset=es_ES@UTF-8
6+
wp_locale=es_ES
7+
wp_admin_user=admin
8+
wp_admin_password=123456
9+
wp_admin_email=$wp_admin_user@$domain
10+
wp_db_host=localhost
11+
wp_db_user=wpuser1
12+
wp_db_password=123456
13+
wp_db_name=MyBlog2
14+
wpcli_user=wpcli

install_one_local_instance/install_wordpress.sh

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
#!/bin/bash
22

3-
43
if [ "$(id -u)" != "0" ]; then
54
echo "This script must be run as root" 1>&2
65
exit 1
76
fi
8-
9-
if [[ -e ./conf/config ]];then
7+
if [[ -e ./conf/config ]];then
108
source ./conf/config;
11-
else
9+
else
1210
iferror "First you need configure parameters"
13-
fi
11+
fi
1412

1513

1614
sudoers_root="root ALL=(ALL:ALL) ALL"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/bash
2+
3+
domain=dominioC.org
4+
5+
if [ "$(id -u)" != "0" ]; then
6+
echo "This script must be run as root" 1>&2
7+
exit 1
8+
fi
9+
10+
if [[ -e ./conf/config ]];then
11+
source ./conf/config;
12+
else
13+
iferror "First you need configure parameters"
14+
fi
15+
16+
17+
# function: read_root_path
18+
# Read root path from Nginx server
19+
20+
function read_root_path {
21+
if [[ -e /etc/sites-available/$domain.conf ]];then
22+
wp_path=$(grep -E "root.*$domain" /etc/sites-available/$domain.conf \
23+
| awk -F' ' '{print substr($2, 1, length($2)-1)}');
24+
else
25+
iferror "Site is not available";
26+
fi
27+
}
28+
29+
# function: get_config_parameters
30+
# Read wp-conging.php to get parameters needed to uninstall
31+
32+
function get_config_parameters {
33+
wp_cnf=$wp_path/wp-config.php
34+
35+
db_name=$(grep "DB_NAME" $wp_cnf | awk -F"'" '{print $4}')
36+
db_user=$(grep "DB_USER" $wp_cnf | awk -F"'" '{print $4}')
37+
db_password=$(grep "DB_PASSWORD" $wp_cnf | awk -F"'" '{print $4}')
38+
db_host=$(grep "DB_PASSWORD" $wp_cnf | awk -F"'" '{print $4}')
39+
if [ $db_host -eq '' ]; then
40+
db_host=localhost
41+
}
42+
43+
# function: mysql_remove_database
44+
# Remove database from mysql
45+
46+
function mysql_remove_database {
47+
SQL="drop database if exists $db_name";
48+
mysql -u$db_user -p$db_password -e $SQL || iferror "Database not removed";
49+
}
50+
51+
# function: remove_root_path
52+
# remove path of Wordpress installation
53+
54+
function remove_root_path {
55+
if [[ -d $wp_path ]]; then
56+
rm -rf $wp_path;
57+
else
58+
iferror "Root path does not exists"
59+
fi
60+
}
61+
62+
# function: nginx_disable_site
63+
# disable site from sites-enabled
64+
65+
function nginx_disable_site {
66+
if [[ -e /etc/nginx/sites-enabled/$domain.conf]]; then
67+
rm -f /etc/nginx/sites-enabled/$domain.conf;
68+
else
69+
iferror "Site is not enabled"
70+
fi
71+
}
72+
73+
#function nginx_remove_site
74+
# remove server from sites-available
75+
76+
function nginx_remove_site {
77+
if [[ -e /etc/nginx/sites-available/$domain.conf]]; then
78+
rm -f /etc/nginx/sites-available/$domain.conf;
79+
else
80+
iferror "Site is not available "
81+
fi
82+
}
83+
84+
function start {
85+
read_root_path \
86+
&& get_config_parameters \
87+
&& mysql_remove_database \
88+
&& remove_root_path \
89+
&& nginx_disable_site \
90+
&& nginx_remove_site
91+
}
92+
93+
start

0 commit comments

Comments
 (0)