forked from penguintutor/pixel-server
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreateadmin.py
More file actions
20 lines (18 loc) · 751 Bytes
/
createadmin.py
File metadata and controls
20 lines (18 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import sys
from pixelserver.serveruser import ServerUser
# Create admin user and password
# Run using:
# python3 createadmin.py <username> <password> >>users.cfg
## Warning!! without two >> then it may delete all existing users.
# Username should not already exist, otherwise will be ignored
# Uses minimal information - login to update afterwards
# Check command line arguments
if (len(sys.argv) < 2):
print ("Insufficient arguments\npython3 createadmin.py <username> <password> >> users.cfg\n")
sys.exit()
# check for colon in username
if (':' in sys.argv[1]):
print ("Colon not allowed in username")
sys.exit()
# Create user entry
print ("{}:{}:Admin user:admin::\n".format(sys.argv[1], ServerUser.hash_password(sys.argv[2])))