added basic file output to write finished configs back to the system

This commit is contained in:
spinach 2025-02-24 03:26:27 -05:00
parent 96c0b81e64
commit 9181f71a96
2 changed files with 30 additions and 37 deletions

View File

@ -1,37 +1,6 @@
## Global Settings
DB_HOST="mariadb"
DB_ROOT_PASS=""
TIME_ZONE="America/New_York"
## Mariadb Settings
MYSQL_ROOT_PASSWORD="$DB_ROOT_PASS"
MYSQL_LOG_CONSOLE="true"
MARIADB_AUTO_UPGRADE=1
## Gitea Settings
GITEA__database__DB_TYPE="mysql"
GITEA__database__HOST="$DB_HOST"
GITEA__database__HOST="mariadb"
GITEA__database__NAME="gitea"
GITEA__database__USER="gitea"
GITEA__database__PASSWD=""
## Seafile Settings
# COMPOSE_FILE='seafile-server.yml,caddy.yml,seadoc.yml'
# COMPOSE_PATH_SEPARATOR=','
SEAFILE_VOLUME=volume/seafile/data
SEAFILE_CADDY_VOLUME=volume/caddy/data
SEAFILE_MYSQL_DB_HOST="$DB_HOST"
SEAFILE_MYSQL_DB_USER="seafile"
SEAFILE_MYSQL_DB_PASSWORD=""
SEAFILE_JWT_PRIVATE_KEY=""
SEAFILE_SERVER_HOSTNAME="seafile.keegandeppe.com"
SEAFILE_SERVER_PROTOCOL="https"
INIT_SEAFILE_ADMIN_EMAIL="19keegandeppe@gmail.com"
INIT_SEAFILE_ADMIN_PASSWORD=""
ENABLE_SEADOC=false

34
init.py
View File

@ -80,7 +80,7 @@ def parse_env(service):
:service: is a string of the service name to parse, must match folder name
"""
print(f"setting up {service}...")
print(f"\nsetting up {service}...")
f = open(f"{service}/env")
c = dict()
@ -105,20 +105,44 @@ def parse_env(service):
def gen_env(kv):
"""
gen_env takes in a dictionary and writes out each pair into an env file
gen_env takes in a dictionary and returns the formatted env file
:kv: is a dictionary of strings
"""
env = ""
for key, value in kv.items():
print(f"{key}=\"{value}\"")
env += f"{key}=\"{value}\"\n"
return env
def mariadb_init():
if os.path.isfile("mariadb/.env"):
print("mariadb/.env already exists... skipping")
return
c = parse_env("mariadb")
password = c["MYSQL_ROOT_PASSWORD"]
sql_init(password)
gen_env(c)
def gitea_init():
if os.path.isfile("gitea/.env"):
print("gitea/.env already exists... skipping")
return
c = parse_env("gitea")
username = c["GITEA__database__USER"]
password = c["GITEA__database__PASSWD"]
db = c["GITEA__database__NAME"]
sql_add_user(username, password, db)
env = gen_env(c)
f = open("gitea/.env", 'w')
f.write(env)
f.close()
def seafile_init():
c = parse_env("seafile")
username = c["SEAFILE_MYSQL_DB_USER"]
@ -129,5 +153,5 @@ def seafile_init():
# seafile_init()
mariadb_init()
# def get_env():
# print(os.environ['PWD'])
gitea_init()
seafile_init()