prepared smb.conf generation

This commit is contained in:
Daniel 2019-10-11 20:19:55 +02:00
parent 4d1a62597d
commit e79b3e6dfb
4 changed files with 23 additions and 3 deletions

View file

@ -9,7 +9,7 @@ app.config.from_object(config)
db = SQLAlchemy(app)
csrf = CSRFProtect()
csrf.init_app(app)
app_version = app.config["VERSION"]
app_version = app.config["version"]
import dirkules.models
import dirkules.samba.models

View file

@ -5,7 +5,7 @@ from logging.config import dictConfig
from apscheduler.jobstores.base import ConflictingIdError
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
VERSION = "1.0"
version = "1.0.1"
baseDir = os.path.abspath(os.path.dirname(__file__))
staticDir = os.path.join(baseDir, 'static')

View file

@ -1,3 +1,5 @@
from dirkules.config import staticDir, version
from dirkules import db
from dirkules.samba.models import SambaGlobal
@ -10,3 +12,21 @@ def set_samba_global(workgroup, name):
db.session.add(workgroup)
db.session.add(name)
db.session.commit()
def generate_smb():
if SambaGlobal.query.first() is None:
workgroup = 'WORKGROUP'
server_string = '%h dirkules'
else:
workgroup = SambaGlobal.query.get(1)
server_string = SambaGlobal.query.get(2)
f = open("smb.conf.txt", "w")
samba_global = open(staticDir + "/conf/samba_global.conf", "r")
f.write("# This file was generated by dirkules v{}".format(version))
f.write()
f.write("# Global Config")
f.write("server string = {}".format(server_string))
f.write("workgroup = {}".format(workgroup))
f.write(samba_global.read())
f.close()

View file

@ -20,7 +20,7 @@ def config():
if request.method == 'POST' and form.validate():
set_samba_global(form.workgroup.data, form.server_string.data)
return redirect(url_for('.index'))
file = open(staticDir + "/conf/samba_global.conf")
file = open(staticDir + "/conf/samba_global.conf", "r")
conf = list()
while True:
line = file.readline()