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

177 lines
5.9 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
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
#=================================================
2019-07-02 00:38:57 +02:00
ynh_print_info --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
#=================================================
2019-07-02 00:38:57 +02:00
ynh_print_info --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
#=================================================
# STANDARD MODIFICATIONS
#=================================================
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2019-07-02 00:38:57 +02:00
ynh_print_info --message="Installing dependencies..."
2019-02-21 08:05:10 +01:00
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
2019-07-02 00:38:57 +02:00
ynh_print_info --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
#=================================================
2019-07-02 00:38:57 +02:00
ynh_print_info --message="Setting up source files..."
2019-02-21 08:05:10 +01:00
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src
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
#=================================================
# NGINX CONFIGURATION
#=================================================
2019-07-02 00:38:57 +02:00
ynh_print_info --message="Configuring nginx web server..."
2019-02-21 08:05:10 +01:00
### `ynh_add_nginx_config` will use the file conf/nginx.conf
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
2019-07-02 00:38:57 +02:00
ynh_print_info --message="Configuring system user..."
2018-07-21 12:18:50 +02:00
2019-02-21 08:05:10 +01:00
# Create a system user
2019-07-02 00:38:57 +02:00
ynh_system_user_create --username=$app
2014-07-23 15:52:50 +02:00
2019-02-21 08:05:10 +01:00
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
2019-07-02 00:38:57 +02:00
ynh_print_info --message="Configuring php-fpm..."
2019-02-21 08:05:10 +01:00
# Create a dedicated php-fpm config
ynh_add_fpm_config
2017-02-12 11:34:30 +01:00
2019-02-21 08:05:10 +01:00
#=================================================
# SPECIFIC SETUP
#=================================================
2019-07-02 00:38:57 +02:00
# SETUPING FRESHRSS
#=================================================
ynh_print_info --message="FreshRSS setup script..."
$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
2014-07-23 15:52:50 +02:00
# Add users
2019-07-02 00:38:57 +02:00
ynh_print_info --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)
2019-05-22 12:38:02 +02:00
$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
#=================================================
2019-07-02 00:38:57 +02:00
ynh_print_info --message="Setting up cron..."
2017-02-13 22:20:55 +01:00
cron_path="/etc/cron.d/$app"
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"
2019-02-21 08:05:10 +01:00
cp ../conf/freshrss.cron "$cron_path"
chmod 644 "$cron_path"
#=================================================
2017-02-13 22:20:55 +01:00
2014-07-23 15:52:50 +02:00
2019-02-21 08:05:10 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R root: $final_path
chown -R $app: $final_path/data/
chown -R $app: $final_path/extensions/
#=================================================
# SETUP SSOWAT
#=================================================
2019-07-02 00:38:57 +02:00
ynh_print_info --message="Configuring SSOwat..."
2019-02-21 08:05:10 +01:00
#skip api directory
2019-10-22 21:16:46 +02:00
ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/api/,/scripts/api.js"
ynh_app_setting_delete --app="$app" --key=unprotected_regex
ynh_app_setting_delete --app="$app" --key=skipped_uris
2019-02-21 08:05:10 +01:00
#=================================================
# RELOAD NGINX
#=================================================
2019-07-02 00:38:57 +02:00
ynh_print_info --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
#=================================================
2019-07-02 00:38:57 +02:00
ynh_print_info --message="Installation of $app completed"