-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import argparse | ||
from miraheze.salt.utils import * | ||
|
||
def reset_wiki(wiki: str) -> None: | ||
# Step 1: Get the db cluster for the wiki | ||
|
||
try: | ||
wiki_cluster = get_db_cluster(wiki) | ||
except (KeyError, IndexError): | ||
print(f'Error: Unable to determine the db cluster for {wiki}') | ||
sys.exit(1) | ||
|
||
# Step 2: Execute deleteWiki.php | ||
execute_salt_command(salt_command=generate_salt_command('mwtask181', f'mwscript extensions/CreateWiki/deleteWiki.php loginwiki --deletewiki {wiki} --delete {os.getlogin()}')) | ||
|
||
# Step 3: Backup and drop database | ||
execute_salt_command(salt_command=generate_salt_command(wiki_cluster, f"sudo -i mysqldump {wiki} > {wiki}.sql'")) | ||
execute_salt_command(salt_command=generate_salt_command(wiki_cluster, f"sudo -i mysql -e 'DROP DATABASE {wiki}'")) | ||
|
||
|
||
def main() -> None: | ||
parser = argparse.ArgumentParser(description='Executes the commands needed to reset wikis') | ||
parser.add_argument('--wiki', required=True, help='Old wiki database name') | ||
|
||
args = parser.parse_args() | ||
reset_wiki(args.wiki) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |