Added Bulk Token Updater
This commit is contained in:
parent
cb6e5265a5
commit
7b266d6dbf
22
bulk-update-github-auth-token.py
Normal file
22
bulk-update-github-auth-token.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
import glob
|
||||
from pathlib import Path
|
||||
|
||||
BASEPATH = "/var/lib/gitea/gitea-repositories/"
|
||||
SEARCH_PATH = "*/*/config"
|
||||
SEARCH_TOKEN = "OLD_GITHUB_AUTH_TOKEN"
|
||||
REPLACE_TOKEN = "NEW_GITHUB_AUTH_TOKEN"
|
||||
|
||||
for path in glob.glob("{0}{1}".format(BASEPATH,SEARCH_PATH), recursive=True):
|
||||
LOG_HEAD = path.replace(BASEPATH,"")
|
||||
print("Updating : {0}".format(LOG_HEAD.replace(".git/config","")))
|
||||
|
||||
with open(path, 'r') as file :
|
||||
filedata = file.read()
|
||||
|
||||
filedata = filedata.replace("{0}@".format(SEARCH_TOKEN),"{0}@".format(REPLACE_TOKEN))
|
||||
|
||||
with open(path, 'w') as file:
|
||||
file.write(filedata)
|
||||
|
||||
print(" ")
|
Reference in a new issue