Add ynh_script_progression somewhere

This commit is contained in:
Josué Tille
2019-09-10 22:43:45 +02:00
parent 3a6e4b46d7
commit 3a66c7b87b
6 changed files with 71 additions and 23 deletions

View File

@ -14,6 +14,8 @@ ynh_abort_if_errors
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
ynh_script_progression --message="Loading settings..."
# Retrieve old app settings
domain=$(ynh_app_setting_get --app $app --key domain)
path_url=$(ynh_app_setting_get --app $app --key path)
@ -37,17 +39,15 @@ test ! -e "$final_path" || ynh_die --message "This path already contains a folde
#=================================================
# Add users
# We can't use the official helper (for now) because we need to set the shell for the login
test getent passwd "$app" &>/dev/null || \
useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \
ynh_die --message "Unable to create $app system account"
# Should be replaced by this when getops is available in the helper ynh_system_user_create (probably in Yunohost 3.5)
# ynh_system_user_create --username= $app --home_dir=/opt/yunohost/$app --use_shell
ynh_script_progression --message="Configuring system user..."
ynh_system_user_create --username= $app --home_dir=/opt/yunohost/$app --use_shell
# Restore all files
ynh_script_progression --message="Restoring files..." --weight=10
ynh_restore
# Create and restore the database
ynh_script_progression --message="Restoring database..." --weight=3
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
@ -56,6 +56,7 @@ systemctl daemon-reload
systemctl enable "$app".service
# SETUP FAIL2BAN
ynh_script_progression --message="Configuring fail2ban..."
ynh_add_fail2ban_config --logpath "/var/log/$app/gitea.log" --failregex ".*Failed authentication attempt for .* from <HOST>" --max_retry 5
#=================================================
@ -63,15 +64,19 @@ ynh_add_fail2ban_config --logpath "/var/log/$app/gitea.log" --failregex ".*Faile
#=================================================
# Set permissions
ynh_script_progression --message="Protecting directory..."
set_permission
# Configure logrotate
ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate "/var/log/$app"
# Add gitea to YunoHost's monitored services
ynh_script_progression --message="Register gitea service..."
yunohost service add "$app" --log /var/log/"$app"/gitea.log
# Reload services
ynh_script_progression --message="Reloading services..."
systemctl reload nginx.service
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "/var/log/$app/gitea.log" -t 10
sleep 1