2014-07-23 15:52:50 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-07-21 12:18:50 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2016-09-01 08:31:03 +02:00
|
|
|
|
2018-07-21 12:18:50 +02:00
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
2017-02-13 22:30:35 +01:00
|
|
|
|
2018-07-21 12:18:50 +02:00
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
2019-07-02 00:38:57 +02:00
|
|
|
|
2017-03-13 20:14:53 +01:00
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
2019-02-21 08:05:10 +01:00
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
|
|
admin=$YNH_APP_ARG_ADMIN
|
|
|
|
language=$YNH_APP_ARG_LANGUAGE
|
|
|
|
|
2017-03-05 17:17:14 +01:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2014-07-23 15:52:50 +02:00
|
|
|
|
2019-02-21 08:05:10 +01:00
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
#=================================================
|
2020-09-04 22:24:17 +02:00
|
|
|
ynh_script_progression --message="Validating installation parameters..."
|
2017-03-05 17:27:33 +01:00
|
|
|
|
2019-02-21 08:05:10 +01:00
|
|
|
final_path=/var/www/$app
|
2019-07-02 00:38:57 +02:00
|
|
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
2014-09-21 11:52:46 +02:00
|
|
|
|
2018-07-21 12:18:50 +02:00
|
|
|
# Register (book) web path
|
2019-07-02 00:38:57 +02:00
|
|
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
2014-07-23 15:52:50 +02:00
|
|
|
|
2019-02-21 08:05:10 +01:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2020-09-04 22:24:17 +02:00
|
|
|
ynh_script_progression --message="Storing installation settings..."
|
2017-02-13 22:20:55 +01:00
|
|
|
|
2019-07-02 00:38:57 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
|
|
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
|
|
|
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
|
|
|
ynh_app_setting_set --app=$app --key=language --value=$language
|
2019-02-21 08:05:10 +01:00
|
|
|
|
2021-03-22 23:20:17 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installing dependencies..." --weight=3
|
|
|
|
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
|
2021-04-17 18:39:02 +02:00
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring system user..."
|
|
|
|
|
|
|
|
# Create a system user
|
|
|
|
ynh_system_user_create --username=$app
|
|
|
|
|
2019-02-21 08:05:10 +01:00
|
|
|
#=================================================
|
|
|
|
# CREATE A MYSQL DATABASE
|
|
|
|
#=================================================
|
2020-09-04 22:24:17 +02:00
|
|
|
ynh_script_progression --message="Creating a MySQL database..."
|
2019-02-21 08:05:10 +01:00
|
|
|
|
2019-07-02 00:38:57 +02:00
|
|
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
|
|
|
db_user=$db_name
|
|
|
|
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
|
|
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
2019-02-21 08:05:10 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2020-09-04 22:24:17 +02:00
|
|
|
ynh_script_progression --message="Setting up source files..."
|
2019-02-21 08:05:10 +01:00
|
|
|
|
2019-07-02 00:38:57 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
2019-02-21 08:05:10 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2019-07-02 00:38:57 +02:00
|
|
|
ynh_setup_source --dest_dir="$final_path"
|
2019-02-21 08:05:10 +01:00
|
|
|
|
2021-04-17 18:39:02 +02:00
|
|
|
set_permissions
|
|
|
|
|
2019-02-21 08:05:10 +01:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2020-09-04 22:24:17 +02:00
|
|
|
ynh_script_progression --message="Configuring NGINX web server..."
|
2019-02-21 08:05:10 +01:00
|
|
|
|
2020-09-04 22:24:17 +02:00
|
|
|
# Create a dedicated NGINX config
|
2019-02-21 08:05:10 +01:00
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
2020-09-04 22:24:17 +02:00
|
|
|
ynh_script_progression --message="Configuring PHP-FPM..."
|
2019-02-21 08:05:10 +01:00
|
|
|
|
2020-09-04 22:24:17 +02:00
|
|
|
# Create a dedicated PHP-FPM config
|
2020-11-13 14:55:16 +01:00
|
|
|
ynh_add_fpm_config --package="$extra_php_dependencies"
|
2020-10-01 22:19:32 +02:00
|
|
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
2017-02-12 11:34:30 +01:00
|
|
|
|
2020-09-04 22:24:17 +02:00
|
|
|
#=================================================
|
2019-07-02 00:38:57 +02:00
|
|
|
# SETUPING FRESHRSS
|
|
|
|
#=================================================
|
2020-09-04 22:24:17 +02:00
|
|
|
ynh_script_progression --message="FreshRSS setup script..."
|
2019-07-02 00:38:57 +02:00
|
|
|
|
2021-04-17 18:39:02 +02:00
|
|
|
sudo -u $app $final_path/cli/do-install.php --default_user $admin --auth_type http_auth --environment production --base_url https://$domain$path_url --title FreshRSS --api_enabled --db-type mysql --db-host localhost --db-user $db_name --db-password $db_pwd --db-base $db_name
|
2017-01-22 14:50:51 +01:00
|
|
|
|
2020-09-04 22:24:17 +02:00
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Creating users..."
|
|
|
|
|
2017-02-13 22:37:16 +01:00
|
|
|
for myuser in $(ynh_user_list)
|
2014-07-23 15:52:50 +02:00
|
|
|
do
|
2017-01-22 14:50:51 +01:00
|
|
|
user_token=$(ynh_string_random)
|
2021-04-17 18:39:02 +02:00
|
|
|
sudo -u $app $final_path/cli/create-user.php --user $myuser --language $language --token $user_token
|
2014-07-23 15:52:50 +02:00
|
|
|
done
|
2019-02-21 08:05:10 +01:00
|
|
|
|
|
|
|
#=================================================
|
2019-07-02 00:38:57 +02:00
|
|
|
# SETUP A CRON
|
2019-02-21 08:05:10 +01:00
|
|
|
#=================================================
|
2020-09-04 22:24:17 +02:00
|
|
|
ynh_script_progression --message="Setting up cron..."
|
2019-07-02 00:38:57 +02:00
|
|
|
|
2017-02-13 22:20:55 +01:00
|
|
|
cron_path="/etc/cron.d/$app"
|
2020-09-04 22:39:46 +02:00
|
|
|
|
2019-07-02 00:38:57 +02:00
|
|
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string=$final_path --target_file="../conf/freshrss.cron"
|
|
|
|
ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file="../conf/freshrss.cron"
|
2020-10-18 22:21:30 +02:00
|
|
|
ynh_replace_string --match_string="__PHPVERSION__" --replace_string=$phpversion --target_file="../conf/freshrss.cron"
|
2020-09-04 22:39:46 +02:00
|
|
|
|
2019-02-21 08:05:10 +01:00
|
|
|
cp ../conf/freshrss.cron "$cron_path"
|
|
|
|
chmod 644 "$cron_path"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
2020-09-04 22:24:17 +02:00
|
|
|
ynh_script_progression --message="Configuring SSOwat..."
|
2019-02-21 08:05:10 +01:00
|
|
|
|
2015-10-03 11:58:14 +02:00
|
|
|
#skip api directory
|
2020-04-05 09:48:43 +02:00
|
|
|
ynh_app_setting_set --app="$app" --key=skipped_uris --value="/api/,/scripts/api.js"
|
2019-10-22 21:16:46 +02:00
|
|
|
ynh_app_setting_delete --app="$app" --key=unprotected_regex
|
2020-04-05 09:48:43 +02:00
|
|
|
ynh_app_setting_delete --app="$app" --key=unprotected_uris
|
2019-10-22 21:16:46 +02:00
|
|
|
|
2019-02-21 08:05:10 +01:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2020-09-04 22:39:46 +02:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..."
|
2019-02-21 08:05:10 +01:00
|
|
|
|
2019-07-02 00:38:57 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2019-02-21 08:05:10 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-09-04 22:24:17 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|
|
|
|
|