update db migration

This commit is contained in:
VirtuBox
2019-03-22 05:20:06 +01:00
parent fe3f9515cd
commit a1b2f2d2a6

120
install
View File

@@ -167,13 +167,11 @@ wo_sync_db()
### ###
# Switching from EE -> WO # Switching from EE -> WO
### ###
if [ -f /var/lib/ee/ee.db ]; then if [ ! -f /var/lib/wo/dbase.db ]; then
# Create the WordOps folder # Create the WordOps folder
mkdir -p /var/lib/wo mkdir -p /var/lib/wo
# Backup the nginx directory if [ -f /var/lib/ee/ee.db ]; then
tar -cvf - /etc/nginx /etc/ee /var/lib/ee | pigz -9 > /var/lib/wo/ee-backup.tgz
# Copy the EasyEngine database # Copy the EasyEngine database
cp /var/lib/ee/ee.db /var/lib/wo/dbase-ee.db cp /var/lib/ee/ee.db /var/lib/wo/dbase-ee.db
@@ -183,9 +181,10 @@ wo_sync_db()
### ###
# Clean WO installation # Clean WO installation
### ###
elif [ ! -d /var/lib/wo ]; then
# Create the directory holding the WordOps database cp /var/lib/ee/ee.db /var/lib/wo/dbase.db
mkdir -p /var/lib/wo rm -rf /var/lib/ee
else
# Create an empty database for WordOps # Create an empty database for WordOps
echo "CREATE TABLE sites ( echo "CREATE TABLE sites (
@@ -207,76 +206,71 @@ wo_sync_db()
php_version VARCHAR php_version VARCHAR
);" | sqlite3 /var/lib/wo/dbase.db );" | sqlite3 /var/lib/wo/dbase.db
if [ -f /var/lib/wo/dbase-ee.db ]; then
# Copy the main EasyEngine database over since we are migrating
cp /var/lib/wo/dbase-ee.db /var/lib/wo/dbase.db
fi
# Check site is enable/live or disable # Check site is enable/live or disable
cd /etc/nginx/sites-available || exit 1 AV_SITES="$(basename -a /etc/nginx/sites-available/* | grep -v default)"
for site in $(echo \* | grep -v default); for site in $AV_SITES;
do do
if [ -f "/etc/nginx/sites-enabled/$site" ]; then if [ -h "/etc/nginx/sites-enabled/$site" ]; then
wo_site_status='1' wo_site_status='1'
else else
wo_site_status='0' wo_site_status='0'
fi fi
# Acquire information about the current nginx configuration # Acquire information about the current nginx configuration
wo_site_current_type=$(head -n1 "/etc/nginx/sites-available/$site" | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5)
# Sniff out the vhost type and cache configuration wo_site_current_type=$(grep "common/" /etc/nginx/sites-available/$site | awk -F "/" '{print $2}')
if [ "$wo_site_current_type" = "HTML" ]; then
wo_site_current="html"
wo_site_current_cache="basic"
elif [ "$wo_site_current_type" = "PHP" ]; then
wo_site_current="php"
wo_site_current_cache="basic"
elif [ "$wo_site_current_type" = "MYSQL" ]; then
wo_site_current="mysql"
wo_site_current_cache="basic"
# Caching types on a single WordPress installation if [ "$(echo "$wo_site_current_type" | grep php)" ]; then
elif [ "$wo_site_current_type" = "WPSINGLE BASIC" ]; then if [ "$(echo "$wo_site_current_type" | grep php7)" ]; then
wo_site_current="wp" php_version="7.0"
wo_site_current_cache="basic" else
elif [ "$wo_site_current_type" = "WPSINGLE WP SUPER CACHE" ]; then php_version="5.6"
wo_site_current="wp"
wo_site_current_cache="wpsc"
elif [ "$wo_site_current_type" = "WPSINGLE FAST CGI" ] || [ "$wo_site_current_type" = "WPSINGLE FASTCGI" ]; then
wo_site_current="wp"
wo_site_current_cache="wpfc"
# Caching types on a single, subdirectory WordPress installation
elif [ "$wo_site_current_type" = "WPSUBDIR BASIC" ]; then
wo_site_current="wpsubdir"
wo_site_current_cache="basic"
elif [ "$wo_site_current_type" = "WPSUBDIR WP SUPER CACHE" ]; then
wo_site_current="wpsubdir"
wo_site_current_cache="wpsc"
elif [ "$wo_site_current_type" = "WPSUBDIR FAST CGI" ] || [ "$wo_site_current_type" = "WPSUBDIR FASTCGI" ]; then
wo_site_current="wpsubdir"
wo_site_current_cache="wpfc"
# Caching types on a single, subdomain WordPress installation
elif [ "$wo_site_current_type" = "WPSUBDOMAIN BASIC" ]; then
wo_site_current="wpsubdomain"
wo_site_current_cache="basic"
elif [ "$wo_site_current_type" = "WPSUBDOMAIN WP SUPER CACHE" ]; then
wo_site_current="wpsubdomain"
wo_site_current_cache="wpsc"
elif [ "$wo_site_current_type" = "WPSUBDOMAIN FAST CGI" ] || [ "$wo_site_current_type" = "WPSUBDOMAIN FASTCGI" ]; then
wo_site_current="wpsubdomain"
wo_site_current_cache="wpfc"
fi fi
else
php_version=""
fi
if [ "$(echo "$wo_site_current_type" | grep redis)" ]; then
wo_site_current_cache="wpredis"
elif [ -z "$(echo "$wo_site_current_type" | grep wpsc)" ]; then
wo_site_current_cache="wpsc"
elif [ -z "$(echo "$wo_site_current_type" | grep wpfc)" ]; then
wo_site_current_cache="wpfc"
else
wo_site_current_cache="basic"
fi
if [ "$(echo "$wo_site_current_type" | grep wp)" ]; then
if [ -z "$(echo "$wo_site_current_type" | grep wpsubdir)" ]; then
wo_site_current="wpsubdir"
elif [ -z "$(echo "$wo_site_current_type" | grep wpsudomain)" ]; then
wo_site_current="wpsubdomain"
else
wo_site_current="wp"
fi
else
if [ -z "$(echo "$wo_site_current_type" | grep location)" ]; then
wo_site_current="proxy"
elif [ -z "$(echo "$wo_site_current_type" | grep php)" ]; then
wo_site_current="html"
else
if [ -f /var/www/${site}/ee-config.php ] || [ -f /var/www/${site}/wo-config.php ]; then
wo_site_current="mysql"
else
wo_site_current="php"
fi
fi
fi
done
wo_webroot="/var/www/$site" wo_webroot="/var/www/$site"
# Import the configuration into the WordOps SQLite database # Import the configuration into the WordOps SQLite database
echo "INSERT INTO sites (sitename, site_type, cache_type, site_path, is_enabled, is_ssl, storage_fs, storage_db) echo "INSERT INTO sites (sitename, site_type, cache_type, site_path, is_enabled, is_ssl, storage_fs, storage_db)
VALUES (\"$site\", \"$wo_site_current\", \"$wo_site_current_cache\", \"$wo_webroot\", \"$wo_site_status\", 0, 'ext4', 'mysql');" | sqlite3 /var/lib/wo/dbase.db VALUES (\"$site\", \"$wo_site_current\", \"$wo_site_current_cache\", \"$wo_webroot\", \"$wo_site_status\", 0, 'ext4', 'mysql');" | sqlite3 /var/lib/wo/dbase.db
done
else
wo_php_version="7.2" wo_php_version="7.2"
wo_lib_echo "Updating WordOps Database" wo_lib_echo "Updating WordOps Database"
echo "ALTER TABLE sites ADD COLUMN db_name varchar;" | sqlite3 /var/lib/wo/dbase.db echo "ALTER TABLE sites ADD COLUMN db_name varchar;" | sqlite3 /var/lib/wo/dbase.db
@@ -288,9 +282,9 @@ wo_sync_db()
fi fi
echo "UPDATE sites SET php_version = REPLACE(php_version, '5.6', '7.2');" | sqlite3 /var/lib/wo/dbase.db # echo "UPDATE sites SET php_version = REPLACE(php_version, '5.6', '7.2');" | sqlite3 /var/lib/wo/dbase.db
echo "UPDATE sites SET php_version = REPLACE(php_version, '7.0', '7.3');" | sqlite3 /var/lib/wo/dbase.db # echo "UPDATE sites SET php_version = REPLACE(php_version, '7.0', '7.3');" | sqlite3 /var/lib/wo/dbase.db
fi
} }
# Once again, set the proper ACL on the WordOps configuration directory # Once again, set the proper ACL on the WordOps configuration directory