2017-02-02 19:21:27 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-02-20 17:33:19 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2017-04-21 12:54:39 +02:00
|
|
|
|
2018-02-20 17:33:19 +01:00
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
2017-02-02 19:21:27 +01:00
|
|
|
|
2018-11-03 21:46:35 +01:00
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
2022-06-16 01:28:41 +02:00
|
|
|
secret=$(ynh_string_random --length=24)
|
|
|
|
hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1)
|
|
|
|
|
2018-11-03 21:46:35 +01:00
|
|
|
#=================================================
|
2020-04-19 05:16:46 +02:00
|
|
|
# STORE SETTINGS FROM MANIFEST
|
2018-11-03 21:46:35 +01:00
|
|
|
#=================================================
|
2023-05-31 21:08:32 +02:00
|
|
|
ynh_script_progression --message="Storing installation settings..."
|
2018-11-03 21:46:35 +01:00
|
|
|
|
2020-04-19 05:16:46 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=secret --value=$secret
|
2023-05-31 21:08:32 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password
|
2018-11-04 11:00:03 +01:00
|
|
|
|
2018-11-03 21:46:35 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2020-05-30 15:28:48 +02:00
|
|
|
ynh_script_progression --message="Setting up source files..."
|
2017-02-02 19:21:27 +01:00
|
|
|
|
2018-11-03 21:46:35 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-05-31 20:58:29 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2018-11-03 21:46:35 +01:00
|
|
|
|
2023-05-31 20:58:29 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2021-06-20 23:23:08 +02:00
|
|
|
|
2018-11-03 21:46:35 +01:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2020-11-16 16:41:23 +01:00
|
|
|
ynh_script_progression --message="Configuring NGINX web server..."
|
2017-02-02 19:21:27 +01:00
|
|
|
|
2018-11-03 21:46:35 +01:00
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
2017-02-02 19:21:27 +01:00
|
|
|
|
2023-06-01 08:37:45 +02:00
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
|
|
|
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
|
|
ynh_use_logrotate
|
|
|
|
|
|
|
|
yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log"
|
|
|
|
|
2020-05-30 16:42:42 +02:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
2018-11-03 21:46:35 +01:00
|
|
|
#=================================================
|
2022-06-16 01:28:41 +02:00
|
|
|
# ADD A CONFIGURATION
|
2018-11-03 21:46:35 +01:00
|
|
|
#=================================================
|
2022-06-16 01:28:41 +02:00
|
|
|
ynh_script_progression --message="Adding a configuration file..."
|
2020-04-19 05:16:46 +02:00
|
|
|
|
2023-05-31 21:08:32 +02:00
|
|
|
ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$install_dir/lstu.conf"
|
2020-05-28 21:36:47 +02:00
|
|
|
|
2018-11-03 21:46:35 +01:00
|
|
|
#=================================================
|
2020-05-28 21:36:47 +02:00
|
|
|
# INSTALL LSTU
|
2018-11-03 21:46:35 +01:00
|
|
|
#=================================================
|
2020-12-08 17:31:59 +01:00
|
|
|
ynh_script_progression --message="Installing Lstu..."
|
2018-11-03 21:46:35 +01:00
|
|
|
|
2023-05-31 20:58:29 +02:00
|
|
|
pushd $install_dir
|
2020-04-19 05:16:46 +02:00
|
|
|
carton install --deployment --without=sqlite --without=mysql
|
2019-02-03 00:19:57 +01:00
|
|
|
popd
|
2018-11-03 21:46:35 +01:00
|
|
|
|
2020-04-19 05:16:46 +02:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2020-05-30 15:28:48 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
2020-04-19 05:16:46 +02:00
|
|
|
|
|
|
|
# Start a systemd service
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at"
|
|
|
|
|
2019-02-21 12:35:13 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-05-30 15:30:23 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed"
|