This commit is contained in:
Ray Elliott 2020-06-12 23:41:13 +01:00
parent 4f19a98a3b
commit 20559e5395
7 changed files with 154 additions and 24 deletions

View File

@ -1,4 +1,9 @@
#!/bin/sh
export local_url=''
export remote_url=''
export local_ssh=''
export remote_ssh=''
export username=''
export webuser=''

20
run.sh
View File

@ -1,20 +0,0 @@
#!/bin/sh
. ./config-urls
if [ "$1" = 'local' ] ; then
(
echo "export local_url=\"$local_ur\""; \
echo "export remote_url=\"$remote_url\""; \
cat config "$2" \
) | ssh root@"$local_url" -T /bin/sh
elif [ "$1" = 'remote' ] ; then
(
echo "export local_url=\"$remote_url\""; \
echo "export remote_url=\"$local_url\""; \
cat config "$2" \
) | ssh root@"$remote_url" -T /bin/sh
else
echo "error: must specify local or remote"
fi

View File

@ -1,5 +1,22 @@
#!/bin/sh
. ./config
if [ "$1" = 'local' ] ; then
src_url="$local_url";
dest_url="$remote_url";
src_ssh="$local_ssh"
elif [ "$1" = 'remote' ] ; then
src_url="$remote_url";
dest_url="$local_url";
src_ssh="$remote_ssh"
else
echo "error: must specify local or remote"
exit 5
fi
ssh -T $src_ssh << EOSSH
apt upgrade -y || exit 10
apt install -y tmux ufw curl || exit 15
@ -11,3 +28,4 @@ systemctl restart sshd
ufw allow ssh || exit 20
yes | ufw enable
EOSSH

View File

@ -1,5 +1,22 @@
#!/bin/sh
. ./config
if [ "$1" = 'local' ] ; then
src_url="$local_url";
dest_url="$remote_url";
src_ssh="$local_ssh"
elif [ "$1" = 'remote' ] ; then
src_url="$remote_url";
dest_url="$local_url";
src_ssh="$remote_ssh"
else
echo "error: must specify local or remote"
exit 5
fi
ssh -T $src_ssh << EOSSH
success="0"
if [ -n "$apache2_version" ] ; then
@ -21,7 +38,7 @@ elif [ -n "$lightspeed_version" ] ; then
wget --no-check-certificate https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh && bash ols1clk.sh \
--adminpassword "$ls_webadmin_pass" \
--lsphp "$ls_lsphp_version" \
--wordpressplus "$local_url" \
--wordpressplus "$src_url" \
--wordpresspath "$wp_path" \
--dbrootpassword "$db_root_pass" \
--dbpassword "$wp_db_pass" \
@ -46,3 +63,4 @@ if [ "$success" -eq 1 ] ; then
&& ufw allow https
fi
EOSSH

View File

@ -1 +1,75 @@
#!/bin/sh
. ./config
if [ "$1" = 'local' ] ; then
src_url="$local_url";
dest_url="$remote_url";
src_ssh="$local_ssh"
dest_ssh="$remote_ssh"
elif [ "$1" = 'remote' ] ; then
src_url="$remote_url";
dest_url="$local_url";
src_ssh="$remote_ssh"
dest_ssh="$local_ssh"
else
echo "error: must specify local or remote"
exit 5
fi
db_file="$wp_path/data.sql"
tar_file="/tmp/wordpress.tar.gz"
############## source
ssh -T $src_ssh << EOSSH
wp db export \
--path="$wp_path" \
--dbuser="$wp_db_user" \
--dbpass="$wp_db_pass" \
--add-drop-table \
--allow-root \
"$db_file"
tar czf "$tar_file" "$wp_path"
EOSSH
scp "$src_ssh:$tar_file" "$tar_file"
ssh -T $src_ssh << EOSSH
rm "$db_file"
rm "$tar_file"
EOSSH
############## destination
scp "$tar_file" "$dest_ssh:$tar_file"
ssh -T $dest_ssh << EOSSH
rm -Rf "$wp_path"
cd /
tar xzf "$tar_file"
wp db import \
--path="$wp_path" \
--dbuser="$wp_db_user" \
--dbpass="$wp_db_pass" \
--allow-root \
"$db_file"
rm "$db_file"
rm "$tar_file"
wp search-replace \
--path="$wp_path" \
--allow-root \
--skip-columns=guid \
"$src_url" \
"$dest_url"
wp option update home \
--path="$wp_path" \
--allow-root
wp option update home \
--path="$wp_path" \
--allow-root
EOSSH
mv "$tar_file" ./wordpress-"$(date +%s)".tar.gz

View File

@ -1,3 +1,23 @@
#!/bin/sh
. ./config-urls
(
echo "export local_url=\"$local_ur\""; \
echo "export remote_url=\"$remote_url\""; \
cat config "$2" \
) | ssh root@"$local_url" -T /bin/sh
(
echo "export local_url=\"$remote_url\""; \
echo "export remote_url=\"$local_url\""; \
cat config "$2" \
) | ssh root@"$remote_url" -T /bin/sh
db_file="$wp_path/data.sql"
wp db export --dbuser=wordpress --dbpass=$wp_db_pass --add-drop-table --alow-root "$db_file"
tar czf /tmp/wordpress.tar.gz "$wp_path"
# scp
rm "$db_file"
rm /tmp/wordpress.tar.gz

View File

@ -1,5 +1,22 @@
#!/bin/sh
. ./config
if [ "$1" = 'local' ] ; then
src_url="$local_url";
dest_url="$remote_url";
src_ssh="$local_ssh"
elif [ "$1" = 'remote' ] ; then
src_url="$remote_url";
dest_url="$local_url";
src_ssh="$remote_ssh"
else
echo "error: must specify local or remote"
exit 5
fi
ssh -T $src_ssh << EOSSH
if [ -n "$php_version" ] ; then
echo "TODO - install specific PHP version"
exit 1
@ -26,9 +43,6 @@ else
echo "TODO - install WordPress"
fi
# check if wordpress already installed in $wp_path
# if not then install
if [ -n "$wp_themes" ] ; then
printf "\nInstalling themes ..."
option='--activate'
@ -71,3 +85,4 @@ if [ -n "$litespeed_version" ] ; then
fi
chown -R "$ownergroup" "$wp_path"
EOSSH