-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmigrate.sh
More file actions
35 lines (29 loc) · 849 Bytes
/
Copy pathmigrate.sh
File metadata and controls
35 lines (29 loc) · 849 Bytes
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
#!/bin/bash
# check if wp-cli is installed
# if not, download it
if [ -z "$(command -v wp)" ]; then
wget -O wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp
WPCLI="./wp"
else
WPCLI="wp"
fi
# check if wp is-installed
WP_CHECK=$($WPCLI core is-installed)
if [ -z "$WP_CHECK" ]; then
SITE_URL=$($WPCLI option get siteurl)
SITE_DOMAIN=$($WPCLI option get siteurl | awk -F "//" '{print $2}')
# replace site url with https
$WPCLI search-replace \
"$SITE_URL" \
"https://$SITE_DOMAIN" \
--skip-columns=guid --skip-tables=wp_users
# replace encoded site url with https
$WPCLI search-replace \
"http:\/\/$SITE_DOMAIN" \
"https:\/\/$SITE_DOMAIN" \
--skip-columns=guid --skip-tables=wp_users
else
echo "no wordpress instance found"
exit 1
fi