mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[CI] Format code with Black
This commit is contained in:
parent
56c4740274
commit
61b5bb02f4
3 changed files with 48 additions and 31 deletions
42
src/hook.py
42
src/hook.py
|
@ -355,27 +355,27 @@ def hook_exec(
|
||||||
r"update-alternatives: ",
|
r"update-alternatives: ",
|
||||||
# Postgresql boring messages -_-
|
# Postgresql boring messages -_-
|
||||||
r"Building PostgreSQL dictionaries from .*",
|
r"Building PostgreSQL dictionaries from .*",
|
||||||
r'Removing obsolete dictionary files',
|
r"Removing obsolete dictionary files",
|
||||||
r'Creating new PostgreSQL cluster',
|
r"Creating new PostgreSQL cluster",
|
||||||
r'/usr/lib/postgresql/13/bin/initdb',
|
r"/usr/lib/postgresql/13/bin/initdb",
|
||||||
r'The files belonging to this database system will be owned by user',
|
r"The files belonging to this database system will be owned by user",
|
||||||
r'This user must also own the server process.',
|
r"This user must also own the server process.",
|
||||||
r'The database cluster will be initialized with locale',
|
r"The database cluster will be initialized with locale",
|
||||||
r'The default database encoding has accordingly been set to',
|
r"The default database encoding has accordingly been set to",
|
||||||
r'The default text search configuration will be set to',
|
r"The default text search configuration will be set to",
|
||||||
r'Data page checksums are disabled.',
|
r"Data page checksums are disabled.",
|
||||||
r'fixing permissions on existing directory /var/lib/postgresql/13/main ... ok',
|
r"fixing permissions on existing directory /var/lib/postgresql/13/main ... ok",
|
||||||
r'creating subdirectories \.\.\. ok',
|
r"creating subdirectories \.\.\. ok",
|
||||||
r'selecting dynamic .* \.\.\. ',
|
r"selecting dynamic .* \.\.\. ",
|
||||||
r'selecting default .* \.\.\. ',
|
r"selecting default .* \.\.\. ",
|
||||||
r'creating configuration files \.\.\. ok',
|
r"creating configuration files \.\.\. ok",
|
||||||
r'running bootstrap script \.\.\. ok',
|
r"running bootstrap script \.\.\. ok",
|
||||||
r'performing post-bootstrap initialization \.\.\. ok',
|
r"performing post-bootstrap initialization \.\.\. ok",
|
||||||
r'syncing data to disk \.\.\. ok',
|
r"syncing data to disk \.\.\. ok",
|
||||||
r'Success. You can now start the database server using:',
|
r"Success. You can now start the database server using:",
|
||||||
r'pg_ctlcluster \d\d main start',
|
r"pg_ctlcluster \d\d main start",
|
||||||
r'Ver\s*Cluster\s*Port\s*Status\s*Owner\s*Data\s*directory',
|
r"Ver\s*Cluster\s*Port\s*Status\s*Owner\s*Data\s*directory",
|
||||||
r'/var/lib/postgresql/\d\d/main /var/log/postgresql/postgresql-\d\d-main.log',
|
r"/var/lib/postgresql/\d\d/main /var/log/postgresql/postgresql-\d\d-main.log",
|
||||||
]
|
]
|
||||||
return all(not re.search(w, msg) for w in irrelevant_warnings)
|
return all(not re.search(w, msg) for w in irrelevant_warnings)
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,9 @@ def tools_postinstall(
|
||||||
)
|
)
|
||||||
|
|
||||||
if username in ADMIN_ALIASES:
|
if username in ADMIN_ALIASES:
|
||||||
raise YunohostValidationError(f"Unfortunately, {username} cannot be used as a username", raw_msg=True)
|
raise YunohostValidationError(
|
||||||
|
f"Unfortunately, {username} cannot be used as a username", raw_msg=True
|
||||||
|
)
|
||||||
|
|
||||||
# Check there's at least 10 GB on the rootfs...
|
# Check there's at least 10 GB on the rootfs...
|
||||||
disk_partitions = sorted(
|
disk_partitions = sorted(
|
||||||
|
|
|
@ -50,22 +50,31 @@ class AppResourceManager:
|
||||||
self.validate()
|
self.validate()
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
|
||||||
resources = self.wanted["resources"]
|
resources = self.wanted["resources"]
|
||||||
|
|
||||||
if "database" in list(resources.keys()):
|
if "database" in list(resources.keys()):
|
||||||
if "apt" not in list(resources.keys()):
|
if "apt" not in list(resources.keys()):
|
||||||
logger.error(" ! Packagers: having an 'apt' resource is mandatory when using a 'database' resource, to also install postgresql/mysql if needed")
|
logger.error(
|
||||||
|
" ! Packagers: having an 'apt' resource is mandatory when using a 'database' resource, to also install postgresql/mysql if needed"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
if list(resources.keys()).index("database") < list(resources.keys()).index("apt"):
|
if list(resources.keys()).index("database") < list(
|
||||||
logger.error(" ! Packagers: the 'apt' resource should be placed before the 'database' resource, to install postgresql/mysql if needed *before* provisioning the database")
|
resources.keys()
|
||||||
|
).index("apt"):
|
||||||
|
logger.error(
|
||||||
|
" ! Packagers: the 'apt' resource should be placed before the 'database' resource, to install postgresql/mysql if needed *before* provisioning the database"
|
||||||
|
)
|
||||||
|
|
||||||
dbtype = resources["database"]["type"]
|
dbtype = resources["database"]["type"]
|
||||||
apt_packages = resources["apt"].get("packages", "").split(", ")
|
apt_packages = resources["apt"].get("packages", "").split(", ")
|
||||||
if dbtype == "mysql" and "mariadb-server" not in apt_packages:
|
if dbtype == "mysql" and "mariadb-server" not in apt_packages:
|
||||||
logger.error(" ! Packagers : when using a mysql database, you should add mariadb-server in apt dependencies. Even though it's currently installed by default in YunoHost installations, it might not be in the future !")
|
logger.error(
|
||||||
|
" ! Packagers : when using a mysql database, you should add mariadb-server in apt dependencies. Even though it's currently installed by default in YunoHost installations, it might not be in the future !"
|
||||||
|
)
|
||||||
if dbtype == "postgresql" and "postgresql" not in apt_packages:
|
if dbtype == "postgresql" and "postgresql" not in apt_packages:
|
||||||
logger.error(" ! Packagers : when using a postgresql database, you should add postgresql in apt dependencies.")
|
logger.error(
|
||||||
|
" ! Packagers : when using a postgresql database, you should add postgresql in apt dependencies."
|
||||||
|
)
|
||||||
|
|
||||||
def apply(
|
def apply(
|
||||||
self, rollback_and_raise_exception_if_failure, operation_logger=None, **context
|
self, rollback_and_raise_exception_if_failure, operation_logger=None, **context
|
||||||
|
@ -458,7 +467,11 @@ class SystemuserAppResource(AppResource):
|
||||||
type = "system_user"
|
type = "system_user"
|
||||||
priority = 20
|
priority = 20
|
||||||
|
|
||||||
default_properties: Dict[str, Any] = {"allow_ssh": False, "allow_sftp": False, "home": "/var/www/__APP__"}
|
default_properties: Dict[str, Any] = {
|
||||||
|
"allow_ssh": False,
|
||||||
|
"allow_sftp": False,
|
||||||
|
"home": "/var/www/__APP__",
|
||||||
|
}
|
||||||
|
|
||||||
# FIXME : wat do regarding ssl-cert, multimedia, and other groups
|
# FIXME : wat do regarding ssl-cert, multimedia, and other groups
|
||||||
|
|
||||||
|
@ -502,8 +515,10 @@ class SystemuserAppResource(AppResource):
|
||||||
# So we gotta brute force by replacing the line in /etc/passwd T_T
|
# So we gotta brute force by replacing the line in /etc/passwd T_T
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
user_infos[5] = self.home
|
user_infos[5] = self.home
|
||||||
new_raw_user_line_in_etc_passwd = ':'.join(user_infos)
|
new_raw_user_line_in_etc_passwd = ":".join(user_infos)
|
||||||
os.system(f"sed -i 's@{raw_user_line_in_etc_passwd}@{new_raw_user_line_in_etc_passwd}@g' /etc/passwd")
|
os.system(
|
||||||
|
f"sed -i 's@{raw_user_line_in_etc_passwd}@{new_raw_user_line_in_etc_passwd}@g' /etc/passwd"
|
||||||
|
)
|
||||||
|
|
||||||
def deprovision(self, context: Dict = {}):
|
def deprovision(self, context: Dict = {}):
|
||||||
if os.system(f"getent passwd {self.app} >/dev/null 2>/dev/null") == 0:
|
if os.system(f"getent passwd {self.app} >/dev/null 2>/dev/null") == 0:
|
||||||
|
|
Loading…
Add table
Reference in a new issue