mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
fixed bug where tables/default settings were firing each restart
This commit is contained in:
parent
c896a12b17
commit
2eeee9d6c4
@ -43,6 +43,7 @@ class Users(BaseModel):
|
|||||||
class Meta:
|
class Meta:
|
||||||
table_name = "users"
|
table_name = "users"
|
||||||
|
|
||||||
|
|
||||||
class Audit_Log(BaseModel):
|
class Audit_Log(BaseModel):
|
||||||
audit_id = AutoField()
|
audit_id = AutoField()
|
||||||
created = DateTimeField(default=datetime.datetime.now)
|
created = DateTimeField(default=datetime.datetime.now)
|
||||||
@ -53,7 +54,6 @@ class Audit_Log(BaseModel):
|
|||||||
log_msg = TextField(default='')
|
log_msg = TextField(default='')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Host_Stats(BaseModel):
|
class Host_Stats(BaseModel):
|
||||||
time = DateTimeField(default=datetime.datetime.now)
|
time = DateTimeField(default=datetime.datetime.now)
|
||||||
boot_time = CharField(default="")
|
boot_time = CharField(default="")
|
||||||
@ -167,7 +167,8 @@ class db_builder:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_settings():
|
def default_settings():
|
||||||
|
logger.info("Fresh Install Detected - Creating Default Settings")
|
||||||
|
console.info("Fresh Install Detected - Creating Default Settings")
|
||||||
default_data = helper.find_default_password()
|
default_data = helper.find_default_password()
|
||||||
|
|
||||||
username = default_data.get("username", 'admin')
|
username = default_data.get("username", 'admin')
|
||||||
@ -185,9 +186,12 @@ class db_builder:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_fresh_install():
|
def is_fresh_install():
|
||||||
if helper.check_file_exists(helper.db_path):
|
try:
|
||||||
|
user = Users.get_by_id(1)
|
||||||
return False
|
return False
|
||||||
|
except:
|
||||||
return True
|
return True
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class db_shortcuts:
|
class db_shortcuts:
|
||||||
|
4
main.py
4
main.py
@ -82,7 +82,9 @@ if __name__ == '__main__':
|
|||||||
helper.create_session_file(ignore=args.ignore)
|
helper.create_session_file(ignore=args.ignore)
|
||||||
|
|
||||||
# do our installer stuff
|
# do our installer stuff
|
||||||
if not installer.is_fresh_install():
|
fresh_install = installer.is_fresh_install()
|
||||||
|
|
||||||
|
if fresh_install:
|
||||||
installer.create_tables()
|
installer.create_tables()
|
||||||
installer.default_settings()
|
installer.default_settings()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user