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/
|
||||
test-ext/
|
||||
wp/
|
||||
*.sql
|
||||
|
30
main.py
30
main.py
@ -5,12 +5,6 @@ import unpacker
|
||||
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
|
||||
|
||||
function ai1wm_activate_plugins( $plugins ) {
|
||||
@ -31,39 +25,35 @@ def setup_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='AiO-Restore',
|
||||
description='Unpack and Restore All-in-One WP Migration Packages',
|
||||
epilog='aio_restore ',
|
||||
epilog='aio_restore [source] [target]',
|
||||
)
|
||||
parser.add_argument(
|
||||
'source',
|
||||
type=str,
|
||||
help='Source Path'
|
||||
help='Source Path as string'
|
||||
)
|
||||
parser.add_argument(
|
||||
'target',
|
||||
type=str,
|
||||
help='Target Path'
|
||||
help='Target Path as string'
|
||||
)
|
||||
parser.add_argument(
|
||||
'db_name',
|
||||
'--db_name',
|
||||
type=str,
|
||||
help='Database Name'
|
||||
help='Database Name as string'
|
||||
)
|
||||
parser.add_argument(
|
||||
'db_pass',
|
||||
'--db_pass',
|
||||
type=str,
|
||||
help='Database Password'
|
||||
help='Database Password as string'
|
||||
)
|
||||
parser.add_argument(
|
||||
name='site_url',
|
||||
name='-s',
|
||||
name='--site',
|
||||
'--site_url',
|
||||
type=str,
|
||||
help='Site URL, domain only'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-h',
|
||||
'--home',
|
||||
'home_url',
|
||||
'--home_url',
|
||||
type=str,
|
||||
help='Home URL, domain only'
|
||||
)
|
||||
@ -104,7 +94,7 @@ if __name__ == '__main__':
|
||||
if os.path.isfile(args.target):
|
||||
# check for database.sql and package.json
|
||||
# Setup Site files
|
||||
setup.WPSetup()
|
||||
setup.WPSetup(plugin_prefix)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
sys.exit(-1)
|
||||
|
39
setup.py
39
setup.py
@ -1,7 +1,13 @@
|
||||
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():
|
||||
"""Checks if WP-CLI is installed."""
|
||||
try:
|
||||
@ -11,22 +17,37 @@ class Setup():
|
||||
return False
|
||||
|
||||
def __download_core():
|
||||
print('')
|
||||
"""Download the core files, skip the content"""
|
||||
print('wp core download --force --skip-content --version=')
|
||||
|
||||
def __format_mysql():
|
||||
print('')
|
||||
def __format_mysql(self):
|
||||
"""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():
|
||||
print('')
|
||||
|
||||
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():
|
||||
print('')
|
||||
"""Import the database to the server after being processed for prefix"""
|
||||
print('wp db import database.sql')
|
||||
|
||||
def wp_setup(self):
|
||||
# Initial setup for restore
|
||||
"""Initial setup for restore, call functions in order of need"""
|
||||
self.__format_mysql()
|
||||
self.__move_folders()
|
||||
|
||||
@ -35,7 +56,9 @@ class Setup():
|
||||
|
||||
# File management
|
||||
self.__download_core(manual)
|
||||
self.__write_config() # TODO: Get data from input
|
||||
|
||||
# TODO: Get data from input
|
||||
self.__write_config()
|
||||
self.__import_mysql(manual)
|
||||
|
||||
return 'Completed'
|
Loading…
x
Reference in New Issue
Block a user