2017-02-07 22:51:47 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-09-02 11:08:06 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
2017-02-07 22:51:47 +01:00
|
|
|
|
2020-05-30 16:34:01 +02:00
|
|
|
secret=$(ynh_string_random --length=24)
|
2023-04-21 19:11:39 +02:00
|
|
|
max_file_size=100
|
|
|
|
use_ldap=$YNH_APP_ARG_USE_LDAP
|
2017-02-07 22:51:47 +01:00
|
|
|
|
2019-03-03 18:04:55 +01:00
|
|
|
#=================================================
|
2020-04-20 04:16:40 +02:00
|
|
|
# STORE SETTINGS FROM MANIFEST
|
2019-03-03 18:04:55 +01:00
|
|
|
#=================================================
|
|
|
|
|
2022-01-19 20:47:13 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=use_ldap --value=$use_ldap
|
2020-04-20 04:16:40 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=max_file_size --value=$max_file_size
|
|
|
|
ynh_app_setting_set --app=$app --key=secret --value=$secret
|
2019-03-03 18:04:55 +01:00
|
|
|
|
2018-09-02 11:08:06 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2020-05-30 16:34:01 +02:00
|
|
|
ynh_script_progression --message="Setting up source files..."
|
2018-09-02 11:08:06 +02:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-04-21 19:11:39 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2017-02-07 22:51:47 +01:00
|
|
|
|
2023-04-21 19:11:39 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2021-06-06 19:02:01 +02:00
|
|
|
|
2018-09-02 11:08:06 +02:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2020-11-01 18:24:02 +01:00
|
|
|
ynh_script_progression --message="Configuring NGINX web server..."
|
2017-02-07 22:51:47 +01:00
|
|
|
|
2020-11-01 18:24:02 +01:00
|
|
|
# Create a dedicated NGINX config
|
2022-01-27 02:40:24 +01:00
|
|
|
ynh_add_nginx_config
|
2017-02-07 22:51:47 +01:00
|
|
|
|
2023-04-21 19:11:39 +02:00
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
2022-06-16 21:07:01 +02:00
|
|
|
|
2023-04-21 19:11:39 +02:00
|
|
|
# Use logrotate to manage application logfile(s)
|
|
|
|
ynh_use_logrotate
|
2022-06-16 21:07:01 +02:00
|
|
|
|
2023-04-21 19:11:39 +02:00
|
|
|
yunohost service add $app --description="Lufi service" --log="$install_dir/log/production.log"
|
2022-06-16 21:07:01 +02:00
|
|
|
|
2023-04-21 19:11:39 +02:00
|
|
|
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
|
|
|
chmod +x $install_dir/script/lufi
|
2022-06-16 21:07:01 +02:00
|
|
|
|
|
|
|
#=================================================
|
2020-04-20 04:16:40 +02:00
|
|
|
# CONFIGURE LUFI
|
2018-09-02 11:08:06 +02:00
|
|
|
#=================================================
|
2020-11-14 08:31:09 +01:00
|
|
|
ynh_script_progression --message="Configuring $app..."
|
2017-02-07 22:51:47 +01:00
|
|
|
|
2022-01-19 21:01:53 +01:00
|
|
|
ldap="#"
|
2022-01-19 20:47:13 +01:00
|
|
|
if [ $use_ldap -eq 1 ];
|
2019-03-03 18:04:55 +01:00
|
|
|
then
|
2022-01-19 21:01:53 +01:00
|
|
|
ldap=""
|
|
|
|
fi
|
|
|
|
|
2023-04-21 19:11:39 +02:00
|
|
|
ynh_add_config --template="../conf/lufi.conf" --destination="$install_dir/lufi.conf"
|
2020-04-20 04:16:40 +02:00
|
|
|
|
2023-04-21 19:11:39 +02:00
|
|
|
chmod 600 $install_dir/lufi.conf
|
|
|
|
chown $app:$app $install_dir/lufi.conf
|
2021-05-08 23:38:59 +02:00
|
|
|
|
2020-04-20 04:16:40 +02:00
|
|
|
#=================================================
|
2020-05-30 16:34:01 +02:00
|
|
|
# INSTALL LUFI
|
2020-04-20 04:16:40 +02:00
|
|
|
#=================================================
|
2020-11-14 08:31:09 +01:00
|
|
|
ynh_script_progression --message="Installing $app..."
|
2020-04-20 04:16:40 +02:00
|
|
|
|
2023-04-21 19:11:39 +02:00
|
|
|
pushd $install_dir
|
2020-04-20 04:16:40 +02:00
|
|
|
carton install --deployment --without=sqlite --without=mysql --without=htpasswd --without=test
|
|
|
|
popd
|
2018-09-02 11:08:06 +02:00
|
|
|
|
2020-04-20 04:16:40 +02:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2020-05-30 16:34:01 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
2020-04-20 04:16:40 +02:00
|
|
|
|
2020-05-30 16:34:01 +02:00
|
|
|
# Start a systemd service
|
2023-04-21 19:11:39 +02:00
|
|
|
ynh_systemd_action --service_name=$app --action="start" --line_match="Creating process id file" --log_path="$install_dir/log/production.log"
|
2017-02-07 22:51:47 +01:00
|
|
|
|
2018-09-02 11:08:06 +02:00
|
|
|
#=================================================
|
2019-03-03 18:04:55 +01:00
|
|
|
# END OF SCRIPT
|
2018-09-02 11:08:06 +02:00
|
|
|
#=================================================
|
|
|
|
|
2020-05-30 16:34:01 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed"
|