yunohost-gitea_ynh/scripts/install

83 lines
2.9 KiB
Plaintext
Raw Normal View History

2018-02-25 21:45:24 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2018-02-25 21:45:24 +01:00
source _common.sh
source /usr/share/yunohost/helpers
2018-02-25 21:45:24 +01:00
#=================================================
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Installing sources files and data directories..." --weight=10
2018-02-25 21:45:24 +01:00
ynh_setup_source --dest_dir="$install_dir"
chmod +x "$install_dir/gitea"
2020-12-07 17:04:52 +01:00
# create needed directories
_gitea_mkdirs
2018-02-25 21:45:24 +01:00
ynh_script_progression --message="Configuring application, step 1/2..."
2018-02-25 21:45:24 +01:00
_gitea_set_secrets
_gitea_add_config
_gitea_permissions_install_dir
2018-02-25 21:45:24 +01:00
#=================================================
# SYSTEM CONFIGURATION
2018-02-25 21:45:24 +01:00
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
2018-02-25 21:45:24 +01:00
# Create a dedicated NGINX config using the conf/nginx.conf template
ynh_add_nginx_config
2018-02-25 21:45:24 +01:00
# Create a dedicated systemd config
2018-04-30 15:56:19 +02:00
ynh_add_systemd_config
# Add gitea to YunoHost's monitored services
yunohost service add "$app" --log="/var/log/$app/gitea.log"
2018-05-10 16:31:54 +02:00
# Configure logrotate
ynh_use_logrotate --logfile "/var/log/$app"
2019-09-10 22:43:45 +02:00
# 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
2018-02-25 21:45:24 +01:00
#=================================================
# APP INITIAL CONFIGURATION
#=================================================
# ADD A CONFIGURATION
#=================================================
2018-02-25 21:45:24 +01:00
2019-09-10 22:43:45 +02:00
ynh_script_progression --message="Configuring application, step 2/2..."
# Start gitea for building mysql tables
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/gitea.log" --line_match="Starting new Web server: tcp:127.0.0.1:"
2018-02-25 21:45:24 +01:00
# Add ldap config
2019-09-10 21:26:06 +02:00
ynh_replace_string --match_string "__APP__" --replace_string "$app" --target_file ../conf/login_source.sql
ynh_mysql_connect_as "$db_user" "$db_pwd" "$db_name" < ../conf/login_source.sql
2018-02-25 21:45:24 +01:00
# Stop the service to restart it just afterwards
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/gitea.log"
2019-02-03 15:05:38 +01:00
2018-02-25 21:45:24 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
2019-09-10 22:43:45 +02:00
ynh_script_progression --message="Starting gitea services..." --weight=3
2022-07-24 13:45:53 +02:00
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/gitea.log" --line_match="Starting new Web server: tcp:127.0.0.1:"
2019-10-27 14:54:35 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2019-10-27 14:54:35 +01:00
ynh_script_progression --message="Installation of $app completed" --last