mirror of
https://github.com/YunoHost-Apps/forgejo_ynh.git
synced 2024-09-03 18:36:26 +02:00
cleaning
This commit is contained in:
parent
8573359c39
commit
ef480e3c13
4 changed files with 26 additions and 106 deletions
|
@ -1,18 +1,16 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC START
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Load common variables and helpers
|
source _common.sh
|
||||||
source ./_common.sh
|
|
||||||
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Create install and data subdirs
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression "Setting up source files..."
|
||||||
|
|
||||||
ynh_setup_source --dest_dir="$install_dir"
|
ynh_setup_source --dest_dir="$install_dir"
|
||||||
|
|
||||||
|
@ -38,9 +36,9 @@ ynh_app_setting_set --key=internal_token --value="$internal_token"
|
||||||
ynh_app_setting_set --key=oauth2_jwt_secret --value="$oauth2_jwt_secret"
|
ynh_app_setting_set --key=oauth2_jwt_secret --value="$oauth2_jwt_secret"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# APP INITIAL CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression "Adding $app's configuration..."
|
ynh_script_progression "Adding $app's configuration files..."
|
||||||
|
|
||||||
ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+")
|
ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+")
|
||||||
ynh_config_add --template="app.ini" --destination="$install_dir/custom/conf/app.ini"
|
ynh_config_add --template="app.ini" --destination="$install_dir/custom/conf/app.ini"
|
||||||
|
@ -49,34 +47,20 @@ chmod 640 "$install_dir/custom/conf/app.ini"
|
||||||
chown "$app:$app" "$install_dir/custom/conf/app.ini"
|
chown "$app:$app" "$install_dir/custom/conf/app.ini"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression "Upgrading systemd configuration..."
|
ynh_script_progression "Adding system configurations related to $app..."
|
||||||
|
|
||||||
ynh_config_add_systemd
|
ynh_config_add_systemd
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression "Upgrading NGINX web server configuration..."
|
|
||||||
|
|
||||||
ynh_config_add_nginx
|
ynh_config_add_nginx
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP LOGROTATE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression "Configuring log rotation..."
|
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
|
||||||
ynh_config_add_logrotate "/var/log/$app"
|
ynh_config_add_logrotate "/var/log/$app"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression "Integrating service in YunoHost..."
|
|
||||||
|
|
||||||
yunohost service add "$app" --description="Forgejo" --log="/var/log/$app/forgejo.log"
|
yunohost service add "$app" --description="Forgejo" --log="/var/log/$app/forgejo.log"
|
||||||
|
|
||||||
|
ynh_config_add_fail2ban --logpath "/var/log/$app/forgejo.log" --failregex ".*Failed authentication attempt for .* from <HOST>"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -85,13 +69,6 @@ ynh_script_progression "Starting $app's systemd service..."
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemctl --service="$app" --action="start" --log_path="/var/log/$app/forgejo.log" --wait_until="Starting new Web server: tcp:127.0.0.1:"
|
ynh_systemctl --service="$app" --action="start" --log_path="/var/log/$app/forgejo.log" --wait_until="Starting new Web server: tcp:127.0.0.1:"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP FAIL2BAN
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression "Configuring Fail2Ban..."
|
|
||||||
|
|
||||||
ynh_config_add_fail2ban --logpath "/var/log/$app/forgejo.log" --failregex ".*Failed authentication attempt for .* from <HOST>" --max_retry 5
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LDAP CONFIGURATION
|
# LDAP CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -4,32 +4,22 @@ source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# REMOVE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
|
||||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression "Removing system configurations related to $app..."
|
||||||
|
|
||||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
|
||||||
if ynh_hide_warnings yunohost service status "$app" >/dev/null
|
if ynh_hide_warnings yunohost service status "$app" >/dev/null
|
||||||
then
|
then
|
||||||
ynh_script_progression "Removing $app service integration..."
|
ynh_script_progression "Removing $app service integration..."
|
||||||
yunohost service remove "$app"
|
yunohost service remove "$app"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
|
||||||
ynh_script_progression "Removing systemd configuration..."
|
|
||||||
ynh_config_remove_systemd
|
ynh_config_remove_systemd
|
||||||
|
|
||||||
# Remove the app-specific logrotate config
|
|
||||||
ynh_script_progression "Removing logrotate configuration..."
|
|
||||||
ynh_config_remove_logrotate
|
ynh_config_remove_logrotate
|
||||||
|
|
||||||
# Remove the dedicated NGINX config
|
|
||||||
ynh_script_progression "Removing NGINX web server configuration..."
|
|
||||||
ynh_config_remove_nginx
|
ynh_config_remove_nginx
|
||||||
|
|
||||||
# Remove the dedicated Fail2Ban config
|
|
||||||
ynh_script_progression "Removing Fail2Ban configuration..."
|
|
||||||
ynh_config_remove_fail2ban
|
ynh_config_remove_fail2ban
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -3,15 +3,6 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD RESTORATION STEPS
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression "Restoring the NGINX configuration..."
|
|
||||||
|
|
||||||
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -23,18 +14,11 @@ ynh_restore "$install_dir"
|
||||||
# RESTORE THE DATA DIRECTORY
|
# RESTORE THE DATA DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression "Restoring the data directory..."
|
ynh_script_progression "Restoring the data directory..."
|
||||||
|
|
||||||
ynh_restore "$data_dir"
|
ynh_restore "$data_dir"
|
||||||
|
|
||||||
chown -R "$app:$app" "$data_dir"
|
chown -R "$app:$app" "$data_dir"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE FAIL2BAN CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression "Restoring the Fail2Ban configuration..."
|
|
||||||
|
|
||||||
ynh_restore "/etc/fail2ban/jail.d/$app.conf"
|
|
||||||
ynh_restore "/etc/fail2ban/filter.d/$app.conf"
|
|
||||||
ynh_systemctl --action=restart --service=fail2ban
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE DATABASE
|
# RESTORE THE DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -43,39 +27,30 @@ ynh_script_progression "Restoring the database..."
|
||||||
ynh_psql_db_shell < "./db.sql"
|
ynh_psql_db_shell < "./db.sql"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression "Restoring $app's systemd service..."
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||||
|
|
||||||
|
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
ynh_restore "/etc/systemd/system/$app.service"
|
ynh_restore "/etc/systemd/system/$app.service"
|
||||||
systemctl enable "$app.service" --quiet
|
systemctl enable "$app.service" --quiet
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression "Restoring the logrotate configuration..."
|
|
||||||
|
|
||||||
ynh_restore "/etc/logrotate.d/$app"
|
ynh_restore "/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression "Integrating service in YunoHost..."
|
|
||||||
|
|
||||||
yunohost service add "$app" --description="Forgejo" --log="/var/log/$app/forgejo.log"
|
yunohost service add "$app" --description="Forgejo" --log="/var/log/$app/forgejo.log"
|
||||||
|
|
||||||
|
ynh_restore "/etc/fail2ban/jail.d/$app.conf"
|
||||||
|
ynh_restore "/etc/fail2ban/filter.d/$app.conf"
|
||||||
|
ynh_systemctl --action=restart --service=fail2ban
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression "Starting $app's systemd service..."
|
ynh_script_progression "Reloading NGINX web server and $app's service..."
|
||||||
|
|
||||||
ynh_systemctl --service="$app" --action="start" --log_path="/var/log/$app/forgejo.log" --wait_until="Starting new Web server: tcp:127.0.0.1:"
|
ynh_systemctl --service="$app" --action="start" --log_path="/var/log/$app/forgejo.log" --wait_until="Starting new Web server: tcp:127.0.0.1:"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression "Reloading NGINX web server..."
|
|
||||||
|
|
||||||
ynh_systemctl --service=nginx --action=reload
|
ynh_systemctl --service=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -83,34 +83,19 @@ ynh_script_progression "Upgrading systemd configuration..."
|
||||||
|
|
||||||
ynh_config_add_systemd
|
ynh_config_add_systemd
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression "Upgrading NGINX web server configuration..."
|
|
||||||
|
|
||||||
ynh_config_add_nginx
|
ynh_config_add_nginx
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP LOGROTATE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression "Configuring log rotation..."
|
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
|
||||||
ynh_config_add_logrotate "/var/log/$app"
|
ynh_config_add_logrotate "/var/log/$app"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression "Integrating service in YunoHost..."
|
|
||||||
|
|
||||||
yunohost service add "$app" --description="Forgejo" --log="/var/log/$app/forgejo.log"
|
yunohost service add "$app" --description="Forgejo" --log="/var/log/$app/forgejo.log"
|
||||||
|
|
||||||
|
ynh_config_add_fail2ban --logpath "/var/log/$app/forgejo.log" --failregex ".*Failed authentication attempt for .* from <HOST>"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression "Starting $app's systemd service..."
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
# Start a systemd service
|
|
||||||
ynh_systemctl --service="$app" --action="start" --log_path="/var/log/$app/forgejo.log" --wait_until="Starting new Web server: tcp:127.0.0.1:"
|
ynh_systemctl --service="$app" --action="start" --log_path="/var/log/$app/forgejo.log" --wait_until="Starting new Web server: tcp:127.0.0.1:"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -124,13 +109,6 @@ set_users_login_source
|
||||||
|
|
||||||
synchronize_users
|
synchronize_users
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP FAIL2BAN
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression "Configuring Fail2Ban..."
|
|
||||||
|
|
||||||
ynh_config_add_fail2ban --logpath "/var/log/$app/forgejo.log" --failregex ".*Failed authentication attempt for .* from <HOST>" --max_retry 5
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue