-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwp-install.sh
209 lines (183 loc) · 8.09 KB
/
wp-install.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
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
#!/bin/bash
################################################################################
# This installer assumes that you are using:
# - LOCALHOST: a default MAMP installation (see: https://www.mamp.info/)
# - OS: Linux/Mac or a "Windows Bash" (search for: https://github.com/Microsoft/WSL)
################################################################################
# NB. MAMP must be started before this script
################################################################################
# Linux/Mac OS
################################################################################
# You MUST use bundled MAMP binaries:
# 1.Run: "nano ~.bash_profile"
# 2 Append the following lines:
# # Use MAMP version of: PHP, MySQL
# PHP_VERSION=`ls /Applications/MAMP/bin/php/ | sort -n | tail -1`
# export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH
# alias mysql='/Applications/MAMP/Library/bin/mysql'
# 3. Run: "source ~.bash_profile"
################################################################################
################################################################################
# Windows Subsystem for Linux ("Windows Bash")
################################################################################
# You MUST use native Windows binaries:
# 1.Run: "nano ~.bash_profile"
# 2 Append the following lines:
# # Use Windows versions of: PHP, WP-CLI, Composer
# alias php=php.exe
# alias wp='cmd.exe /c wp'
# alias composer='cmd.exe /c composer'
# 3. Run: "source ~.bash_profile"
################################################################################
################################################################################
# Detect OS Type
################################################################################
if grep -q Microsoft /proc/version; then
OS_TYPE="Windows Subsystem for Linux"
else
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine="Linux";;
Darwin*) machine="Mac";;
CYGWIN*) machine="Cygwin";;
MINGW*) machine="MinGw";;
*) machine="UNKNOWN:${unameOut}"
esac
OS_TYPE="Linux System: ${machine}"
if [ "$machine" = "Cygwin" ] || [ "$machine" = "MinGw" ]; then
echo -e "-------------------------------------------------------------"
echo -e "Your OS type: \033[1;33m\"$OS_TYPE\"\033[m\n"
echo -e "If you are running this on Windows,"
echo -e "retry within a: \033[1;33m\"Windows Subsystem for Linux (\"Windows Bash\")\"\033[m\n"
echo -e "\033[1;33mREMEMBER:\033[m ----------------------------------------------------"
echo -e "You MUST use native Windows binaries,"
echo -e "to achieve this, perform the following steps:\n"
echo -e " 1.Run: \"nano ~.bash_profile\"\n"
echo -e " 2 Append the following lines:\n"
echo -e "\t# Use Windows versions of: PHP, WP-CLI, Composer"
echo -e "\talias php=php.exe"
echo -e "\talias wp='cmd.exe /c wp'"
echo -e "\tcomposer: alias composer='cmd.exe /c composer'\n"
echo -e " 3. Run: \"source ~.bash_profile\""
echo -e "-------------------------------------------------------------"
read
exit;
fi
fi
################################################################################
# If present load bash aliases
################################################################################
shopt -s expand_aliases
if [ -f ~/.bash_profile ]; then
. ~/.bash_profile
fi
################################################################################
# Default options
################################################################################
LOCALE="it_IT"
DB_HOST='127.0.0.1'
DB_USER='root'
DB_PASS='root'
DB_PREFIX=''
CURRENT_FOLDER_NAME=${PWD##*/}
ADMIN_USER='admin'
ADMIN_PASSWORD='admin'
ADMIN_EMAIL='admin@example.com'
################################################################################
# Print some info
################################################################################
printf "\033[1;33mwp-config.php\033[m -----------------------------------------\n"
printf " DEBUG\t\t= \033[1;33menabled\033[m\n"
printf " MEMORY_LIMIT\t= \033[1;33m256MB\033[m\n"
echo "-------------------------------------------------------"
printf " installation-folder\t= \033[1;33m$PWD\033[m\n"
printf " login-url\t\t= \033[1;33mhttp://$DB_HOST/$CURRENT_FOLDER_NAME/wp-login.php\033[m\n"
printf " admin user\t\t= \033[1;33m$ADMIN_USER\033[m\n"
printf " admin password\t\t= \033[1;33m$ADMIN_PASSWORD\033[m\n"
echo "-------------------------------------------------------"
printf "\n"
printf "Your OS: \033[1;33m$OS_TYPE\033[m\n\n"
#printf "WordPress Admin Username: "
#read ADMIN_USER
#printf "WordPress Admin Password: "
#read ADMIN_PASSWORD
WP_GIT_FILES="wp-cli.yml\|one-click-install.sh\|composer.json\|.git\|.gitattributes\|.gitattributes\|.gitignore\|_config.yml\|README.md\|commands.md"
# Check for previous worpdress installation files.
if [[ -f ./wp-config.php ]]; then
printf "\033[1;4;31mWARNING\e[24m:\e[0m WordPress files seem to already be present here.\n"
read -p "Do you want to completely delete this installation? [y/n] " delete
if [[ $delete == [yY] ]]; then ## Only delete the file if y or Y is pressed.
rm -rf `ls | grep -v $WP_GIT_FILES` && echo "Files deleted."
else
echo "Installation aborted."
exit;
fi
fi
################################################################################
# Install WordPress and create the wp-config.php file...
################################################################################
wp core download --locale=$LOCALE
wp core config --dbname=$CURRENT_FOLDER_NAME --dbuser=$DB_USER --dbpass=$DB_PASS --dbhost=$DB_HOST --dbprefix=$DB_PREFIX --extra-php <<PHP
/**
* Enable WP DEBUGGING
*/
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true); // see: /wp-content/debug.log
define('WP_DEBUG_DISPLAY', true);
/**
* Increase WP MEMORY LIMIT
*/
define('WP_MEMORY_LIMIT', '256M'); // front-end area
define('WP_MAX_MEMORY_LIMIT', '256M'); // wp-admin area
/**
* Trick: fix some relative paths
*/
define('WP_CONTENT_URL', 'http://'.\$_SERVER['HTTP_HOST'].'/'.basename(__DIR__).'/wp-content');
/**
* Disable the Plugin and Theme Editor
*/
define( 'DISALLOW_FILE_EDIT', true );
/**
* Disable Plugin and Theme Update and Installation
*/
//define( 'DISALLOW_FILE_MODS', true );
/**
* Disable All Automatic Updates
*/
define( 'AUTOMATIC_UPDATER_DISABLED', true );
PHP
wp db reset --yes
wp core install --title=$CURRENT_FOLDER_NAME --url="http://$DB_HOST/$CURRENT_FOLDER_NAME" --admin_user=$ADMIN_USER --admin_password=$ADMIN_PASSWORD --admin_email=$ADMIN_EMAIL --skip-email
################################################################################
# Install Composer dependencies
################################################################################
composer install
################################################################################
# Finalize Wordpress Installation
################################################################################
# Update WordPress options
wp option update permalink_structure '/%postname%/'
#wp option update default_ping_status 'closed'
#wp option update default_pingback_flag '0'
# Generate .htaccess file
wp rewrite flush --hard
# Remove defaults plugins
wp plugin delete hello
# Install and activate defaults plugins
#wp plugin install abt-relative-urls add-custom-post-types-archive-to-nav-menus hide-update-reminder underconstruction better-wp-security backwpup --activate
# Install defaults plugins
#wp plugin install gravity-forms-placeholders disqus-comment-system regenerate-thumbnails widget-classes custom-post-widget jetpack w3-total-cache wordpress-seo
# Update plugins
wp plugin update --all
# BackWPup options
#wp option update backwpup_cfg_showadminbar '0'
# Import photo samples
#wp media import https://dl.dropboxusercontent.com/u/15052756/photo-samples/flowers-01.jpg
# wp config set WP_DEBUG true --raw
# wp config set WP_DEBUG_LOG true --raw
# wp config set WP_DEBUG_DISPLAY true --raw
# wp config set WP_MEMORY_LIMIT true --raw
# Activate and configure All-In-One-WP-Migration
wp plugin activate all-in-one-wp-migration
mkdir -p wp-content/ai1wm-backups/
mkdir -p wp-content/plugins/all-in-one-wp-migration/storage