mirror of
https://framagit.org/YunoHost-Apps/gitea_ynh.git
synced 2025-09-03 02:28:30 +02:00
Fix install and fix linter
This commit is contained in:
@ -33,15 +33,15 @@ ynh_user_exists "$admin" \
|
||||
# Check Final Path availability
|
||||
test ! -e "$final_path" || ynh_die --message "This path already contains a folder"
|
||||
|
||||
if [ -e "$DATADIR" ]; then
|
||||
old_data_dir_path="$DATADIR$(date '+%Y%m%d.%H%M%S')"
|
||||
if [ -e "$datadir" ]; then
|
||||
old_data_dir_path="$datadir$(date '+%Y%m%d.%H%M%S')"
|
||||
ynh_print_warn "A data directory already exist. Data was renamed to $old_data_dir_path"
|
||||
mv "$DATADIR" "$old_data_dir_path"
|
||||
mv "$datadir" "$old_data_dir_path"
|
||||
fi
|
||||
|
||||
# Generate random password and key
|
||||
ynh_script_progression --message="Defining db password and key..."
|
||||
DB_PASSWORD=$(ynh_string_random)
|
||||
db_password=$(ynh_string_random)
|
||||
key=$(ynh_string_random)
|
||||
|
||||
# Find available ports
|
||||
@ -49,7 +49,7 @@ port=$(ynh_find_port --port 6000)
|
||||
|
||||
# Store Settings
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
ynh_app_setting_set --app $app --key mysqlpwd --value $DB_PASSWORD
|
||||
ynh_app_setting_set --app $app --key mysqlpwd --value $db_password
|
||||
ynh_app_setting_set --app $app --key adminusername --value $admin
|
||||
ynh_app_setting_set --app $app --key secret_key --value $key
|
||||
ynh_app_setting_set --app $app --key web_port --value $port
|
||||
@ -60,11 +60,11 @@ ynh_app_setting_set --app $app --key web_port --value $port
|
||||
|
||||
# Initialize database and store mysql password for upgrade
|
||||
ynh_script_progression --message="Configuring MySQL database..."
|
||||
ynh_mysql_create_db "$dbname" "$db_user" "$DB_PASSWORD"
|
||||
ynh_mysql_create_db "$dbname" "$db_user" "$db_password"
|
||||
|
||||
# Add users
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
ynh_system_user_create --username=$app --home_dir=/home/$app --use_shell
|
||||
ynh_system_user_create --username=$app --home_dir=$datadir --use_shell
|
||||
# Add ssh permission for gitea user
|
||||
adduser $app ssh.app
|
||||
|
||||
@ -98,14 +98,14 @@ ynh_script_progression --message="Configuring application, step 2/2..."
|
||||
systemctl start "$app".service
|
||||
|
||||
# Wait untill login_source mysql table is created
|
||||
while ! $(ynh_mysql_connect_as "$db_user" "$DB_PASSWORD" "$dbname" <<< "SELECT * FROM login_source;" &>/dev/null)
|
||||
while ! $(ynh_mysql_connect_as "$db_user" "$db_password" "$dbname" <<< "SELECT * FROM login_source;" &>/dev/null)
|
||||
do
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Add ldap config
|
||||
ynh_replace_string --match_string "__APP__" --replace_string "$app" --target_file ../conf/login_source.sql
|
||||
ynh_mysql_connect_as "$db_user" "$DB_PASSWORD" "$dbname" < ../conf/login_source.sql
|
||||
ynh_mysql_connect_as "$db_user" "$db_password" "$dbname" < ../conf/login_source.sql
|
||||
|
||||
# SETUP FAIL2BAN
|
||||
ynh_script_progression --message="Configuring fail2ban..."
|
||||
@ -116,7 +116,7 @@ ynh_add_fail2ban_config --logpath "/var/log/$app/gitea.log" --failregex ".*Faile
|
||||
#=================================================
|
||||
|
||||
# Unprotect root from SSO if public
|
||||
ynh_script_progression --message="Protecting directory"
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
if [ "$is_public" == '1' ];
|
||||
then
|
||||
ynh_permission_update --permission "main" --add "visitors"
|
||||
@ -139,7 +139,7 @@ ynh_app_setting_set --app $app --key upstream_version --value $(ynh_app_upstream
|
||||
|
||||
# Reload services
|
||||
ynh_script_progression --message="Starting gitea services..." --weight=3
|
||||
ynh_systemd_action -l "Starting new server: tcp:127.0.0.1:" -p "/var/log/$app/gitea.log" -t 10
|
||||
ynh_systemd_action -l "Starting new Web server: tcp:127.0.0.1:" -p "/var/log/$app/gitea.log" -t 10
|
||||
sleep 1
|
||||
|
||||
# Store the checksum with the 'INTERNAL_TOKEN' value.
|
||||
|
Reference in New Issue
Block a user