1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/freshrss_ynh.git synced 2024-09-03 18:36:33 +02:00
freshrss_ynh/scripts/install

163 lines
5.7 KiB
Text
Raw Normal View History

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
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
is_public=$YNH_APP_ARG_IS_PUBLIC
2019-02-21 08:05:10 +01:00
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 --home_dir="$final_path"
2021-04-17 18:39:02 +02:00
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
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
2021-04-17 18:39:02 +02:00
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
2021-11-30 16:41:08 +01:00
ynh_add_fpm_config
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
ynh_exec_as $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)
ynh_exec_as $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
ynh_add_config --template="../conf/freshrss.cron" --destination="/etc/cron.d/$app"
2021-08-28 10:54:58 +02:00
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
2019-02-21 08:05:10 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
2019-02-21 08:05:10 +01:00
# Make app public if necessary
if [ $is_public -eq 1 ]
then
ynh_permission_update --permission="main" --add="visitors"
fi
2019-10-22 21:16:46 +02:00
2021-08-24 08:01:56 +02:00
ynh_permission_create --permission="api" --url="/api" --additional_urls="/scripts/api.js" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true"
2021-08-23 23:33:35 +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