Merge branch 'testing'

This commit is contained in:
Josué Tille
2019-09-07 13:09:48 +02:00
17 changed files with 120 additions and 18 deletions

View File

@ -26,6 +26,7 @@ dbpass=$(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)
port=$(ynh_app_setting_get --app $app --key web_port)
upstream_version=$(ynh_app_setting_get $app upstream_version)
#=================================================
# STANDARD MODIFICATIONS
@ -50,7 +51,7 @@ config_nginx
config_gitea
# RELOAD services
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "systemd" -a restart
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "/var/log/$app/gitea.log" -a restart -t 10
sleep 1
# Store the checksum with the 'INTERNAL_TOKEN' value.

View File

@ -332,3 +332,39 @@ ynh_handle_app_migration () {
migration_process=1
fi
}
# Verify the checksum and backup the file if it's different
# This helper is primarily meant to allow to easily backup personalised/manually
# modified config files.
#
# $app should be defined when calling this helper
#
# usage: ynh_backup_if_checksum_is_different --file=file
# | arg: -f, --file - The file on which the checksum test will be perfomed.
# | ret: the name of a backup file, or nothing
#
# Requires YunoHost version 2.6.4 or higher.
ynh_backup_if_checksum_is_different () {
# Declare an array to define the options of this helper.
local legacy_args=f
declare -Ar args_array=( [f]=file= )
local file
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
local checksum_value=$(ynh_app_setting_get --app=$app --key=$checksum_setting_name)
# backup_file_checksum isn't declare as local, so it can be reuse by ynh_store_file_checksum
backup_file_checksum=""
if [ -n "$checksum_value" ]
then # Proceed only if a value was stored into the app settings
if [ -e $file ] && ! echo "$checksum_value $file" | sudo md5sum -c --status
then # If the checksum is now different
backup_file_checksum="/home/yunohost.conf/backup/$file.backup.$(date '+%Y%m%d.%H%M%S')"
sudo mkdir -p "$(dirname "$backup_file_checksum")"
sudo cp -a "$file" "$backup_file_checksum" # Backup the current file
ynh_print_warn "File $file has been manually modified since the installation or last upgrade. So it has been duplicated in $backup_file_checksum"
echo "$backup_file_checksum" # Return the name of the backup file
fi
fi
}

View File

@ -19,6 +19,7 @@ domain=$YNH_APP_ARG_DOMAIN
path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
upstream_version=$(ynh_app_upstream_version)
# Register (book) web path
ynh_webpath_register --app $app --domain $domain --path_url $path_url
@ -98,6 +99,9 @@ ynh_replace_string "__ADMIN__" "$admin" ../conf/login_source.sql
ynh_replace_string "__APP__" "$app" ../conf/login_source.sql
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ../conf/login_source.sql
# SETUP FAIL2BAN
ynh_add_fail2ban_config --logpath "/var/log/$app/gitea.log" --failregex ".*Failed authentication attempt for .* from <HOST>" --max_retry 5
#=================================================
# GENERIC FINALIZATION
#=================================================
@ -106,7 +110,7 @@ ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ../conf/login_source.sql
set_access_settings
# Add gitea to YunoHost's monitored services
yunohost service add "$app" --log "/var/log/$app/$app.log"
yunohost service add "$app" --log "/var/log/$app/gitea.log"
# Configure logrotate
ynh_use_logrotate "/var/log/$app"
@ -115,7 +119,7 @@ ynh_use_logrotate "/var/log/$app"
ynh_app_setting_set --app $app --key upstream_version --value $(ynh_app_upstream_version)
# Reload services
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "systemd"
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "/var/log/$app/gitea.log" -t 10
sleep 1
# Store the checksum with the 'INTERNAL_TOKEN' value.

View File

@ -45,4 +45,7 @@ ynh_remove_systemd_config
# Remove monitor
yunohost service remove "$app"
# Remove fail2ban config
ynh_remove_fail2ban_config
true # Do not fail if remove after install error

View File

@ -20,6 +20,7 @@ path_url=$(ynh_app_setting_get --app $app --key path)
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
admin=$(ynh_app_setting_get --app $app --key adminusername)
port=$(ynh_app_setting_get --app $app --key web_port)
upstream_version=$(ynh_app_setting_get $app upstream_version)
# Check domain/path availability with app helper
ynh_webpath_available $domain $path_url || ynh_die --message "$domain is not available as domain, please use an other domain."
@ -54,6 +55,9 @@ ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
systemctl daemon-reload
systemctl enable "$app".service
# SETUP FAIL2BAN
ynh_add_fail2ban_config --logpath "/var/log/$app/gitea.log" --failregex ".*Failed authentication attempt for .* from <HOST>" --max_retry 5
#=================================================
# GENERIC FINALIZATION
#=================================================
@ -65,9 +69,9 @@ set_permission
ynh_use_logrotate "/var/log/$app"
# Add gitea to YunoHost's monitored services
yunohost service add "$app" --log /var/log/"$app"/"$app".log
yunohost service add "$app" --log /var/log/"$app"/gitea.log
# Reload services
systemctl reload nginx.service
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "systemd"
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "/var/log/$app/gitea.log" -t 10
sleep 1

View File

@ -155,11 +155,18 @@ case $upstream_version in
ynh_setup_source $final_path source/${architecture}_1.7
restart_gitea
;&
"1.7."* )
ynh_setup_source $final_path source/${architecture}_1.8
restart_gitea
;&
esac
# Install gitea
# Install gitea source
ynh_setup_source $final_path source/$architecture
# SETUP FAIL2BAN
ynh_add_fail2ban_config --logpath "/var/log/$app/gitea.log" --failregex ".*Failed authentication attempt for .* from <HOST>" --max_retry 5
#=================================================
# GENERIC FINALIZATION
#=================================================
@ -174,7 +181,7 @@ ynh_app_setting_set --app $app --key upstream_version --value $(ynh_app_upstream
set_access_settings
# Reload services
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "systemd"
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "/var/log/$app/gitea.log" -t 10
sleep 1
# Store the checksum with the 'INTERNAL_TOKEN' value.