-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdlunzipwp.sh
134 lines (113 loc) · 3.7 KB
/
dlunzipwp.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
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
#!/bin/bash
clear
echo "======================https://github.com/fabianofm/dlunzipwp==============================="
echo "This script helps you to download, unzip the WordPress and added your database information."
echo "Finish run the WordPress installation script by accessing the URL in a web browser."
echo "==========================================================================================="
echo "WordPress Version (e.g.: 5.4.2): "
read WORDPRESS_VERSION
echo "Database Name: "
read dbname
echo "Database User: "
read dbuser
echo "Database Password: "
read dbpass
echo "Database Hostname: "
read dbhostname
echo "select the language"
echo " 1) English"
echo " 2) Português pt_BR"
echo " 3) Português pt_PT"
echo " 4) Español es_ES"
read nlang
case $nlang in
1)
URL=https://wordpress.org/wordpress-$WORDPRESS_VERSION.tar.gz
setlanguage="en"
;;
2)
URL=https://br.wordpress.org/wordpress-$WORDPRESS_VERSION-pt_BR.tar.gz
setlanguage="pt_BR"
;;
3)
URL=https://pt.wordpress.org/wordpress-$WORDPRESS_VERSION-pt_PT.tar.gz
setlanguage="pt_PT"
;;
4)
URL=https://es.wordpress.org/wordpress-$WORDPRESS_VERSION-es_ES.tar.gz
setlanguage="es_ES"
;;
*) echo "invalid option" ;;
esac
echo "For $setlanguage WP $WORDPRESS_VERSION ($URL.sha1)"
echo "Calculates and verifies SHA-1 hashes? (y/n)"
read answerverifies
if [ "$answerverifies" != "${answerverifies#[Yy]}" ]; then
echo "Enter the code sha1: "
read WORDPRESS_SHA1
fi
echo "run install? (y/n)"
read run
if [ "$run" = n ]; then # POSIX sh
exit
else
echo "============================================"
echo " Installing WordPress"
echo "============================================"
#download wordpress
curl -o wordpress.tar.gz -fSL "$URL"
[ ! -z "$WORDPRESS_SHA1" ] && echo "$WORDPRESS_SHA1 *wordpress.tar.gz" | sha1sum -c -
#extract the contents - wordpress
tar -xzf wordpress.tar.gz
#change dir to wordpress
cd wordpress
#copy file to parent dir
cp -rf . ..
#move back to parent dir
cd ..
#remove files from wordpress folder
rm -R wordpress
#create wp config
cp wp-config-sample.php wp-config.php
if [ "$setlanguage" = "pt_BR" ]; then
txtDatabaseName="nome_do_banco_de_dados_aqui"
txtUsername="nome_de_usuario_aqui"
txtPassword="senha_aqui"
txtLocalhost="localhost"
txtSalt="coloque a sua frase única aqui"
else
txtDatabaseName="database_name_here"
txtUsername="username_here"
txtPassword="password_here"
txtLocalhost="localhost"
txtSalt="put your unique phrase here"
fi
#set database details with perl find and replace
perl -pi -e "s/$txtDatabaseName/$dbname/g" wp-config.php
perl -pi -e "s/$txtUsername/$dbuser/g" wp-config.php
perl -pi -e "s/$txtPassword/$dbpass/g" wp-config.php
perl -pi -e "s/$txtLocalhost/$dbhostname/g" wp-config.php
#set WP salts
perl -i -pe'
BEGIN {
@chars = ("a" .. "z", "A" .. "Z", 0 .. 9);
push @chars, split //, "!@#$%^&*()-_ []{}<>~\`+=,.;:/?|";
sub salt { join "", map $chars[ rand @chars ], 1 .. 64 }
}
s/'"$txtSalt"'/salt()/ge
' wp-config.php
mkdir wp-content/uploads
find . -type d | xargs chmod -v 755 # Change directory permissions rwxr-xr-x
find . -type f | xargs chmod -v 644 # Change file permissions rw-r--r--
#$SUDO_USER - To get the current "logged in" user (no root)
chown -R $SUDO_USER:www-data *
chmod -R 775 wp-content
echo "Cleaning..."
#remove tar
rm wordpress.tar.gz
#remove bash script
rm dlunzipwp.sh
echo "========================="
echo "Installation is complete."
echo "========================="
fi