mirror of
https://github.com/vale981/dirkules
synced 2025-03-04 17:01:40 -05:00
prepared smb.conf generation
This commit is contained in:
parent
4d1a62597d
commit
e79b3e6dfb
4 changed files with 23 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue