-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished Docker files. Commands will be added to README.md/Documentat…
…ion later.
- Loading branch information
Showing
3 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: '3' | ||
services: | ||
sb-ui: | ||
image: "nthiterationlab/streamingbandit-ui:latest" | ||
ports: | ||
- "80:80" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
from pymongo import MongoClient | ||
from bcrypt import hashpw, checkpw, gensalt | ||
import yaml | ||
import os | ||
import argparse | ||
|
||
def insert_admin(): | ||
dirs = os.listdir() | ||
if 'app' in dirs: | ||
f = open("app/config.cfg", 'r') | ||
else: | ||
f = open("./config.cfg", 'r') | ||
settings = yaml.load(f) | ||
mongo_client = MongoClient(settings['mongo_ip'], settings['mongo_port']) | ||
mongo_db = mongo_client['userinfo'] | ||
userinfo = mongo_db['userinfo'] | ||
f.close() | ||
|
||
parser = argparse.ArgumentParser(description = "Add admin user to MongoDB") | ||
parser.add_argument('-p', '--password', type = str, help = "Admin password", required = True) | ||
|
||
if userinfo.find({'username':'admin'}).count() > 0: | ||
print("Admin already exists") | ||
else: | ||
args = parser.parse_args() | ||
password = args.password | ||
hashed = hashpw(password.encode('utf-8'), gensalt()) | ||
userinfo.insert_one({"username":"admin","password":hashed,"user_id":0}) | ||
print("Successfully added an admin user with password {}!".format(password)) | ||
|
||
if __name__ == "__main__": | ||
insert_admin() |