mirror of
https://framagit.org/YunoHost-Apps/gitea_ynh.git
synced 2025-09-02 18:18:31 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:

committed by
Josué Tille

parent
9e748220af
commit
a9647ffbf1
@ -1,11 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
@ -15,7 +9,7 @@ source /usr/share/yunohost/helpers
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message='Creating base directory...'
|
||||
ynh_script_progression 'Creating base directory...'
|
||||
|
||||
if [ -n "$(ls -A "$data_dir")" ]; then
|
||||
old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')"
|
||||
@ -34,45 +28,45 @@ mkdir -p "$data_dir/repositories"
|
||||
mkdir -p "$data_dir/data/avatars"
|
||||
mkdir -p "$data_dir/data/attachments"
|
||||
|
||||
ynh_script_progression --message='Installing sources files and data directories...' --weight=10
|
||||
ynh_script_progression 'Installing sources files and data directories...'
|
||||
|
||||
# Setup source
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
_set_permissions
|
||||
|
||||
ynh_script_progression --message="Configuring application, step 1/2..."
|
||||
ynh_script_progression "Configuring application, step 1/2..."
|
||||
|
||||
internal_token="$(ynh_exec_as "$app" "$install_dir/gitea" generate secret INTERNAL_TOKEN)"
|
||||
secret_key="$(ynh_exec_as "$app" "$install_dir/gitea" generate secret SECRET_KEY)"
|
||||
lfs_jwt_secret="$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET)"
|
||||
jwt_secret="$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET)"
|
||||
internal_token="$(ynh_exec_as_app "$install_dir/gitea" generate secret INTERNAL_TOKEN)"
|
||||
secret_key="$(ynh_exec_as_app "$install_dir/gitea" generate secret SECRET_KEY)"
|
||||
lfs_jwt_secret="$(ynh_exec_as_app "$install_dir/gitea" generate secret JWT_SECRET)"
|
||||
jwt_secret="$(ynh_exec_as_app "$install_dir/gitea" generate secret JWT_SECRET)"
|
||||
|
||||
ynh_app_setting_set --app="$app" --key=internal_token --value="$internal_token"
|
||||
ynh_app_setting_set --app="$app" --key=secret_key --value="$secret_key"
|
||||
ynh_app_setting_set --app="$app" --key=lfs_jwt_secret --value="$lfs_jwt_secret"
|
||||
ynh_app_setting_set --app="$app" --key=jwt_secret --value="$jwt_secret"
|
||||
ynh_app_setting_set --key=internal_token --value="$internal_token"
|
||||
ynh_app_setting_set --key=secret_key --value="$secret_key"
|
||||
ynh_app_setting_set --key=lfs_jwt_secret --value="$lfs_jwt_secret"
|
||||
ynh_app_setting_set --key=jwt_secret --value="$jwt_secret"
|
||||
|
||||
ynh_add_config --template='app.ini' --destination="$install_dir/custom/conf/app.ini"
|
||||
ynh_config_add --template='app.ini' --destination="$install_dir/custom/conf/app.ini"
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Adding system configurations related to $app..."
|
||||
|
||||
# Create a dedicated NGINX config using the conf/nginx.conf template
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
ynh_config_add_systemd
|
||||
|
||||
# Add gitea to YunoHost's monitored services
|
||||
yunohost service add "$app" --log="/var/log/$app/gitea.log"
|
||||
|
||||
# Configure logrotate
|
||||
ynh_use_logrotate --logfile="/var/log/$app"
|
||||
ynh_config_add_logrotate "/var/log/$app"
|
||||
|
||||
# Create a dedicated Fail2Ban config
|
||||
ynh_add_fail2ban_config --logpath="/var/log/$app/gitea.log" --failregex='.*Failed authentication attempt for .* from <HOST>' --max_retry=5
|
||||
ynh_config_add_fail2ban --logpath="/var/log/$app/gitea.log" --failregex='.*Failed authentication attempt for .* from <HOST>'
|
||||
|
||||
#=================================================
|
||||
# APP INITIAL CONFIGURATION
|
||||
@ -80,30 +74,28 @@ ynh_add_fail2ban_config --logpath="/var/log/$app/gitea.log" --failregex='.*Faile
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message='Configuring application, step 2/2...'
|
||||
ynh_script_progression 'Configuring application, step 2/2...'
|
||||
_set_permissions
|
||||
|
||||
# Start gitea for building mysql tables
|
||||
ynh_systemd_action --service_name="$app" --action=start --log_path="/var/log/$app/gitea.log" --line_match="$systemd_match_start_line"
|
||||
ynh_systemctl --service="$app" --action=start --log_path="/var/log/$app/gitea.log" --wait_until="$systemd_match_start_line"
|
||||
|
||||
# Add ldap config
|
||||
ynh_replace_string --match_string=__APP__ --replace_string="$app" --target_file=./login_source.sql
|
||||
ynh_replace_string --match_string=__GROUP_TEAM_MAP__ --replace_string='""' --target_file=./login_source.sql
|
||||
ynh_mysql_connect_as "$db_user" "$db_pwd" "$db_name" < ./login_source.sql
|
||||
ynh_replace --match=__APP__ --replace="$app" --file=./login_source.sql
|
||||
ynh_replace --match=__GROUP_TEAM_MAP__ --replace='""' --file=./login_source.sql
|
||||
ynh_mysql_db_shell < ./login_source.sql
|
||||
|
||||
# Stop the service to restart it just afterwards
|
||||
ynh_systemd_action --service_name="$app" --action='stop' --log_path="/var/log/$app/gitea.log"
|
||||
ynh_systemctl --service="$app" --action='stop' --log_path="/var/log/$app/gitea.log"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message='Starting gitea services...' --weight=3
|
||||
ynh_script_progression 'Starting gitea services...'
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action=start --log_path="/var/log/$app/gitea.log" --line_match="$systemd_match_start_line"
|
||||
ynh_systemctl --service="$app" --action=start --log_path="/var/log/$app/gitea.log" --wait_until="$systemd_match_start_line"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
Reference in New Issue
Block a user