mirror of
https://github.com/jackeilles/xygt.git
synced 2024-11-25 00:02:39 +01:00
add wipe script
This commit is contained in:
parent
c39495149f
commit
4aaf68c1be
1 changed files with 40 additions and 0 deletions
40
wipe.py
Executable file
40
wipe.py
Executable file
|
@ -0,0 +1,40 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""
|
||||||
|
This is to only be used in the event of catastrophic failure where everything is basically fucked.
|
||||||
|
This wipes all files and DB entries for Files, URL's and users.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
from pymongo import MongoClient
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
# MongoDB init stuff
|
||||||
|
client = MongoClient("mongodb://localhost:27017/")
|
||||||
|
db = client["xygt"]
|
||||||
|
files = db["file"]
|
||||||
|
url = db["url"]
|
||||||
|
users = db["users"]
|
||||||
|
fileDir = "./data"
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# Start
|
||||||
|
conf1 = input("This will irrevocably remove ALL DATA from xygt.cc, are you sure you'd like to proceed. (Type this w.o quotes 'Yes I would like to proceed')")
|
||||||
|
if conf1 == "Yes I would like to proceed":
|
||||||
|
conf2 = input("Are you definitely sure? (y/n)").lower()
|
||||||
|
if conf2 == "y":
|
||||||
|
print("WIPING ALL DATA.\n\n")
|
||||||
|
print("Clearing files db")
|
||||||
|
Config.files.delete_many({})
|
||||||
|
print("Clearing url db")
|
||||||
|
Config.url.delete_many({})
|
||||||
|
print("Clearing user db")
|
||||||
|
Config.url.delete_many({})
|
||||||
|
print("Deleting local files")
|
||||||
|
os.remove(f"{Config.fileDir}/*")
|
||||||
|
print("Done. xygt.cc is ready to start clean.")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
# UNCOMMENT TO RUN!!!
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in a new issue