mirror of https://gitlab.com/bashrc2/epicyon
First account gets admin status
parent
cd7ded743f
commit
5f58b0f02e
|
@ -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= \
|
||||
|
|
14
epicyon.py
14
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)
|
||||
|
|
18
person.py
18
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,{},{}):
|
||||
|
|
Loading…
Reference in New Issue