174 lines
4 KiB
Python
174 lines
4 KiB
Python
from pyinfra import host
|
|
from pyinfra.operations import apt, server, files
|
|
from pyinfra.facts.server import LinuxName
|
|
|
|
files_path = "files/www/"
|
|
|
|
## check on which Distribution the script is executed
|
|
if host.get_fact(LinuxName) == "Debian":
|
|
|
|
## update apt repositories
|
|
apt.update(
|
|
name="update apt repositories",
|
|
# _doas=True,
|
|
# _doas_user="pyinfra",
|
|
# _sudo=True,
|
|
# _sudo_user="pyinfra",
|
|
)
|
|
|
|
## get repository for php7.3 part-1
|
|
apt.packages(
|
|
name="get repository for php7.3 part-1",
|
|
packages=["lsb-release",
|
|
"apt-transport-https",
|
|
"ca-certificates",
|
|
"software-properties-common",
|
|
],
|
|
)
|
|
|
|
## create /etc/apt/source.list.d/
|
|
source_list_d_path = "/etc/apt/source.list.d/"
|
|
files.directory(
|
|
name="create /etc/apt/source.list.d/",
|
|
path=source_list_d_path,
|
|
)
|
|
|
|
## get repository for php7.3 part-2
|
|
server.shell(
|
|
name="get repository for php7.3 part-2",
|
|
commands=["wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg",
|
|
"sh -c 'echo \"deb https://packages.sury.org/php/ $(lsb_release -sc) main\" > /etc/apt/source.list.d/php.list'",
|
|
"apt update",
|
|
],
|
|
)
|
|
|
|
## insrall php7.3
|
|
apt.packages(
|
|
name="install php7.3 and php-fpm",
|
|
packages=["php7.3", "php-fpm"],
|
|
)
|
|
|
|
## install apache2 as replacenebt for httpd.service
|
|
apt.packages(
|
|
name="install apache2 as replacenebt for httpd.service",
|
|
packages=["apache2"],
|
|
)
|
|
|
|
# elif host.get_fact(LinuxName) == "":
|
|
else:
|
|
print("www deploy.py don't support: \"" + host.get_fact(LinuxName) + "\" yet")
|
|
exit("exit from www/deploy.py")
|
|
|
|
## start the php8.2-fpm.service service
|
|
#service_name = "php73_fpm"
|
|
service_name = "php8.2-fpm.service"
|
|
server.service(
|
|
name="enable and restart php8.2-fpm.service",
|
|
service=service_name,
|
|
enabled=True,
|
|
running=True,
|
|
)
|
|
|
|
# ? when: phpinstall.changed
|
|
|
|
## fetch element tarball
|
|
url = "https://github.com/vector-im/element-web/releases/download/v1.11.52/element-v1.11.52.tar.gz"
|
|
dest = "/tmp/element.tar.gz"
|
|
sha256_checksum = "1f309d7863f583fef7294aa34ae19413991fd82aebd4c5d8bc3ac72eab04f71a."
|
|
checksum_path = "files/www/element.sha256"
|
|
files.download(
|
|
name="fetch element tarball",
|
|
src=url,
|
|
dest=dest,
|
|
sha256sum=sha256_checksum,
|
|
)
|
|
|
|
## create /var/www/
|
|
files.directory(
|
|
name="create /var/www/",
|
|
path="/var/www/",
|
|
)
|
|
|
|
## extract element tarball
|
|
server.shell(
|
|
name="extract element tarball",
|
|
commands=["tar xzf /tmp/element.tar.gz -C /var/www/"],
|
|
)
|
|
|
|
## rm -rf /var/www/element
|
|
server.shell(
|
|
name="rm -rf /var/www/element",
|
|
commands=["rm -rf /var/www/element"],
|
|
)
|
|
|
|
## cp -r /var/www/element-v1.11.52 /var/www/element
|
|
## files.put() seams not to be compatible with directorys
|
|
element_vers = "element-v1.11.52/"
|
|
element_path = "/var/www/" +element_vers
|
|
server.shell(
|
|
name="cp -r " +element_path +" /var/www/element",
|
|
commands=["cp -r " +element_path +" /var/www/element"],
|
|
)
|
|
|
|
## copy element config.json
|
|
element_json_path = files_path +"config.json"
|
|
files.put(
|
|
name="copy element config.json",
|
|
src=element_json_path,
|
|
dest="/var/www/element/config.json",
|
|
)
|
|
|
|
## copy heizhaus.jpg
|
|
heizhaus_jpg_path = files_path +"heizhaus.jpg"
|
|
files.put(
|
|
name="copy heizhaus.jpg",
|
|
src=heizhaus_jpg_path,
|
|
dest="/var/www/element/heizhaus.jpg",
|
|
)
|
|
|
|
## heizhaus-logo.png
|
|
heizhaus_logo_path = files_path +"heizhaus-logo.png"
|
|
files.put(
|
|
name="heizhaus-logo.png",
|
|
src=heizhaus_logo_path,
|
|
dest="/var/www/element/heizhaus-logo.png",
|
|
)
|
|
|
|
## mkdir /var/www/matrix
|
|
files.directory(
|
|
name="mkdir /var/www/matrix",
|
|
path="/var/www/matrix",
|
|
)
|
|
|
|
## copy matrix/client
|
|
matrix_client_json_path = files_path +"matrix_client.json"
|
|
files.put(
|
|
name="copy matrix/client",
|
|
src=matrix_client_json_path,
|
|
dest="/var/www/matrix/client",
|
|
)
|
|
|
|
## copy matrix/server
|
|
matrix_server_json_path = files_path +"matrix_server.json"
|
|
files.put(
|
|
name="copy matrix/server",
|
|
src=matrix_server_json_path,
|
|
dest="/var/www/matrix/server",
|
|
)
|
|
|
|
## copy /etc/httpd.conf
|
|
httpd_conf_path = files_path +"httpd.conf"
|
|
files.put(
|
|
name="copy /etc/httpd.conf",
|
|
src=httpd_conf_path,
|
|
dest="/etc/httpd.conf",
|
|
)
|
|
|
|
## start apache2
|
|
service_name = "apache2"
|
|
server.service(
|
|
name="start apache2",
|
|
service=service_name,
|
|
running=True,
|
|
)
|