This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·147 lines (124 loc) · 6.82 KB
/
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
#!bin/bash
# https://developer.wordpress.org/cli/commands/
WP_CONFIG=wp-config.php;
URL=http://localhost:8000;
TITLE=WPClothes2Order-test-env;
ADMIN_USER=admin;
ADMIN_PASS=password;
C20_PLUGIN=WPClothes2Order;
REPO_USER=AshleyRedman;
# Update local packages & install git
echo "------------------------------------------------------------------------------------------------------------"
echo "Updating & installing local packages";
echo "------------------------------------------------------------------------------------------------------------"
apt-get update;
apt-get upgrade -y;
echo "------------------------------------------------------------------------------------------------------------"
echo "Installing git";
echo "------------------------------------------------------------------------------------------------------------"
apt-get install -y git;
# Install WP-CLI
echo "------------------------------------------------------------------------------------------------------------"
echo "Installing the WP CLI";
echo "------------------------------------------------------------------------------------------------------------"
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar;
php wp-cli.phar --info;
chmod +x wp-cli.phar;
mv wp-cli.phar /usr/local/bin/wp;
# Update WP to latest stable
echo "------------------------------------------------------------------------------------------------------------"
echo "Updating WP CLI to the latest stable build";
echo "------------------------------------------------------------------------------------------------------------"
wp cli update --stable --yes --color --allow-root;
# Allow chance for MySQL to be ready & wait for config to be generated
echo "------------------------------------------------------------------------------------------------------------"
until [ -f $WP_CONFIG ]
do
echo "$WP_CONFIG not found, waiting for it to be generated...";
sleep 5;
done
echo "------------------------------------------------------------------------------------------------------------"
echo "$WP_CONFIG found...";
# Setup WP & base admin user
echo "------------------------------------------------------------------------------------------------------------"
echo "Auto installing WordPress";
echo "------------------------------------------------------------------------------------------------------------"
wp core install --url=$URL --title=$TITLE --admin_user=$ADMIN_USER --admin_password=$ADMIN_PASS --admin_email=$ADMIN_EMAIL --color --allow-root;
# Update WordPress core version
echo "------------------------------------------------------------------------------------------------------------"
echo "Updating WordPress to the latest stable build";
echo "------------------------------------------------------------------------------------------------------------"
wp core update --color --allow-root;
# Set correct permalink strucutre
echo "------------------------------------------------------------------------------------------------------------"
echo "Setting correct permalink structure";
echo "------------------------------------------------------------------------------------------------------------"
wp rewrite structure '/%postname%/' --hard --color --allow-root;
# Remove must-use dir & re-create
echo "------------------------------------------------------------------------------------------------------------"
echo "Cleaning up must-use plugins";
echo "------------------------------------------------------------------------------------------------------------"
rm -r wp-content/mu-plugins;
mkdir wp-content/mu-plugins;
# Setup any mu-plugins
echo "------------------------------------------------------------------------------------------------------------"
echo "Setting up must use plugins";
echo "------------------------------------------------------------------------------------------------------------"
# Define constants
touch wp-content/mu-plugins/env.php;
echo "<?php define('WP_ENVIRONMENT_TYPE', 'local');" >> wp-content/mu-plugins/env.php;
# Skip WC setup wizard
touch wp-content/mu-plugins/wc.php;
echo "<?php add_filter('woocommerce_prevent_automatic_wizard_redirect', '__return_true');" >> wp-content/mu-plugins/wc.php;
# Install the spatie ray WP plugin, see https://spatie.be/docs/ray/v1/installation-in-your-project/wordpress
git clone https://github.com/spatie/wordpress-ray.git wp-content/mu-plugins/wordpress-ray;
touch wp-content/mu-plugins/ray-loader.php;
echo "<?php require WPMU_PLUGIN_DIR.'/wordpress-ray/wp-ray.php';" >> wp-content/mu-plugins/ray-loader.php;
# Remove plugins that come with WP
echo "------------------------------------------------------------------------------------------------------------"
echo "Removing default plugins";
echo "------------------------------------------------------------------------------------------------------------"
wp plugin delete hello --color --allow-root;
wp plugin delete akismet --color --allow-root;
# Insatll WC
echo "------------------------------------------------------------------------------------------------------------"
echo "Installing Woocommerce";
echo "------------------------------------------------------------------------------------------------------------"
wp plugin install woocommerce --force --activate --color --allow-root;
# Pull the wpc2o plugin and set to the dev branch ready to branched off
echo "------------------------------------------------------------------------------------------------------------"
echo "Pulling latest dev build of WPClothes2Order plugin";
echo "------------------------------------------------------------------------------------------------------------"
git clone https://github.com/$REPO_USER/$C20_PLUGIN.git wp-content/plugins/$C20_PLUGIN;
cd wp-content/plugins/$C20_PLUGIN;
git checkout dev;
cd ../../../;
# Add ray config
echo "------------------------------------------------------------------------------------------------------------"
echo "Adding ray config to app/ray.php";
echo "------------------------------------------------------------------------------------------------------------"
tee -a ./ray.php << END
<?php
// Save this in a file called "ray.php"
return [
/*
* The host used to communicate with the Ray app.
*/
'host' => 'host.docker.internal',
/*
* The port number used to communicate with the Ray app.
*/
'port' => 23517,
/*
* Absolute base path for your sites or projects in Homestead, Vagrant, Docker, or another remote development server.
*/
'remote_path' => null,
/*
* Absolute base path for your sites or projects on your local computer where your IDE or code editor is running on.
*/
'local_path' => null,
];
END
echo "------------------------------------------------------------------------------------------------------------"
echo "Environment ready.";