mirror of
https://framagit.org/YunoHost-Apps/gitea_ynh.git
synced 2024-11-23 11:31:35 +01:00
96 lines
3.2 KiB
Bash
96 lines
3.2 KiB
Bash
#!/bin/bash
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
ynh_app_setting_set --key=protect_against_basic_auth_spoofing --value=false
|
|
|
|
#=================================================
|
|
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
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')"
|
|
ynh_print_warn "Data directory was not empty. Data was moved to $old_data_dir_path"
|
|
mkdir -p "$old_data_dir_path"
|
|
mv -t "$old_data_dir_path" "$data_dir"/*
|
|
fi
|
|
|
|
# base directories
|
|
mkdir -p "$install_dir/data"
|
|
mkdir -p "$install_dir/custom/conf"
|
|
mkdir -p "/var/log/$app"
|
|
|
|
mkdir -p "$data_dir/.ssh"
|
|
mkdir -p "$data_dir/repositories"
|
|
mkdir -p "$data_dir/data/avatars"
|
|
mkdir -p "$data_dir/data/attachments"
|
|
|
|
ynh_script_progression 'Installing sources files and data directories...'
|
|
|
|
# Setup source
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
_set_permissions
|
|
|
|
ynh_script_progression "Configuring application, step 1/2..."
|
|
|
|
set_settings_default
|
|
|
|
ynh_config_add --template='app.ini' --destination="$install_dir/custom/conf/app.ini"
|
|
|
|
#=================================================
|
|
# SYSTEM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression "Adding system configurations related to $app..."
|
|
|
|
# Create a dedicated NGINX config using the conf/nginx.conf template
|
|
ynh_config_add_nginx
|
|
|
|
# Create a dedicated 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_config_add_logrotate "/var/log/$app"
|
|
|
|
# Create a dedicated Fail2Ban config
|
|
ynh_config_add_fail2ban --logpath="/var/log/$app/gitea.log" --failregex='.*Failed authentication attempt for .* from <HOST>'
|
|
|
|
#=================================================
|
|
# APP INITIAL CONFIGURATION
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
|
|
ynh_script_progression 'Configuring application, step 2/2...'
|
|
_set_permissions
|
|
|
|
# Start gitea for building mysql tables
|
|
ynh_systemctl --service="$app" --action=start --log_path="/var/log/$app/gitea.log" --wait_until="$systemd_match_start_line"
|
|
|
|
# Add ldap config
|
|
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_systemctl --service="$app" --action='stop' --log_path="/var/log/$app/gitea.log"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression 'Starting gitea services...'
|
|
|
|
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 "Installation of $app completed"
|