changes to get everything setup
This commit is contained in:
parent
d88171d89e
commit
960a1d1027
1
.gitignore
vendored
1
.gitignore
vendored
@ -162,3 +162,4 @@ cython_debug/
|
|||||||
#reference/
|
#reference/
|
||||||
test-ext/
|
test-ext/
|
||||||
wp/
|
wp/
|
||||||
|
*.sql
|
||||||
|
30
main.py
30
main.py
@ -5,12 +5,6 @@ import unpacker
|
|||||||
import setup
|
import setup
|
||||||
|
|
||||||
'''
|
'''
|
||||||
obtain new info for sites database
|
|
||||||
install core files
|
|
||||||
move wp-content to correct place
|
|
||||||
import db to website
|
|
||||||
check for any issues
|
|
||||||
|
|
||||||
package.json
|
package.json
|
||||||
|
|
||||||
function ai1wm_activate_plugins( $plugins ) {
|
function ai1wm_activate_plugins( $plugins ) {
|
||||||
@ -31,39 +25,35 @@ def setup_args():
|
|||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog='AiO-Restore',
|
prog='AiO-Restore',
|
||||||
description='Unpack and Restore All-in-One WP Migration Packages',
|
description='Unpack and Restore All-in-One WP Migration Packages',
|
||||||
epilog='aio_restore ',
|
epilog='aio_restore [source] [target]',
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'source',
|
'source',
|
||||||
type=str,
|
type=str,
|
||||||
help='Source Path'
|
help='Source Path as string'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'target',
|
'target',
|
||||||
type=str,
|
type=str,
|
||||||
help='Target Path'
|
help='Target Path as string'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'db_name',
|
'--db_name',
|
||||||
type=str,
|
type=str,
|
||||||
help='Database Name'
|
help='Database Name as string'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'db_pass',
|
'--db_pass',
|
||||||
type=str,
|
type=str,
|
||||||
help='Database Password'
|
help='Database Password as string'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
name='site_url',
|
'--site_url',
|
||||||
name='-s',
|
|
||||||
name='--site',
|
|
||||||
type=str,
|
type=str,
|
||||||
help='Site URL, domain only'
|
help='Site URL, domain only'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-h',
|
'--home_url',
|
||||||
'--home',
|
|
||||||
'home_url',
|
|
||||||
type=str,
|
type=str,
|
||||||
help='Home URL, domain only'
|
help='Home URL, domain only'
|
||||||
)
|
)
|
||||||
@ -104,7 +94,7 @@ if __name__ == '__main__':
|
|||||||
if os.path.isfile(args.target):
|
if os.path.isfile(args.target):
|
||||||
# check for database.sql and package.json
|
# check for database.sql and package.json
|
||||||
# Setup Site files
|
# Setup Site files
|
||||||
setup.WPSetup()
|
setup.WPSetup(plugin_prefix)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
39
setup.py
39
setup.py
@ -1,7 +1,13 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
class Setup():
|
class Setup:
|
||||||
|
|
||||||
|
def __init__(self, plugin_prefix):
|
||||||
|
self.plugin_prefix = plugin_prefix
|
||||||
|
# TODO: pass full path or target extraction folder path
|
||||||
|
self.sql_file = 'database.sql'
|
||||||
|
|
||||||
def __check_wp_cli():
|
def __check_wp_cli():
|
||||||
"""Checks if WP-CLI is installed."""
|
"""Checks if WP-CLI is installed."""
|
||||||
try:
|
try:
|
||||||
@ -11,22 +17,37 @@ class Setup():
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def __download_core():
|
def __download_core():
|
||||||
print('')
|
"""Download the core files, skip the content"""
|
||||||
|
print('wp core download --force --skip-content --version=')
|
||||||
|
|
||||||
def __format_mysql():
|
def __format_mysql(self):
|
||||||
print('')
|
"""Replace the prefix changes in the database"""
|
||||||
|
with open(self.sql_file, 'r') as file:
|
||||||
|
content = file.read()
|
||||||
|
|
||||||
|
# Perform the replacement
|
||||||
|
modified_content = content.replace(self.plugin_prefix, "wp_")
|
||||||
|
|
||||||
|
# Write the modified content back to the file
|
||||||
|
with open(self.sql_file, 'w') as file:
|
||||||
|
file.write(modified_content)
|
||||||
|
|
||||||
def __move_folders():
|
def __move_folders():
|
||||||
print('')
|
print('')
|
||||||
|
|
||||||
def __write_config():
|
def __write_config():
|
||||||
print('')
|
"""Write a new wp-config.php file based on package.json"""
|
||||||
|
# TODO: Test for wp-config.php
|
||||||
|
# TODO: Shuffle salts
|
||||||
|
print('wp config shuffle-salts')
|
||||||
|
# TODO: Setup database information
|
||||||
|
|
||||||
def __import_mysql():
|
def __import_mysql():
|
||||||
print('')
|
"""Import the database to the server after being processed for prefix"""
|
||||||
|
print('wp db import database.sql')
|
||||||
|
|
||||||
def wp_setup(self):
|
def wp_setup(self):
|
||||||
# Initial setup for restore
|
"""Initial setup for restore, call functions in order of need"""
|
||||||
self.__format_mysql()
|
self.__format_mysql()
|
||||||
self.__move_folders()
|
self.__move_folders()
|
||||||
|
|
||||||
@ -35,7 +56,9 @@ class Setup():
|
|||||||
|
|
||||||
# File management
|
# File management
|
||||||
self.__download_core(manual)
|
self.__download_core(manual)
|
||||||
self.__write_config() # TODO: Get data from input
|
|
||||||
|
# TODO: Get data from input
|
||||||
|
self.__write_config()
|
||||||
self.__import_mysql(manual)
|
self.__import_mysql(manual)
|
||||||
|
|
||||||
return 'Completed'
|
return 'Completed'
|
Loading…
x
Reference in New Issue
Block a user