automatic participantdir creation due to .gitignore ignoring them by default, to facilitate upgrades

This commit is contained in:
root 2025-02-15 22:51:11 +01:00
parent 651beb1666
commit 5928fd34ad
2 changed files with 19 additions and 1 deletions

View file

@ -9,7 +9,7 @@ import urllib
def main():
os.system('clear')
#os.system('clear')
proxies = {
'http': 'socks5h://127.0.0.1:9050',
'https': 'socks5h://127.0.0.1:9050'
@ -17,6 +17,24 @@ def main():
rootpath='/srv/darknet-lantern/'
urlpath=pwd.getpwuid(os.getuid()).pw_dir+"/.darknet_participant_url"
participantsdir=rootpath+'www/participants/'
officialparticipants=rootpath+'www/.official_participants'
# check if /srv/darknet-lantern/www/participants directory exists,
if not os.path.isdir(participantsdir):
print("participants directory doesnt exist, creating it")
os.makedirs(participantsdir)
# iterate over /srv/darknet-lantern/www/.official_participants, list each line
with open(officialparticipants, 'r') as file:
# for each line (which is a participant):
for line in file:
participantdir=participantsdir+line.strip()
# check if the directory exists
if not os.path.isdir(participantdir):
#if not, create it
print("Official participan ",line.strip() , "'s directory doesnt exist, creating it")
os.makedirs(participantdir)
print_colors("""