Skip to content

Commit

Permalink
Create fix_container_permissions.py
Browse files Browse the repository at this point in the history
  • Loading branch information
RhinosF1 authored Jan 19, 2024
1 parent 11db539 commit 21f694c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions miraheze/swift/fix_container_permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os
import re
import subprocess
import sys

if len(sys.argv) != 2:
print("Please use in form of 'python fix_containers.py foowiki'")
sys.exit(1)

wiki = sys.argv[1]

out = subprocess.run(['sudo', '-u', 'www-data', 'php', '/srv/mediawiki/1.40/maintenance/run.php', '/srv/mediawiki/1.40/extensions/CreateWiki/maintenance/setContainersAccess.php', '--wiki', wiki], capture_output=True, text=True)

matches = re.findall(r"Making sure 'mwstore:\/\/miraheze-swift\/([^']+)' [^\n]+\.failed\.", out.stdout)
for match in matches:
os.system(f"swift post --read-acl 'mw:media' --write-acl 'mw:media' miraheze-{wiki}-{match}")

os.system(f"sudo -u www-data php /srv/mediawiki/1.40/maintenance/run.php /srv/mediawiki/1.40/extensions/CreateWiki/maintenance/setContainersAccess.php --wiki {wiki}")

0 comments on commit 21f694c

Please sign in to comment.