remove irrelevant os.path.exists() checks

This commit is contained in:
2e20 2024-10-07 02:57:27 +02:00
parent 5d4d2d6a62
commit f699f5fe31

View file

@ -2,8 +2,6 @@ from pyinfra import host
from pyinfra.operations import apt, server, files
from pyinfra.facts.server import LinuxName
import os
files_path = "files/matrix-synapse/"
## don't exexute on a local mashine
@ -95,15 +93,11 @@ if host.name != "@local":
## copy doas config
doas_conf_path = files_path +"doas.conf"
exi = os.path.exists(doas_conf_path)
if exi == True:
files.put(
name="copy doas config",
src=doas_conf_path,
dest="/etc/doas.conf",
)
else:
print("file: \"" +doas_conf_path +"\" dosn't exists")
files.put(
name="copy doas config",
src=doas_conf_path,
dest="/etc/doas.conf",
)
## generate synapse config
server.shell(
@ -135,39 +129,27 @@ if host.name != "@local":
## copy synapse config
homeserver_py_path = files_path +"homeserver.yaml"
exi = os.path.exists(homeserver_py_path)
if exi == True:
files.put(
name="copy synapse config",
src=homeserver_py_path,
dest="/var/synapse/homeserver.yaml",
)
else:
print("file: \"" +homeserver_py_path +"\" dosn't exists")
files.put(
name="copy synapse config",
src=homeserver_py_path,
dest="/var/synapse/homeserver.yaml",
)
## copy logging config
log_conf_path = files_path + "chat.heizhaus.org.log.config"
exi = os.path.exists(log_conf_path)
if exi == True:
files.put(
name="copy logging config",
src=log_conf_path,
dest="/var/synapse/chat.heizhaus.org.log.config",
)
else:
print("file: \"" +log_conf_path +"\" dosn't exists")
files.put(
name="copy logging config",
src=log_conf_path,
dest="/var/synapse/chat.heizhaus.org.log.config",
)
## add synapse commands to PATH
dotprofile_path = files_path +"dotprofile"
exi = os.path.exists(dotprofile_path)
if exi == True:
files.put(
name="add synapse commands to PATH",
src=dotprofile_path,
dest="/root/.profile",
)
else:
print("file: \"" +dotprofile_path +"\" dosn't exists")
files.put(
name="add synapse commands to PATH",
src=dotprofile_path,
dest="/root/.profile",
)
## change owner for /var/synapse
# user_name = "_synapse"
@ -204,12 +186,8 @@ if host.name != "@local":
## add synapse backup script
backup_sh_path = files_path +"borgbackup.sh"
exi = os.path.exists(backup_sh_path)
if exi == True:
files.put(
name="add synapse backup script",
src=backup_sh_path,
dest="/etc/daily.d/borgbackup.sh"
)
else:
print("file: \"" +backup_sh_path +"\" dosn't exists")
files.put(
name="add synapse backup script",
src=backup_sh_path,
dest="/etc/daily.d/borgbackup.sh"
)