diff --git a/daemon.py b/daemon.py index 5daa46f82..5aa9ae31c 100644 --- a/daemon.py +++ b/daemon.py @@ -40,6 +40,7 @@ from like import outboxLike from like import outboxUndoLike from blocking import outboxBlock from blocking import outboxUndoBlock +from config import setConfigParam import os import sys @@ -897,8 +898,12 @@ def runDaemon(clientToServer: bool,baseDir: str,domain: str, \ if cw: httpd.acceptedCaps.append('inbox:cw') - print('Creating shared inbox: inbox@'+domain) - createSharedInbox(baseDir,'inbox',domain,port,httpPrefix) + if not os.path.isdir(baseDir+'/accounts/inbox@'+domain): + print('Creating shared inbox: inbox@'+domain) + createSharedInbox(baseDir,'inbox',domain,port,httpPrefix) + print('See config.json for the password. You can remove the password from config.json after moving it elsewhere.') + adminPassword=createPassword(10) + setConfigParam(baseDir,'adminPassword',adminPassword) print('Creating inbox queue') httpd.thrInboxQueue= \ diff --git a/epicyon.py b/epicyon.py index ce2580cf7..b09015030 100644 --- a/epicyon.py +++ b/epicyon.py @@ -760,12 +760,12 @@ if args.skill: if federationList: print('Federating with: '+str(federationList)) -if not os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain): - print('Creating default admin account '+nickname+'@'+domain) - print('See config.json for the password. You can remove the password from config.json after moving it elsewhere.') - adminPassword=createPassword(10) - setConfigParam(baseDir,'adminPassword',adminPassword) - createPerson(baseDir,nickname,domain,port,httpPrefix,True,adminPassword) +#if not os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain): +# print('Creating default admin account '+nickname+'@'+domain) +# print('See config.json for the password. You can remove the password from config.json after moving it elsewhere.') +# adminPassword=createPassword(10) +# setConfigParam(baseDir,'adminPassword',adminPassword) +# createPerson(baseDir,nickname,domain,port,httpPrefix,True,adminPassword) if args.block: if not nickname: @@ -881,4 +881,4 @@ runDaemon(args.client,baseDir,domain,port,httpPrefix, \ args.noannounce,args.cw,ocapAlways, \ useTor,args.maxReplies, \ args.domainMaxPostsPerDay,args.accountMaxPostsPerDay, \ - args.allowDeletion,debug) + args.allowdeletion,debug) diff --git a/person.py b/person.py index bad32e3d7..af102b0ea 100644 --- a/person.py +++ b/person.py @@ -278,13 +278,29 @@ def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \ return privateKeyPem,publicKeyPem,newPerson,webfingerEndpoint +def noOfAccounts(baseDir: str) -> bool: + """Returns the number of accounts on the system + """ + accountCtr=0 + for subdir, dirs, files in os.walk(baseDir+'/accounts'): + for account in dirs: + if '@' in account: + if not account.startswith('inbox'): + accountCtr+=1 + return accountCtr + def createPerson(baseDir: str,nickname: str,domain: str,port: int, \ httpPrefix: str, saveToFile: bool,password=None) -> (str,str,{},{}): """Returns the private key, public key, actor and webfinger endpoint """ if not validNickname(nickname): return None,None,None,None - return createPersonBase(baseDir,nickname,domain,port,httpPrefix,saveToFile,password) + privateKeyPem,publicKeyPem,newPerson,webfingerEndpoint = \ + createPersonBase(baseDir,nickname,domain,port,httpPrefix,saveToFile,password) + if noOfAccounts(baseDir)==1: + print(nickname+' becomes the instance admin') + setRole(baseDir,nickname,domain,'instance','admin') + return privateKeyPem,publicKeyPem,newPerson,webfingerEndpoint def createSharedInbox(baseDir: str,nickname: str,domain: str,port: int, \ httpPrefix: str) -> (str,str,{},{}):