yunohost-gitea_ynh/scripts/install

94 lines
3.1 KiB
Plaintext
Raw Normal View History

2018-02-25 21:45:24 +01:00
#!/bin/bash
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
#=================================================
2018-02-25 21:45:24 +01:00
ynh_script_progression 'Creating base directory...'
2018-02-25 21:45:24 +01:00
2024-04-27 00:07:37 +02:00
if [ -n "$(ls -A "$data_dir")" ]; then
2023-11-29 10:58:11 +01:00
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"
2024-04-27 00:07:37 +02:00
mkdir -p "$old_data_dir_path"
2023-11-29 10:58:11 +01:00
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"
2020-12-07 17:04:52 +01:00
2023-11-29 10:58:11 +01:00
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...'
2023-11-29 10:58:11 +01:00
# Setup source
ynh_setup_source --dest_dir="$install_dir"
_set_permissions
2018-02-25 21:45:24 +01:00
ynh_script_progression "Configuring application, step 1/2..."
2018-02-25 21:45:24 +01:00
2024-08-31 09:56:13 +02:00
set_settings_default
2023-11-29 10:58:11 +01:00
ynh_config_add --template='app.ini' --destination="$install_dir/custom/conf/app.ini"
2018-02-25 21:45:24 +01:00
#=================================================
# SYSTEM CONFIGURATION
2018-02-25 21:45:24 +01:00
#=================================================
ynh_script_progression "Adding system configurations related to $app..."
2018-02-25 21:45:24 +01:00
# Create a dedicated NGINX config using the conf/nginx.conf template
ynh_config_add_nginx
2018-02-25 21:45:24 +01:00
# Create a dedicated systemd config
ynh_config_add_systemd
2018-04-30 15:56:19 +02:00
# 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_config_add_logrotate "/var/log/$app"
2019-09-10 22:43:45 +02:00
# Create a dedicated Fail2Ban config
ynh_config_add_fail2ban --logpath="/var/log/$app/gitea.log" --failregex='.*Failed authentication attempt for .* from <HOST>'
2018-02-25 21:45:24 +01:00
#=================================================
# APP INITIAL CONFIGURATION
#=================================================
# ADD A CONFIGURATION
#=================================================
2018-02-25 21:45:24 +01:00
ynh_script_progression 'Configuring application, step 2/2...'
2023-11-29 10:58:11 +01:00
_set_permissions
2019-09-10 22:43:45 +02:00
# 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"
2018-02-25 21:45:24 +01:00
# 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
2018-02-25 21:45:24 +01:00
# Stop the service to restart it just afterwards
ynh_systemctl --service="$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
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression 'Starting gitea services...'
2022-07-24 13:45:53 +02:00
ynh_systemctl --service="$app" --action=start --log_path="/var/log/$app/gitea.log" --wait_until="$systemd_match_start_line"
2019-10-27 14:54:35 +01:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Installation of $app completed"