From 5026d1c591f459959c555825801108f2a39927d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 23 Jul 2022 09:31:49 +0200 Subject: [PATCH] Fix --- conf/nginx.conf | 11 +++++++---- conf/systemd.service | 19 +++++-------------- scripts/backup | 16 +++++++++++----- scripts/change_url | 37 ++++++++++++++++++++----------------- 4 files changed, 43 insertions(+), 40 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index acafbce..54f47f1 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,10 +1,13 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - proxy_pass http://localhost:__PORT__/; - proxy_set_header Host $host; - proxy_buffering off; - client_max_body_size 200M; + + proxy_pass http://127.0.0.1:__PORT__/; + proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + client_max_body_size 200M; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/conf/systemd.service b/conf/systemd.service index 3dcae38..4889a96 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,24 +1,15 @@ [Unit] -Description=Gitea -After=syslog.target -After=network.target -After=mysql.service -After=slapd.service +Description=Gitea: Git Service +After=syslog.target network.target mysql.service slapd.service [Service] -# Modify these two values and uncomment them if you have -# repos with lots of files and get an HTTP error 500 because -# of that -### -#LimitMEMLOCK=infinity -#LimitNOFILE=65535 Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=/home/yunohost.app/__APP__ -ExecStart=/opt/__APP__/gitea web +WorkingDirectory=__DATADIR__/ +ExecStart=__FINALPATH__/gitea web -p __PORT__ Restart=always -Environment=USER=__APP__ HOME=/home/yunohost.app/__APP__ +Environment=USER=__APP__ HOME=__DATADIR__/ # Sandboxing options to harden security # Depending on specificities of your service/app, you may need to tweak these diff --git a/scripts/backup b/scripts/backup index 795fdc9..eac55dc 100644 --- a/scripts/backup +++ b/scripts/backup @@ -3,12 +3,10 @@ #================================================= # GENERIC START #================================================= - -# Load common variables and helpers -source ../settings/scripts/experimental_helper.sh -source ../settings/scripts/_common.sh - # IMPORT GENERIC HELPERS +#================================================= + +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -69,6 +67,14 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= + +ynh_backup --src_path="/etc/logrotate.d/$app" + #================================================= # BACKUP VARIOUS FILES #================================================= diff --git a/scripts/change_url b/scripts/change_url index 98eb059..9803d38 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,19 +1,14 @@ #!/bin/bash #================================================= -# GENERIC START +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS #================================================= -# Import common cmd -source ./experimental_helper.sh -source ./_common.sh - -# IMPORT GENERIC HELPERS +source _common.sh source /usr/share/yunohost/helpers -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS #================================================= @@ -31,12 +26,17 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Loading installation settings..." --weight=1 +# Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get --app=$app --key=port) +admin=$(ynh_app_setting_get --app=$app --key=admin) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -admin=$(ynh_app_setting_get --app=$app --key=adminusername) -key=$(ynh_app_setting_get --app=$app --key=secret_key) +key=$(ynh_app_setting_get --app=$app --key=key) lfs_key=$(ynh_app_setting_get --app=$app --key=lfs_key) -port=$(ynh_app_setting_get --app=$app --key=web_port) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) +path_url=$(ynh_app_setting_get --app=$app --key=path) upstream_version=$(ynh_app_setting_get --app=$app --key=upstream_version) #================================================= @@ -113,13 +113,16 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= -ynh_script_progression --message="Updating gitea configuration..." +ynh_script_progression --message="Adding a configuration file..." --weight=1 -config_gitea +domain=$new_domain +path_url=$new_path +ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+") -# Store the checksum with the 'INTERNAL_TOKEN' value. -# Should be removed when the issue https://github.com/go-gitea/gitea/issues/3246 is fixed -ynh_store_file_checksum --file "$final_path/custom/conf/app.ini" +ynh_exec_warn_less ynh_add_config --template="../conf/app.ini" --destination="$final_path/custom/conf/app.ini" + +chmod 640 "$final_path/custom/conf/app.ini" +chown $app:$app "$final_path/custom/conf/app.ini" #================================================= # GENERIC FINALISATION