mirror of
https://github.com/YunoHost-Apps/dendrite_ynh.git
synced 2024-09-03 18:25:58 +02:00
Fix Go installation for multiple architectures
This commit is contained in:
parent
c710b4c9b4
commit
319ffd33a5
6 changed files with 53 additions and 51 deletions
|
@ -7,7 +7,10 @@ Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/
|
WorkingDirectory=__FINALPATH__/
|
||||||
ExecStart=__FINALPATH__/./bin/dendrite-monolith-server --tls-cert=/etc/yunohost/certs/__DOMAIN__/crt.pem --tls-key=/etc/yunohost/certs/__DOMAIN__/key.pem --config=dendrite.yaml --http-bind-address=:__PORT__ --https-bind-address=:__TLS_PORT__ >> /var/log/__APP__/__APP__.log 2>&1
|
Environment="__YNH_GO_LOAD_PATH__"
|
||||||
|
ExecStart=__FINALPATH__/bin/dendrite-monolith-server --tls-cert=/etc/yunohost/certs/__DOMAIN__/crt.pem --tls-key=/etc/yunohost/certs/__DOMAIN__/key.pem --config=dendrite.yaml --http-bind-address=:__PORT__ --https-bind-address=:__TLS_PORT__
|
||||||
|
StandardOutput=append:/var/log/__APP__/__APP__.log
|
||||||
|
StandardError=inherit
|
||||||
|
|
||||||
# Sandboxing options to harden security
|
# Sandboxing options to harden security
|
||||||
# Depending on specificities of your service/app, you may need to tweak these
|
# Depending on specificities of your service/app, you may need to tweak these
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
pkg_dependencies="postgresql postgresql-contrib"
|
pkg_dependencies="postgresql postgresql-contrib"
|
||||||
|
|
||||||
|
go_version="1.16"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
source ynh_install_go
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -67,6 +68,15 @@ ynh_exec_warn_less yunohost firewall allow TCP $tls_port
|
||||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||||
ynh_app_setting_set --app=$app --key=tls_port --value=$tls_port
|
ynh_app_setting_set --app=$app --key=tls_port --value=$tls_port
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||||
|
|
||||||
|
# Create a system user
|
||||||
|
# It needs to be created before using the ynh_install_go helper
|
||||||
|
ynh_system_user_create --username=$app --use_shell --groups="ssl-cert"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -74,15 +84,8 @@ ynh_script_progression --message="Installing dependencies..." --weight=3
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
# Install Go if needed
|
# Install Go
|
||||||
if ! command -v /usr/local/go/bin/go &> /dev/null
|
ynh_exec_warn_less ynh_install_go --go_version=$go_version
|
||||||
then
|
|
||||||
ynh_script_progression --message="Installing Go dependency... (this will take some time)" --weight=3
|
|
||||||
ynh_setup_source --source_id="go" --dest_dir="/usr/local/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
export PATH=$PATH:/usr/local/go/bin
|
|
||||||
env_path=$PATH
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A POSTGRESQL DATABASE
|
# CREATE A POSTGRESQL DATABASE
|
||||||
|
@ -94,8 +97,8 @@ ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
ynh_psql_setup_db --db_user=$db_name --db_name=$db_name
|
ynh_psql_setup_db --db_user=$db_name --db_name=$db_name
|
||||||
|
|
||||||
ynh_psql_execute_as_root \
|
ynh_psql_execute_as_root --sql="DROP DATABASE $db_name"
|
||||||
--sql="CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;"
|
ynh_psql_execute_as_root --sql="CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -114,26 +117,21 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
|
||||||
|
|
||||||
# Create a system user
|
|
||||||
ynh_system_user_create --username=$app
|
|
||||||
adduser $app ssl-cert
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILDING SOURCES AND SETTING UP THE SERVER
|
# BUILDING SOURCES AND SETTING UP THE SERVER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_use_go
|
||||||
|
|
||||||
|
mkdir -p "$final_path/bin"
|
||||||
|
chown -R $app:root $final_path
|
||||||
|
|
||||||
pushd "$final_path"
|
pushd "$final_path"
|
||||||
ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6
|
ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6
|
||||||
# Build the sources
|
# Build the sources
|
||||||
mkdir ./bin
|
ynh_exec_warn_less ynh_exec_as $app $ynh_go_load_path HOME=$final_path ./build.sh
|
||||||
ynh_exec_warn_less ./build.sh
|
|
||||||
ynh_script_progression --message="Generating the keys..." --weight=1
|
ynh_script_progression --message="Generating the keys..." --weight=1
|
||||||
# Generate a Matrix signing key for federation
|
# Generate a Matrix signing key for federation
|
||||||
./bin/generate-keys --private-key matrix_key.pem
|
./bin/generate-keys --private-key matrix_key.pem
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
source ynh_install_go
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -58,6 +59,9 @@ ynh_script_progression --message="Removing dependencies..." --weight=3
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
|
|
||||||
|
# Remove Go
|
||||||
|
ynh_remove_go
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
|
source ../settings/scripts/ynh_install_go
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -66,7 +67,7 @@ ynh_restore_file --origin_path="$final_path"
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app
|
ynh_system_user_create --username=$app --use_shell --groups="ssl-cert"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
|
@ -87,15 +88,8 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=3
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
# Install Go if needed
|
# Install Go
|
||||||
if ! command -v /usr/local/go/bin/go &> /dev/null
|
ynh_install_go --go_version=$go_version
|
||||||
then
|
|
||||||
ynh_script_progression --message="Installing Go dependency... (this will take some time)" --weight=3
|
|
||||||
ynh_setup_source --source_id="go" --dest_dir="/usr/local/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
export PATH=$PATH:/usr/local/go/bin
|
|
||||||
env_path=$PATH
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PSQL DATABASE
|
# RESTORE THE PSQL DATABASE
|
||||||
|
@ -119,6 +113,7 @@ systemctl enable $app.service --quiet
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||||
|
|
||||||
|
ynh_use_go
|
||||||
yunohost service add $app --description="Dendrite Matrix homeserver" --log="/var/log/$app/Monolith.log" --needs_exposed_ports "$tls_port"
|
yunohost service add $app --description="Dendrite Matrix homeserver" --log="/var/log/$app/Monolith.log" --needs_exposed_ports "$tls_port"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
source ynh_install_go
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -81,6 +82,15 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated user (if not existing)
|
||||||
|
# It needs to be created before using the ynh_install_go helper
|
||||||
|
ynh_system_user_create --username=$app --use_shell --groups="ssl-cert"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE DEPENDENCIES
|
# UPGRADE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -88,23 +98,8 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
|
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
# TODO: check Go version and upgrade if needed
|
# Install Go
|
||||||
if ! command -v /usr/local/go/bin/go &> /dev/null
|
ynh_exec_warn_less ynh_install_go --go_version=$go_version
|
||||||
then
|
|
||||||
ynh_script_progression --message="Installing Go dependency... (this will take some time)" --weight=3
|
|
||||||
ynh_setup_source --source_id="go" --dest_dir="/usr/local/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
export PATH=$PATH:/usr/local/go/bin
|
|
||||||
env_path=$PATH
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
|
||||||
ynh_system_user_create --username=$app
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
|
@ -112,10 +107,15 @@ ynh_system_user_create --username=$app
|
||||||
# BUILDING SOURCES AND SETTING UP THE SERVER
|
# BUILDING SOURCES AND SETTING UP THE SERVER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_use_go
|
||||||
|
|
||||||
|
mkdir -p "$final_path/bin"
|
||||||
|
chown -R $app:root $final_path
|
||||||
|
|
||||||
pushd "$final_path"
|
pushd "$final_path"
|
||||||
ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6
|
ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6
|
||||||
# Build the sources
|
# Build the sources
|
||||||
ynh_exec_warn_less ./build.sh
|
ynh_exec_warn_less ynh_exec_as $app $ynh_go_load_path HOME=$final_path ./build.sh
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue