start/stop domain + local domain directories creations
This commit is contained in:
parent
563518fe0c
commit
de5c93c668
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# Version: 1.9.2
|
# Version: 1.9.4
|
||||||
# Updated: 2023-09-23 1695486804
|
# Updated: 2023-09-25 1695630197
|
||||||
# Tyto - Littérateur
|
# Tyto - Littérateur
|
||||||
|
|
||||||
# Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
|
# Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -94,6 +94,8 @@ def start_process():
|
||||||
"check" : check.manage,
|
"check" : check.manage,
|
||||||
"new" : new.manage,
|
"new" : new.manage,
|
||||||
"set" : userset.manage,
|
"set" : userset.manage,
|
||||||
|
"start" : userset.manage,
|
||||||
|
"stop" : userset.manage,
|
||||||
"show" : show.manage,
|
"show" : show.manage,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,15 @@ import sys
|
||||||
import domain, langs, debug
|
import domain, langs, debug
|
||||||
|
|
||||||
|
|
||||||
|
#===========================================#
|
||||||
|
# Manage argument from command line "check" #
|
||||||
|
# Domain must be valid to proceed #
|
||||||
|
# Create user work domain directories #
|
||||||
|
#-------------------------------------------#
|
||||||
def manage(action, target):
|
def manage(action, target):
|
||||||
# Load domain configuration, update if needed, check if valid
|
# Load domain configuration, update if needed, check if valid
|
||||||
if not domain.valid_conf():
|
if not domain.cf_valid():
|
||||||
debug.out(105, domain.conf_name, domain.dcf_uri, True, 1, True)
|
debug.out(105, domain.name, domain.cf_uri, True, 1, True)
|
||||||
|
|
||||||
langs.load_website_lang()
|
langs.load_website_lang()
|
||||||
print("check:", action, target)
|
print("check:", action, target)
|
||||||
|
|
|
@ -40,38 +40,37 @@ import debug, tyto, tools, forms, langs
|
||||||
# Exit if directory name is compatible with a domain name #
|
# Exit if directory name is compatible with a domain name #
|
||||||
#---------------------------------------------------------#
|
#---------------------------------------------------------#
|
||||||
def compatible_name():
|
def compatible_name():
|
||||||
if len(conf_name.rsplit(".")) <= 1:
|
if len(name.rsplit(".")) <= 1:
|
||||||
debug.out(3, "abc.tld", conf_name, True, 2, True)
|
debug.out(3, "abc.tld", name, True, 2, True)
|
||||||
|
|
||||||
|
|
||||||
#================================#
|
#================================#
|
||||||
# Load Domain Configuration file #
|
# Load Domain Configuration file #
|
||||||
# As needed, exit if not exists #
|
# As needed, exit if not exists #
|
||||||
#--------------------------------#
|
#--------------------------------#
|
||||||
def dcf_load():
|
def cf_load():
|
||||||
global dcf
|
global cf
|
||||||
|
|
||||||
dcf = False
|
cf_exists() or sys.exit(100)
|
||||||
if not dcf_exists():
|
|
||||||
debug.out(100, conf_name, dcf_uri, True, 1, True)
|
|
||||||
|
|
||||||
dcf = configparser.ConfigParser()
|
cf = False
|
||||||
dcf.read(dcf_uri)
|
cf = configparser.ConfigParser()
|
||||||
|
cf.read(cf_uri)
|
||||||
|
|
||||||
|
|
||||||
#=====================================#
|
#=====================================#
|
||||||
# Load User Domain Configuration file #
|
# Load User Domain Configuration file #
|
||||||
# As needed, exit if not exists #
|
# As needed, exit if not exists #
|
||||||
#-------------------------------------#
|
#-------------------------------------#
|
||||||
def ult_dcf_load():
|
def ult_cf_load():
|
||||||
global ult_dcf
|
global ult_cf
|
||||||
|
|
||||||
ult_dcf = False
|
ult_cf = False
|
||||||
if not os.path.exists(ult_dcf_uri):
|
if not os.path.exists(ult_cf_uri):
|
||||||
debug.out(100, conf_name, ult_dcf_uri, True, 1, True)
|
debug.out(100, name, ult_cf_uri, True, 1, True)
|
||||||
|
|
||||||
ult_dcf = configparser.ConfigParser()
|
ult_cf = configparser.ConfigParser()
|
||||||
ult_dcf.read(ult_dcf_uri)
|
ult_cf.read(ult_cf_uri)
|
||||||
|
|
||||||
|
|
||||||
#===================================#
|
#===================================#
|
||||||
|
@ -90,36 +89,36 @@ def ult_dlf_load():
|
||||||
# Show status message only once #
|
# Show status message only once #
|
||||||
# return True or False
|
# return True or False
|
||||||
#-------------------------------------------#
|
#-------------------------------------------#
|
||||||
def dcf_exists():
|
def cf_exists():
|
||||||
global shown_ok, shown_no
|
global shown_ok, shown_no
|
||||||
|
|
||||||
if os.path.exists(dcf_uri):
|
if os.path.exists(cf_uri):
|
||||||
try: shown_ok
|
try: shown_ok
|
||||||
except: debug.out(202, conf_name, dcf_uri, True, 0, False)
|
except: debug.out(202, name, cf_uri, False, 0, False)
|
||||||
shown_ok = True
|
shown_ok = True
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
try: shown_no
|
try: shown_no
|
||||||
except: debug.out(104, "False", dcf_uri, True, 1, False)
|
except: debug.out(104, "False", cf_uri, True, 1, False)
|
||||||
shown_no = True
|
shown_no = True
|
||||||
compatible_name()
|
compatible_name()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
#=========================================#
|
#=========================================#
|
||||||
# Guess and return wip_url from conf_name #
|
# Guess and return wip_url from name #
|
||||||
#-----------------------------------------#
|
#-----------------------------------------#
|
||||||
def create_wip_url():
|
def create_wip_url():
|
||||||
wip_url = "https://www-wip.%s/"
|
wip_url = "https://www-wip.%s/"
|
||||||
len_cn = conf_name.count(".")
|
len_cn = name.count(".")
|
||||||
|
|
||||||
# Domain name Format: a.b
|
# Domain name Format: a.b
|
||||||
if len_cn == 1:
|
if len_cn == 1:
|
||||||
return wip_url%conf_name
|
return wip_url%name
|
||||||
|
|
||||||
# Domain name format: (at least) a.b.c
|
# Domain name format: (at least) a.b.c
|
||||||
len_cn = len(conf_name.rsplit(".")[0]) + 1
|
len_cn = len(name.rsplit(".")[0]) + 1
|
||||||
tld = conf_name[len_cn:]
|
tld = name[len_cn:]
|
||||||
return wip_url%tld
|
return wip_url%tld
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,21 +129,21 @@ def create_wip_url():
|
||||||
# - default User domain configuration file #
|
# - default User domain configuration file #
|
||||||
# If not User domains list file, create it #
|
# If not User domains list file, create it #
|
||||||
#------------------------------------------#
|
#------------------------------------------#
|
||||||
def dcf_create():
|
def cf_create():
|
||||||
compatible_name()
|
compatible_name()
|
||||||
|
|
||||||
# This fonction is only called with "new domain" argument
|
# This fonction is only called with "new domain" argument
|
||||||
# If a conf already exists, show important RESET log
|
# If a conf already exists, show important RESET log
|
||||||
if dcf_exists():
|
if cf_exists():
|
||||||
debug.out(102, "!?", dcf_uri, True, 1, False)
|
debug.out(102, "!?", cf_uri, True, 1, False)
|
||||||
|
|
||||||
# Ask User to create new domain. Will exit if not ok.
|
# Ask User to create new domain. Will exit if not ok.
|
||||||
forms.ask_domain_shortname(conf_name)
|
forms.ask_domain_shortname(name)
|
||||||
|
|
||||||
# Create default files
|
# Create default files
|
||||||
tools.create_file(dcf_uri, tyto.ini_domain)
|
tools.create_file(cf_uri, tyto.ini_domain)
|
||||||
tools.create_dirs(ult_dir)
|
tools.create_dirs(ult_dir)
|
||||||
tools.create_file(ult_dcf_uri, tyto.ini_domain_user)
|
tools.create_file(ult_cf_uri, tyto.ini_domain_user)
|
||||||
|
|
||||||
# User Domains list file
|
# User Domains list file
|
||||||
if not os.path.exists(ult_dlf_uri):
|
if not os.path.exists(ult_dlf_uri):
|
||||||
|
@ -167,47 +166,49 @@ def dcf_create():
|
||||||
#===========================================#
|
#===========================================#
|
||||||
# Set or Update domain configuration values #
|
# Set or Update domain configuration values #
|
||||||
#-------------------------------------------#
|
#-------------------------------------------#
|
||||||
def dcf_update_values(srv):
|
def cf_update_values(srv):
|
||||||
# Prepare Domain Configuration File keys values
|
# Prepare Domain Configuration File keys values
|
||||||
#-----------------------------------------------
|
#-----------------------------------------------
|
||||||
dcf_load()
|
cf_load()
|
||||||
|
|
||||||
# Test server directory, and exit if not exists
|
# Test server directory, and exit if not exists
|
||||||
srv = srv or dcf.get("SERVER", "root") # Set from db if unknown
|
srv = srv or cf.get("SERVER", "root") # Set from db if unknown
|
||||||
|
|
||||||
# Test registred website lang
|
# Test registred website lang
|
||||||
# change to default lang sys, or "en" if no translation file
|
# change to default lang sys, or "en" if no translation file
|
||||||
# Load website lang file
|
# Load website lang file
|
||||||
langs.load_website_lang()
|
langs.load_website_lang()
|
||||||
|
cf.set("WEBSITE", "lang", langs.site_lang)
|
||||||
|
|
||||||
srv_dom = os.path.join(srv, conf_name + "/")
|
srv_dom = os.path.join(srv, name + "/")
|
||||||
srv_wip = os.path.join(srv_dom, "wip/")
|
srv_wip = os.path.join(srv_dom, "wip/")
|
||||||
srv_www = os.path.join(srv_dom, "www/")
|
srv_www = os.path.join(srv_dom, "www/")
|
||||||
|
|
||||||
# Set booleans if invalid values
|
# Set booleans if invalid values
|
||||||
try: dcf.getboolean("DOMAIN", "activated")
|
try: cf.getboolean("DOMAIN", "activated")
|
||||||
except: dcf.set("DOMAIN", "activated", "no")
|
except: cf.set("DOMAIN", "activated", "no")
|
||||||
try: dcf.getboolean("WEBSITE", "article_code")
|
try: cf.getboolean("WEBSITE", "article_code")
|
||||||
except: dcf.set("WEBSITE", "article_code", "yes")
|
except: cf.set("WEBSITE", "article_code", "yes")
|
||||||
try: dcf.getboolean("WEBSITE", "static")
|
try: cf.getboolean("WEBSITE", "static")
|
||||||
except: dcf.set("WEBSITE", "static", "no")
|
except: cf.set("WEBSITE", "static", "no")
|
||||||
try: dcf.getboolean("WEBSITE_MODULES", "sitemaps")
|
try: cf.getboolean("WEBSITE_MODULES", "sitemaps")
|
||||||
except: dcf.set("WEBSITE_MODULES", "sitemaps", "yes")
|
except: cf.set("WEBSITE_MODULES", "sitemaps", "yes")
|
||||||
|
|
||||||
# Set template filenames to default if none
|
# Set template filenames to default if none
|
||||||
favicon = dcf.get("TEMPLATE_FILENAMES", "favicon") or "favicon.png"
|
favicon = cf.get("TEMPLATE_FILENAMES", "favicon") or "favicon.png"
|
||||||
logo = dcf.get("TEMPLATE_FILENAMES", "logo") or "logo.png"
|
logo = cf.get("TEMPLATE_FILENAMES", "logo") or "logo.png"
|
||||||
styles = dcf.get("TEMPLATE_FILENAMES", "styles") or "styles.css"
|
styles = cf.get("TEMPLATE_FILENAMES", "styles") or "styles.css"
|
||||||
rss = dcf.get("TEMPLATE_FILENAMES", "rss") or "rss.xml"
|
rss = cf.get("TEMPLATE_FILENAMES", "rss") or "rss.xml"
|
||||||
stats = dcf.get("TEMPLATE_FILENAMES", "stats") or "stats.ini"
|
stats = cf.get("TEMPLATE_FILENAMES", "stats") or "stats.ini"
|
||||||
|
|
||||||
dcf.get("WEBSITE", "www_url") or \
|
# https URLs (www + wip)
|
||||||
dcf.set("WEBSITE", "www_url", "https://%s/"%conf_name)
|
cf.get("WEBSITE", "www_url") or \
|
||||||
dcf.get("WEBSITE", "wip_url") or \
|
cf.set("WEBSITE", "www_url", "https://%s/"%name)
|
||||||
dcf.set("WEBSITE", "wip_url", create_wip_url())
|
cf.get("WEBSITE", "wip_url") or \
|
||||||
|
cf.set("WEBSITE", "wip_url", create_wip_url())
|
||||||
|
|
||||||
usr_mods = os.path.join(dcf_dir + "modules/")
|
usr_mods = os.path.join(cf_dir, "modules/")
|
||||||
usr_tpl = os.path.join(dcf_dir, "template/")
|
usr_tpl = os.path.join(cf_dir, "template/")
|
||||||
usr_favicon = os.path.join(usr_tpl, favicon)
|
usr_favicon = os.path.join(usr_tpl, favicon)
|
||||||
usr_logo = os.path.join(usr_tpl, logo)
|
usr_logo = os.path.join(usr_tpl, logo)
|
||||||
usr_styles = os.path.join(usr_tpl, styles)
|
usr_styles = os.path.join(usr_tpl, styles)
|
||||||
|
@ -229,149 +230,164 @@ def dcf_update_values(srv):
|
||||||
|
|
||||||
# Update Domain Configuration File
|
# Update Domain Configuration File
|
||||||
#---------------------------------
|
#---------------------------------
|
||||||
dcf.set("DOMAIN", "name", conf_name)
|
cf.set("DOMAIN", "name", name)
|
||||||
dcf.set("TYTO", "domain_hash", tools.get_filesum(dcf_uri, False))
|
cf.set("TYTO", "domain_hash", tools.get_filesum(cf_uri, False))
|
||||||
dcf.set("TYTO", "domain_conf", dcf_uri)
|
cf.set("TYTO", "domain_conf", cf_uri)
|
||||||
dcf.set("TYTO", "domain_user", ult_dcf_uri)
|
cf.set("TYTO", "domain_user", ult_cf_uri)
|
||||||
|
|
||||||
# USER
|
# USER
|
||||||
dcf.set("USER_DIRS", "root", dcf_dir)
|
cf.set("USER_DIRS", "root", cf_dir)
|
||||||
dcf.set("USER_DIRS", "articles", dcf_dir + "articles/")
|
cf.set("USER_DIRS", "articles", cf_dir + "articles/")
|
||||||
dcf.set("USER_DIRS", "images", dcf_dir + "images/")
|
cf.set("USER_DIRS", "images", cf_dir + "images/")
|
||||||
dcf.set("USER_DIRS", "files", dcf_dir + "files/")
|
cf.set("USER_DIRS", "files", cf_dir + "files/")
|
||||||
dcf.set("USER_DIRS", "modules", usr_mods)
|
cf.set("USER_DIRS", "modules", usr_mods)
|
||||||
dcf.set("USER_DIRS", "database", dcf_dir + ".db/")
|
cf.set("USER_DIRS", "database", cf_dir + ".db/")
|
||||||
dcf.set("USER_DIRS", "template", usr_tpl)
|
cf.set("USER_DIRS", "template", usr_tpl)
|
||||||
|
|
||||||
dcf.set("USER_MODULES_FILES", "metas", usr_mods + "tyto_metas.raw")
|
cf.set("USER_MODULES_FILES", "metas", usr_mods + "tyto_metas.raw")
|
||||||
dcf.set("USER_MODULES_FILES", "header", usr_mods + "tyto_header.raw")
|
cf.set("USER_MODULES_FILES", "header", usr_mods + "tyto_header.raw")
|
||||||
dcf.set("USER_MODULES_FILES", "navbar", usr_mods + "tyto_navbar.raw")
|
cf.set("USER_MODULES_FILES", "navbar", usr_mods + "tyto_navbar.raw")
|
||||||
dcf.set("USER_MODULES_FILES", "sidebar", usr_mods + "tyto_sidebar.raw")
|
cf.set("USER_MODULES_FILES", "sidebar", usr_mods + "tyto_sidebar.raw")
|
||||||
dcf.set("USER_MODULES_FILES", "footer", usr_mods + "tyto_footer.raw")
|
cf.set("USER_MODULES_FILES", "footer", usr_mods + "tyto_footer.raw")
|
||||||
|
|
||||||
dcf.set("USER_TEMPLATE_FILES", "favicon", usr_favicon)
|
cf.set("USER_TEMPLATE_FILES", "favicon", usr_favicon)
|
||||||
dcf.set("USER_TEMPLATE_FILES", "logo", usr_logo)
|
cf.set("USER_TEMPLATE_FILES", "logo", usr_logo)
|
||||||
dcf.set("USER_TEMPLATE_FILES", "styles", usr_styles)
|
cf.set("USER_TEMPLATE_FILES", "styles", usr_styles)
|
||||||
|
|
||||||
# WEBSITE
|
# WEBSITE
|
||||||
dcf.set("WEBSITE", "lang", langs.site_lang)
|
cf.get("WEBSITE_MODULES", "sidebar_title") or \
|
||||||
dcf.get("WEBSITE_MODULES", "sidebar_title") or \
|
cf.set("WEBSITE_MODULES", "sidebar_title", langs.site.sidebar_title)
|
||||||
dcf.set("WEBSITE_MODULES", "sidebar_title", langs.site.sidebar_title)
|
cf.get("WEBSITE_MODULES", "sidebar_items").isdigit() or \
|
||||||
dcf.get("WEBSITE_MODULES", "sidebar_items").isdigit() or \
|
cf.set("WEBSITE_MODULES", "sidebar_items", "0")
|
||||||
dcf.set("WEBSITE_MODULES", "sidebar_items", "0")
|
cf.get("WEBSITE_MODULES", "rss_items").isdigit() or \
|
||||||
dcf.get("WEBSITE_MODULES", "rss_items").isdigit() or \
|
cf.set("WEBSITE_MODULES", "rss_items", "0")
|
||||||
dcf.set("WEBSITE_MODULES", "rss_items", "0")
|
|
||||||
|
|
||||||
dcf.set("TEMPLATE_FILENAMES", "favicon", favicon)
|
cf.set("TEMPLATE_FILENAMES", "favicon", favicon)
|
||||||
dcf.set("TEMPLATE_FILENAMES", "logo", logo)
|
cf.set("TEMPLATE_FILENAMES", "logo", logo)
|
||||||
dcf.set("TEMPLATE_FILENAMES", "styles", styles)
|
cf.set("TEMPLATE_FILENAMES", "styles", styles)
|
||||||
dcf.set("TEMPLATE_FILENAMES", "rss", rss)
|
cf.set("TEMPLATE_FILENAMES", "rss", rss)
|
||||||
dcf.set("TEMPLATE_FILENAMES", "stats", stats)
|
cf.set("TEMPLATE_FILENAMES", "stats", stats)
|
||||||
|
|
||||||
# SERVER
|
# SERVER
|
||||||
dcf.set("SERVER", "root", srv)
|
cf.set("SERVER", "root", srv)
|
||||||
dcf.set("SERVER", "domain", srv_dom)
|
cf.set("SERVER", "domain", srv_dom)
|
||||||
|
|
||||||
# WIP
|
# WIP
|
||||||
dcf.set("WIP_DIRS", "root", srv_wip)
|
cf.set("WIP_DIRS", "root", srv_wip)
|
||||||
dcf.set("WIP_DIRS", "images", srv_wip + "images/")
|
cf.set("WIP_DIRS", "images", srv_wip + "images/")
|
||||||
dcf.set("WIP_DIRS", "files", srv_wip + "files/")
|
cf.set("WIP_DIRS", "files", srv_wip + "files/")
|
||||||
dcf.set("WIP_DIRS", "template", wip_tpl)
|
cf.set("WIP_DIRS", "template", wip_tpl)
|
||||||
dcf.set("WIP_FILES", "favicon", wip_favicon)
|
cf.set("WIP_FILES", "favicon", wip_favicon)
|
||||||
dcf.set("WIP_FILES", "logo", wip_logo)
|
cf.set("WIP_FILES", "logo", wip_logo)
|
||||||
dcf.set("WIP_FILES", "styles", wip_styles)
|
cf.set("WIP_FILES", "styles", wip_styles)
|
||||||
dcf.set("WIP_FILES", "rss", wip_rss)
|
cf.set("WIP_FILES", "rss", wip_rss)
|
||||||
dcf.set("WIP_FILES", "stats", wip_stats)
|
cf.set("WIP_FILES", "stats", wip_stats)
|
||||||
dcf.set("WIP_FILES", "metas", wip_tpl + "metas.html")
|
cf.set("WIP_FILES", "metas", wip_tpl + "metas.html")
|
||||||
dcf.set("WIP_FILES", "header", wip_tpl + "header.html")
|
cf.set("WIP_FILES", "header", wip_tpl + "header.html")
|
||||||
dcf.set("WIP_FILES", "navbar", wip_tpl + "navbar.html")
|
cf.set("WIP_FILES", "navbar", wip_tpl + "navbar.html")
|
||||||
dcf.set("WIP_FILES", "sidebar", wip_tpl + "sidebar.html")
|
cf.set("WIP_FILES", "sidebar", wip_tpl + "sidebar.html")
|
||||||
dcf.set("WIP_FILES", "footer", wip_tpl + "footer.html")
|
cf.set("WIP_FILES", "footer", wip_tpl + "footer.html")
|
||||||
|
|
||||||
|
|
||||||
# WWW
|
# WWW
|
||||||
dcf.set("WWW_DIRS", "root", srv_www)
|
cf.set("WWW_DIRS", "root", srv_www)
|
||||||
dcf.set("WWW_DIRS", "images", srv_www + "images/")
|
cf.set("WWW_DIRS", "images", srv_www + "images/")
|
||||||
dcf.set("WWW_DIRS", "files", srv_www + "files/")
|
cf.set("WWW_DIRS", "files", srv_www + "files/")
|
||||||
dcf.set("WWW_DIRS", "template", www_tpl)
|
cf.set("WWW_DIRS", "template", www_tpl)
|
||||||
dcf.set("WWW_FILES", "favicon", www_favicon)
|
cf.set("WWW_FILES", "favicon", www_favicon)
|
||||||
dcf.set("WWW_FILES", "logo", www_logo)
|
cf.set("WWW_FILES", "logo", www_logo)
|
||||||
dcf.set("WWW_FILES", "styles", www_styles)
|
cf.set("WWW_FILES", "styles", www_styles)
|
||||||
dcf.set("WWW_FILES", "rss", www_rss)
|
cf.set("WWW_FILES", "rss", www_rss)
|
||||||
dcf.set("WWW_FILES", "stats", www_stats)
|
cf.set("WWW_FILES", "stats", www_stats)
|
||||||
dcf.set("WWW_FILES", "metas", www_tpl + "metas.html")
|
cf.set("WWW_FILES", "metas", www_tpl + "metas.html")
|
||||||
dcf.set("WWW_FILES", "header", www_tpl + "header.html")
|
cf.set("WWW_FILES", "header", www_tpl + "header.html")
|
||||||
dcf.set("WWW_FILES", "navbar", www_tpl + "navbar.html")
|
cf.set("WWW_FILES", "navbar", www_tpl + "navbar.html")
|
||||||
dcf.set("WWW_FILES", "sidebar", www_tpl + "sidebar.html")
|
cf.set("WWW_FILES", "sidebar", www_tpl + "sidebar.html")
|
||||||
dcf.set("WWW_FILES", "footer", www_tpl + "footer.html")
|
cf.set("WWW_FILES", "footer", www_tpl + "footer.html")
|
||||||
|
|
||||||
with open(dcf_uri, "w") as f:
|
with open(cf_uri, "w") as f:
|
||||||
dcf.write(f)
|
cf.write(f)
|
||||||
|
|
||||||
# Update User local domain configuration file
|
# Update User local domain configuration file
|
||||||
#--------------------------------------------
|
#--------------------------------------------
|
||||||
ult_dcf_load()
|
ult_cf_load()
|
||||||
ult_dcf.set("DOMAIN", "name", conf_name)
|
ult_cf.set("DOMAIN", "name", name)
|
||||||
ult_dcf.set("DOMAIN", "hash", tools.get_filesum(dcf_uri, True))
|
ult_cf.set("DOMAIN", "hash", tools.get_filesum(cf_uri, True))
|
||||||
ult_dcf.set("DOMAIN", "root", dcf_dir)
|
ult_cf.set("DOMAIN", "root", cf_dir)
|
||||||
ult_dcf.set("DOMAIN", "conf", dcf_uri)
|
ult_cf.set("DOMAIN", "conf", cf_uri)
|
||||||
ult_dcf.set("SERVER", "root", srv)
|
ult_cf.set("SERVER", "root", srv)
|
||||||
|
|
||||||
with open(ult_dcf_uri, "w") as f:
|
with open(ult_cf_uri, "w") as f:
|
||||||
ult_dcf.write(f)
|
ult_cf.write(f)
|
||||||
|
|
||||||
# Update User local Domains List File
|
# Update User local Domains List File
|
||||||
#------------------------------------
|
#------------------------------------
|
||||||
ult_dlf_load()
|
ult_dlf_load()
|
||||||
ult_dlf.set("DOMAINS", conf_name, dcf_dir)
|
ult_dlf.set("DOMAINS", name, cf_dir)
|
||||||
|
|
||||||
with open(ult_dlf_uri, "w") as f:
|
with open(ult_dlf_uri, "w") as f:
|
||||||
ult_dlf.write(f)
|
ult_dlf.write(f)
|
||||||
|
|
||||||
debug.out(204, "True", dcf_uri, True, 0, False)
|
debug.out(204, "True", cf_uri, True, 0, False)
|
||||||
|
|
||||||
|
|
||||||
#=============================================#
|
#=============================================#
|
||||||
# Ensure domain is valid and ready to be used #
|
# Ensure domain is valid and ready to be used #
|
||||||
#---------------------------------------------#
|
#---------------------------------------------#
|
||||||
def valid_conf():
|
def cf_valid():
|
||||||
global active
|
global active
|
||||||
|
|
||||||
dcf_load()
|
cf_load()
|
||||||
# - dcf name must be config_name
|
# - cf name must be config_name
|
||||||
try: dcf_name = dcf.get("DOMAIN", "name")
|
try: cf_name = cf.get("DOMAIN", "name")
|
||||||
except: debug.out(100, conf_name, dcf_uri, True, 2, True)
|
except: debug.out(100, name, cf_uri, True, 2, True)
|
||||||
if dcf_name != conf_name:
|
|
||||||
debug.out(100, conf_name, dcf_uri, True, 2, True)
|
if cf_name != name:
|
||||||
|
debug.out(100, name, cf_uri, True, 2, True)
|
||||||
|
|
||||||
# - root server must exists
|
# - root server must exists
|
||||||
try: dcf_srv = dcf.get("SERVER", "root")
|
try: cf_srv = cf.get("SERVER", "root")
|
||||||
except: debug.out(100, "SERVER root", "?", True, 2, True)
|
except: debug.out(100, "SERVER root", "?", True, 2, True)
|
||||||
if not dcf_srv or not tools.dir_exists(dcf_srv, True):
|
if not cf_srv or not tools.dir_exists(cf_srv, True):
|
||||||
debug.out(100, "SERVER root", "? %s"%dcf_srv, True, 2, True)
|
debug.out(100, "SERVER root", "? %s"%cf_srv, True, 2, True)
|
||||||
|
|
||||||
# Check some values in ult_dcf
|
# Check some values in ult_cf
|
||||||
ult_dcf_load()
|
ult_cf_load()
|
||||||
try:
|
try:
|
||||||
ult_dcf_name = ult_dcf.get("DOMAIN", "name")
|
ult_cf_name = ult_cf.get("DOMAIN", "name")
|
||||||
ult_dcf_hash = ult_dcf.get("DOMAIN", "hash")
|
ult_cf_hash = ult_cf.get("DOMAIN", "hash")
|
||||||
ult_dcf_conf = ult_dcf.get("DOMAIN", "conf")
|
ult_cf_conf = ult_cf.get("DOMAIN", "conf")
|
||||||
ult_dcf_root = ult_dcf.get("DOMAIN", "root")
|
ult_cf_root = ult_cf.get("DOMAIN", "root")
|
||||||
except:
|
except:
|
||||||
debug.out(100, conf_name, ult_dcf_uri, True, 1, True)
|
debug.out(100, name, ult_cf_uri, True, 1, True)
|
||||||
|
|
||||||
# Compare values (exit if mismatch)
|
# Compare values (exit if mismatch)
|
||||||
if ult_dcf_name != conf_name or \
|
if ult_cf_name != name or \
|
||||||
ult_dcf_conf != dcf_uri or \
|
ult_cf_conf != cf_uri or \
|
||||||
dcf_name != ult_dcf_name:
|
cf_name != ult_cf_name:
|
||||||
debug.out(100, conf_name, "?", True, 1, True)
|
debug.out(100, name, "?", True, 1, True)
|
||||||
|
|
||||||
# Check if dcf need to be updated
|
# Check if cf need to be updated
|
||||||
now_dcf_hash = tools.get_filesum(dcf_uri, True)
|
now_cf_hash = tools.get_filesum(cf_uri, True)
|
||||||
if now_dcf_hash != ult_dcf_hash:
|
if now_cf_hash != ult_cf_hash:
|
||||||
dcf_update_values("")
|
cf_update_values("")
|
||||||
|
|
||||||
return is_active()
|
active = is_active()
|
||||||
|
active and create_work_dirs()
|
||||||
|
return active
|
||||||
|
|
||||||
|
|
||||||
|
#========================================#
|
||||||
|
# When user wants to (de)activate domain #
|
||||||
|
#----------------------------------------#
|
||||||
|
def userset_status(action):
|
||||||
|
do = {
|
||||||
|
"start" : "yes",
|
||||||
|
"stop" : "no"
|
||||||
|
}
|
||||||
|
|
||||||
|
tools.update_ini_file(cf_uri, "DOMAIN", "activated", do[action])
|
||||||
|
cf_valid()
|
||||||
|
|
||||||
|
|
||||||
#==============================#
|
#==============================#
|
||||||
|
@ -379,12 +395,22 @@ def valid_conf():
|
||||||
# Return True or False
|
# Return True or False
|
||||||
#------------------------------#
|
#------------------------------#
|
||||||
def is_active():
|
def is_active():
|
||||||
dcf_load()
|
cf_load()
|
||||||
# Domain activated ?
|
# Domain activated ?
|
||||||
try: return dcf.getboolean("DOMAIN", "activated")
|
try: return cf.getboolean("DOMAIN", "activated")
|
||||||
except: return False
|
except: return False
|
||||||
|
|
||||||
|
|
||||||
|
#===================================#
|
||||||
|
# Create user domain work directory #
|
||||||
|
#-----------------------------------#
|
||||||
|
def create_work_dirs():
|
||||||
|
cf_load()
|
||||||
|
|
||||||
|
for key, directory in cf.items("USER_DIRS"):
|
||||||
|
tools.create_dirs(directory)
|
||||||
|
|
||||||
|
|
||||||
#======#=======================================================================
|
#======#=======================================================================
|
||||||
# MAIN #
|
# MAIN #
|
||||||
#------#
|
#------#
|
||||||
|
@ -401,20 +427,20 @@ except:
|
||||||
|
|
||||||
#==========================================#
|
#==========================================#
|
||||||
# utl: $USER/.local/Tyto #
|
# utl: $USER/.local/Tyto #
|
||||||
# dcf: Domain Configuration File #
|
# cf: Domain Configuration File #
|
||||||
#------------------------------------------#
|
#------------------------------------------#
|
||||||
# Domain Configuration directory
|
# Domain Configuration directory
|
||||||
dcf_dir = user_dir.rsplit("articles/")[0]
|
cf_dir = user_dir.rsplit("articles/")[0]
|
||||||
|
|
||||||
# Domain name from current basename directory
|
# Domain name from current basename directory
|
||||||
# Exit if not format at least "abc.tld"
|
# Exit if not format at least "abc.tld"
|
||||||
conf_name = os.path.basename(os.path.dirname(dcf_dir))
|
name = os.path.basename(os.path.dirname(cf_dir))
|
||||||
|
|
||||||
dcf_name = "tyto_domain.ini"
|
cf_name = "tyto_domain.ini"
|
||||||
dcf_uri = os.path.join(dcf_dir, dcf_name)
|
cf_uri = os.path.join(cf_dir, cf_name)
|
||||||
dcf_id = tools.get_filesum(dcf_uri, False) # ID from URI
|
cf_id = tools.get_filesum(cf_uri, False) # ID from URI
|
||||||
|
|
||||||
# Tyto directory in home local user files
|
# Tyto directory in home local user files
|
||||||
ult_dir = os.path.join(home_dir, ".local/Tyto/")
|
ult_dir = os.path.join(home_dir, ".local/Tyto/")
|
||||||
ult_dlf_uri = os.path.join(ult_dir, "domains.ini") # Domains list file
|
ult_dlf_uri = os.path.join(ult_dir, "domains.ini") # Domains list file
|
||||||
ult_dcf_uri = os.path.join(ult_dir, dcf_id + ".ini")
|
ult_cf_uri = os.path.join(ult_dir, cf_id + ".ini")
|
||||||
|
|
|
@ -102,13 +102,13 @@ def ask_domain_shortname(config_name):
|
||||||
# Getting domain Title #
|
# Getting domain Title #
|
||||||
#----------------------#
|
#----------------------#
|
||||||
def ask_domain_title():
|
def ask_domain_title():
|
||||||
domain.dcf_load()
|
domain.cf_load()
|
||||||
title = domain.dcf.get("DOMAIN", "title")
|
title = domain.cf.get("DOMAIN", "title")
|
||||||
|
|
||||||
q = "> %s (%s)%s "%(langs.logs.domain_title, shorter(title), langs.logs.q)
|
q = "> %s (%s)%s "%(langs.logs.domain_title, shorter(title), langs.logs.q)
|
||||||
answer = ask(q, False, title)
|
answer = ask(q, False, title)
|
||||||
if answer != title:
|
if answer != title:
|
||||||
tools.update_ini_file(domain.dcf_uri, "DOMAIN", "title", answer)
|
tools.update_ini_file(domain.cf_uri, "DOMAIN", "title", answer)
|
||||||
|
|
||||||
|
|
||||||
#===========================#
|
#===========================#
|
||||||
|
@ -116,8 +116,8 @@ def ask_domain_title():
|
||||||
# Check if date match regex #
|
# Check if date match regex #
|
||||||
#---------------------------#
|
#---------------------------#
|
||||||
def ask_domain_date():
|
def ask_domain_date():
|
||||||
domain.dcf_load()
|
domain.cf_load()
|
||||||
date = domain.dcf.get("DOMAIN", "date")
|
date = domain.cf.get("DOMAIN", "date")
|
||||||
example = date or "YYYY[-MM-DD]"
|
example = date or "YYYY[-MM-DD]"
|
||||||
|
|
||||||
q = "> %s (%s)%s "%(langs.logs.domain_date, example, langs.logs.q)
|
q = "> %s (%s)%s "%(langs.logs.domain_date, example, langs.logs.q)
|
||||||
|
@ -141,41 +141,41 @@ def ask_domain_date():
|
||||||
debug.out(50, "YYYY[-MM-DD]", answer, True, 2, True)
|
debug.out(50, "YYYY[-MM-DD]", answer, True, 2, True)
|
||||||
|
|
||||||
if answer != date:
|
if answer != date:
|
||||||
tools.update_ini_file(domain.dcf_uri, "DOMAIN", "date", answer)
|
tools.update_ini_file(domain.cf_uri, "DOMAIN", "date", answer)
|
||||||
|
|
||||||
|
|
||||||
#========================#
|
#========================#
|
||||||
# Get domain description #
|
# Get domain description #
|
||||||
#------------------------#
|
#------------------------#
|
||||||
def ask_domain_about():
|
def ask_domain_about():
|
||||||
domain.dcf_load()
|
domain.cf_load()
|
||||||
about = domain.dcf.get("DOMAIN", "about")
|
about = domain.cf.get("DOMAIN", "about")
|
||||||
|
|
||||||
q = "> %s (%s)%s "%(langs.logs.domain_about, shorter(about), langs.logs.q)
|
q = "> %s (%s)%s "%(langs.logs.domain_about, shorter(about), langs.logs.q)
|
||||||
answer = ask(q, False, about)
|
answer = ask(q, False, about)
|
||||||
if answer != about:
|
if answer != about:
|
||||||
tools.update_ini_file(domain.dcf_uri, "DOMAIN", "about", answer)
|
tools.update_ini_file(domain.cf_uri, "DOMAIN", "about", answer)
|
||||||
|
|
||||||
|
|
||||||
#=======================#
|
#=======================#
|
||||||
# Get domain admin mail #
|
# Get domain admin mail #
|
||||||
#-----------------------#
|
#-----------------------#
|
||||||
def ask_domain_mail():
|
def ask_domain_mail():
|
||||||
domain.dcf_load()
|
domain.cf_load()
|
||||||
mail = domain.dcf.get("DOMAIN", "mail")
|
mail = domain.cf.get("DOMAIN", "mail")
|
||||||
|
|
||||||
q = "> %s (%s)%s "%(langs.logs.domain_mail, shorter(mail), langs.logs.q)
|
q = "> %s (%s)%s "%(langs.logs.domain_mail, shorter(mail), langs.logs.q)
|
||||||
answer = ask(q, False, mail)
|
answer = ask(q, False, mail)
|
||||||
if answer != mail:
|
if answer != mail:
|
||||||
tools.update_ini_file(domain.dcf_uri, "DOMAIN", "mail", answer)
|
tools.update_ini_file(domain.cf_uri, "DOMAIN", "mail", answer)
|
||||||
|
|
||||||
|
|
||||||
#===============================================#
|
#===============================================#
|
||||||
# Get domain tags (wil be used in all articles) #
|
# Get domain tags (wil be used in all articles) #
|
||||||
#-----------------------------------------------#
|
#-----------------------------------------------#
|
||||||
def ask_domain_tags():
|
def ask_domain_tags():
|
||||||
domain.dcf_load()
|
domain.cf_load()
|
||||||
tags = domain.dcf.get("DOMAIN", "tags")
|
tags = domain.cf.get("DOMAIN", "tags")
|
||||||
|
|
||||||
q = "> %s (%s)%s "%(langs.logs.domain_tags, shorter(tags), langs.logs.q)
|
q = "> %s (%s)%s "%(langs.logs.domain_tags, shorter(tags), langs.logs.q)
|
||||||
answer = ask(q, False, tags)
|
answer = ask(q, False, tags)
|
||||||
|
@ -189,7 +189,7 @@ def ask_domain_tags():
|
||||||
if i != len(tuple_tags) - 1:
|
if i != len(tuple_tags) - 1:
|
||||||
answer = answer + ","
|
answer = answer + ","
|
||||||
|
|
||||||
tools.update_ini_file(domain.dcf_uri, "DOMAIN", "tags", answer)
|
tools.update_ini_file(domain.cf_uri, "DOMAIN", "tags", answer)
|
||||||
|
|
||||||
|
|
||||||
#===================================#
|
#===================================#
|
||||||
|
@ -197,8 +197,8 @@ def ask_domain_tags():
|
||||||
# default en if no translation file # > !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! < TODO
|
# default en if no translation file # > !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! < TODO
|
||||||
#-----------------------------------#
|
#-----------------------------------#
|
||||||
def ask_domain_lang():
|
def ask_domain_lang():
|
||||||
domain.dcf_load()
|
langs.get_website_lang()
|
||||||
lang = domain.dcf.get("WEBSITE", "lang") or langs.get_sys_lang()
|
lang = langs.site_lang
|
||||||
|
|
||||||
q = "> %s (%s)%s "%(langs.logs.domain_lang, lang, langs.logs.q)
|
q = "> %s (%s)%s "%(langs.logs.domain_lang, lang, langs.logs.q)
|
||||||
answer = ask(q, False, lang).lower()
|
answer = ask(q, False, lang).lower()
|
||||||
|
@ -206,26 +206,26 @@ def ask_domain_lang():
|
||||||
# Lang Format is 2 character
|
# Lang Format is 2 character
|
||||||
if len(answer) != 2:
|
if len(answer) != 2:
|
||||||
debug.out("8", "xx", answer, True, 2, False)
|
debug.out("8", "xx", answer, True, 2, False)
|
||||||
ask_domain_lang()
|
debug.out(103, "en", "%swebsite_en.py"%langs.trfs, True, 1, False)
|
||||||
return
|
answer = lang
|
||||||
|
|
||||||
# Check if translation file exists
|
# Check if translation file exists
|
||||||
if not langs.translation_exists("website", answer, False):
|
if not langs.translation_exists("website", answer, False):
|
||||||
debug.out(103, "en", "%swebsite_en.py"%langs.trfs, True, 1, False)
|
debug.out(103, "en", "%swebsite_en.py"%langs.trfs, True, 1, False)
|
||||||
answer = "en"
|
answer = lang
|
||||||
|
|
||||||
if answer != lang:
|
if answer != lang:
|
||||||
tools.update_ini_file(domain.dcf_uri, "WEBSITE", "lang", answer)
|
tools.update_ini_file(domain.cf_uri, "WEBSITE", "lang", answer)
|
||||||
|
|
||||||
|
|
||||||
#===================================#
|
#===================================#
|
||||||
# Get domain server root #
|
# Get domain server root #
|
||||||
#-----------------------------------#
|
#-----------------------------------#
|
||||||
def ask_domain_server():
|
def ask_domain_server():
|
||||||
domain.dcf_load()
|
domain.cf_load()
|
||||||
srv = domain.dcf.get("SERVER", "root")
|
srv = domain.cf.get("SERVER", "root")
|
||||||
|
|
||||||
if srv and not not tools.dir_exists(srv, False):
|
if srv and not tools.dir_exists(srv, False):
|
||||||
srv = ""
|
srv = ""
|
||||||
|
|
||||||
q = "> %s (%s)%s "%(langs.logs.domain_srv, srv, langs.logs.q)
|
q = "> %s (%s)%s "%(langs.logs.domain_srv, srv, langs.logs.q)
|
||||||
|
@ -237,5 +237,5 @@ def ask_domain_server():
|
||||||
ask_domain_server()
|
ask_domain_server()
|
||||||
return
|
return
|
||||||
|
|
||||||
domain.dcf_update_values(answer)
|
domain.cf_update_values(answer)
|
||||||
|
|
||||||
|
|
|
@ -104,14 +104,14 @@ def load_logs_lang():
|
||||||
# Get/Set and import file | #
|
# Get/Set and import file | #
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
#=======================================#
|
#=======================================#
|
||||||
# Get website lang from dcf to set site #
|
# Get website lang from cf to set site #
|
||||||
#---------------------------------------#
|
#---------------------------------------#
|
||||||
def get_website_lang():
|
def get_website_lang():
|
||||||
global site_lang, tr_website_uri
|
global site_lang, tr_website_uri
|
||||||
|
|
||||||
tr_website_uri = "%swebsite_%s.py"
|
tr_website_uri = "%swebsite_%s.py"
|
||||||
domain.dcf_load()
|
domain.cf_load()
|
||||||
site_lang = domain.dcf.get("WEBSITE", "lang")
|
site_lang = domain.cf.get("WEBSITE", "lang") or get_sys_lang()
|
||||||
|
|
||||||
if not translation_exists("website", site_lang, False):
|
if not translation_exists("website", site_lang, False):
|
||||||
site_lang = get_sys_lang() # or default "en"
|
site_lang = get_sys_lang() # or default "en"
|
||||||
|
|
|
@ -54,8 +54,8 @@ def manage(action, target):
|
||||||
# or if user "force" option
|
# or if user "force" option
|
||||||
#-----------------------------------#
|
#-----------------------------------#
|
||||||
def create_domain():
|
def create_domain():
|
||||||
if not domain.dcf_exists() or args.force:
|
if not domain.cf_exists() or args.force:
|
||||||
domain.dcf_create()
|
domain.cf_create()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# Tyto - Littérateur
|
||||||
|
|
||||||
|
# Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
|
||||||
|
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
# XMPP: echolib (im@echolib.re)
|
||||||
|
#
|
||||||
|
# Description: About post (from target) database, uri...
|
||||||
|
# File: /var/lib/tyto/program/new.py
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#-------------------------
|
||||||
|
# Funny Stats Project
|
||||||
|
#-------------------------
|
||||||
|
# file lines :
|
||||||
|
# file comments :
|
||||||
|
# file functions:
|
||||||
|
# file program :
|
||||||
|
#--------------------------
|
|
@ -63,6 +63,19 @@ def dir_exists(dir_path, out):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
#====================#
|
||||||
|
# Create directories #
|
||||||
|
#--------------------#
|
||||||
|
def create_dirs(path):
|
||||||
|
try:
|
||||||
|
if not os.path.exists(path):
|
||||||
|
os.makedirs(path, exist_ok=True)
|
||||||
|
debug.out(203, "True", path, False, 0, False)
|
||||||
|
except:
|
||||||
|
# Exit if not created
|
||||||
|
debug.out(5, "False", path, True, 2, True)
|
||||||
|
|
||||||
|
|
||||||
#============================#
|
#============================#
|
||||||
# Create a new file and logs #
|
# Create a new file and logs #
|
||||||
#----------------------------#
|
#----------------------------#
|
||||||
|
@ -76,8 +89,10 @@ def create_file(file_path, contents):
|
||||||
# Exit at error
|
# Exit at error
|
||||||
debug.out(7, "False", file_path, True, 2, True)
|
debug.out(7, "False", file_path, True, 2, True)
|
||||||
|
|
||||||
if up: debug.out(207, file_path, False, 0, False)
|
# log "update" or "new"
|
||||||
else: debug.out(206, file_path, False, 0, False)
|
file_name = os.path.basename(file_path)
|
||||||
|
if up: debug.out(207, file_name, file_path, False, 0, False)
|
||||||
|
else: debug.out(206, file_name, file_path, False, 0, False)
|
||||||
|
|
||||||
|
|
||||||
#===========================================#
|
#===========================================#
|
||||||
|
@ -88,23 +103,15 @@ def update_ini_file(file_path, section, key, val):
|
||||||
if not os.path.exists(file_path):
|
if not os.path.exists(file_path):
|
||||||
debug.out(5, "False", file_path, True, 2, True)
|
debug.out(5, "False", file_path, True, 2, True)
|
||||||
|
|
||||||
|
# Load ini file
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(file_path)
|
config.read(file_path)
|
||||||
config.set(section, key, val)
|
|
||||||
|
|
||||||
|
# New value is same as registred
|
||||||
|
if config.get(section, key) == val:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Update file with new value
|
||||||
|
config.set(section, key, val)
|
||||||
with open(file_path, "w") as f:
|
with open(file_path, "w") as f:
|
||||||
config.write(f)
|
config.write(f)
|
||||||
|
|
||||||
|
|
||||||
#====================#
|
|
||||||
# Create directories #
|
|
||||||
#--------------------#
|
|
||||||
def create_dirs(path):
|
|
||||||
try:
|
|
||||||
if not os.path.exists(path):
|
|
||||||
os.makedirs(path, exist_ok=True)
|
|
||||||
debug.out(203, "True", path, False, 0, False)
|
|
||||||
except:
|
|
||||||
# Exit if not created
|
|
||||||
debug.out(5, "False", path, True, 2, True)
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#
|
#
|
||||||
actions = (
|
actions = (
|
||||||
"check", "wip", "publish",
|
"check", "wip", "publish",
|
||||||
|
"start", "stop",
|
||||||
"new",
|
"new",
|
||||||
"set",
|
"set",
|
||||||
"show",
|
"show",
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
# file program :
|
# file program :
|
||||||
#--------------------------
|
#--------------------------
|
||||||
|
|
||||||
import langs, forms
|
import langs, forms, domain
|
||||||
|
|
||||||
|
|
||||||
#====================================#
|
#====================================#
|
||||||
|
@ -40,6 +40,7 @@ import langs, forms
|
||||||
# Specific to action "set #
|
# Specific to action "set #
|
||||||
#------------------------------------#
|
#------------------------------------#
|
||||||
def manage(action, target):
|
def manage(action, target):
|
||||||
|
if action == "set":
|
||||||
do = {
|
do = {
|
||||||
"title" : forms.ask_domain_title,
|
"title" : forms.ask_domain_title,
|
||||||
"date" : forms.ask_domain_date,
|
"date" : forms.ask_domain_date,
|
||||||
|
@ -50,4 +51,8 @@ def manage(action, target):
|
||||||
}
|
}
|
||||||
|
|
||||||
do[target]()
|
do[target]()
|
||||||
|
elif action in ("start", "stop") \
|
||||||
|
and target == "domain":
|
||||||
|
domain.userset_status(action)
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -42,6 +42,8 @@ tyto [action] [target] [options]
|
||||||
[action]
|
[action]
|
||||||
new : create new domain (reset with -F)
|
new : create new domain (reset with -F)
|
||||||
set : set website lang, domain values (title, server...)
|
set : set website lang, domain values (title, server...)
|
||||||
|
start : activate domain (default "no" when created)
|
||||||
|
stop : deactivate domain
|
||||||
check :
|
check :
|
||||||
wip :
|
wip :
|
||||||
publish :
|
publish :
|
||||||
|
|
|
@ -86,6 +86,8 @@ tyto [action] [target] [options]
|
||||||
[action]
|
[action]
|
||||||
new : créer un nouveau domaine (réinitialisé avec -F)
|
new : créer un nouveau domaine (réinitialisé avec -F)
|
||||||
set : définir la langue du site web, du domaine (titre, serveur...)
|
set : définir la langue du site web, du domaine (titre, serveur...)
|
||||||
|
start : activer le domaine (défaut "no" à la création)
|
||||||
|
stop : désactiver le domaine
|
||||||
show : [domains]
|
show : [domains]
|
||||||
check :
|
check :
|
||||||
wip :
|
wip :
|
||||||
|
|
Loading…
Reference in New Issue