2015-03-19 20:49:50 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
2021-05-16 16:48:58 +02:00
|
|
|
# GENERIC START
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2016-06-15 23:56:45 +02:00
|
|
|
|
2020-04-24 20:16:33 +02:00
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
2016-06-15 23:56:45 +02:00
|
|
|
|
2022-06-23 08:54:56 +02:00
|
|
|
secret=$(ynh_string_random)
|
|
|
|
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2015-03-27 23:20:31 +01:00
|
|
|
|
2020-01-02 18:40:15 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=always_encrypt --value=$always_encrypt
|
2022-06-23 08:54:56 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=secret --value="$secret"
|
2019-01-30 19:27:17 +01:00
|
|
|
|
2020-01-02 18:40:15 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=overwrite_settings --value=1
|
|
|
|
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1
|
|
|
|
ynh_app_setting_set --app=$app --key=overwrite_systemd --value=1
|
|
|
|
ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
|
2015-03-19 20:49:50 +01:00
|
|
|
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2020-01-02 18:40:15 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..."
|
2015-03-19 20:49:50 +01:00
|
|
|
|
2020-01-02 18:40:15 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-04-16 17:12:12 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2015-11-18 00:28:42 +01:00
|
|
|
|
2023-04-16 17:12:12 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:$app "$install_dir"
|
2017-03-19 19:16:10 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2020-10-05 22:02:46 +02:00
|
|
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
|
2016-06-15 23:56:45 +02:00
|
|
|
|
2020-10-05 22:02:46 +02:00
|
|
|
# Create a dedicated NGINX config
|
2017-09-05 00:25:58 +02:00
|
|
|
ynh_add_nginx_config
|
2017-03-19 19:16:10 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
2022-07-28 22:53:10 +02:00
|
|
|
# ADD A CONFIGURATION
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
2022-07-28 22:53:10 +02:00
|
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=2
|
2015-03-19 20:49:50 +01:00
|
|
|
|
2022-07-28 22:53:10 +02:00
|
|
|
workers="$(( $(nproc) * 2 ))"
|
2023-04-16 17:12:12 +02:00
|
|
|
ynh_add_config --template="../conf/lutim.conf.template" --destination="$install_dir/lutim.conf"
|
2022-06-23 08:54:56 +02:00
|
|
|
|
2023-04-16 17:12:12 +02:00
|
|
|
chmod 400 "$install_dir/lutim.conf"
|
|
|
|
chown $app:$app "$install_dir/lutim.conf"
|
2016-06-05 00:53:04 +02:00
|
|
|
|
2020-01-29 15:24:28 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP HOOKS FILE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_addaccess"
|
|
|
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_removeaccess"
|
|
|
|
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP CRON
|
|
|
|
#=================================================
|
2015-03-19 20:49:50 +01:00
|
|
|
|
2021-04-22 22:46:29 +02:00
|
|
|
ynh_add_config --template="../conf/cron_lutim" --destination="/etc/cron.d/$app"
|
2023-04-16 17:12:12 +02:00
|
|
|
chmod +x $install_dir/script/lutim
|
2015-03-19 20:49:50 +01:00
|
|
|
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
|
|
|
# INSTALL LUTIM WITH CARTON
|
|
|
|
#=================================================
|
2020-11-12 15:30:00 +01:00
|
|
|
ynh_script_progression --message="Installing $app with Carton..." --weight=60
|
2016-05-15 12:15:08 +02:00
|
|
|
|
2017-09-05 00:25:58 +02:00
|
|
|
mkdir -p /var/log/$app/
|
2023-04-16 17:12:12 +02:00
|
|
|
(cd $install_dir
|
2017-12-05 19:36:40 +01:00
|
|
|
carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log")
|
2015-03-19 20:49:50 +01:00
|
|
|
|
2019-01-18 19:56:43 +01:00
|
|
|
# Use a perl path adapted to the system architecture
|
2023-04-16 17:12:12 +02:00
|
|
|
arch_dir=$(ls -1 $install_dir/local/lib/perl5/ | grep linux-gnu)
|
2015-08-19 21:33:40 +02:00
|
|
|
if [ "$?" -ne 0 ]
|
|
|
|
then
|
2022-07-28 22:53:10 +02:00
|
|
|
ynh_die --message="Unable to find the perl directory for your architecture."
|
2015-08-19 21:33:40 +02:00
|
|
|
fi
|
2023-04-16 17:12:12 +02:00
|
|
|
ynh_replace_string --match_string="__ARCHDIR__" --replace_string="$arch_dir" --target_file="$install_dir/script/lutim"
|
2015-08-19 21:33:40 +02:00
|
|
|
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP LOG FILE
|
|
|
|
#=================================================
|
2015-03-19 20:49:50 +01:00
|
|
|
|
2019-01-18 19:56:43 +01:00
|
|
|
# Making log a symbolic link to /var/log
|
2017-09-05 00:25:58 +02:00
|
|
|
touch /var/log/$app/production.log
|
2017-09-08 13:10:22 +02:00
|
|
|
chown $app -R /var/log/$app
|
2023-04-16 17:12:12 +02:00
|
|
|
ln -s /var/log/$app/production.log "$install_dir/log/production.log"
|
2015-03-26 13:07:01 +01:00
|
|
|
|
2022-07-28 22:53:10 +02:00
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring a systemd service..." --weight=2
|
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
|
|
|
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
2022-06-23 08:54:56 +02:00
|
|
|
# GENERIC FINALIZATION
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP LOGROTATE
|
|
|
|
#=================================================
|
2020-01-02 18:40:15 +01:00
|
|
|
ynh_script_progression --message="Configuring log rotation..." --weight=2
|
2015-03-19 20:49:50 +01:00
|
|
|
|
2019-01-18 19:56:43 +01:00
|
|
|
# Use logrotate to manage application logfile(s)
|
2017-03-19 19:16:10 +01:00
|
|
|
ynh_use_logrotate
|
|
|
|
|
|
|
|
#=================================================
|
2021-05-16 16:48:58 +02:00
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
2017-03-19 19:16:10 +01:00
|
|
|
#=================================================
|
2021-05-16 16:48:58 +02:00
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
2015-11-18 00:28:42 +01:00
|
|
|
|
2023-04-16 17:12:12 +02:00
|
|
|
yunohost service add $app --log="$install_dir/log/production.log"
|
2015-03-26 13:07:01 +01:00
|
|
|
|
2021-05-16 16:48:58 +02:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=6
|
|
|
|
|
|
|
|
# Wait for lutim to be fully started
|
|
|
|
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
|
|
|
ynh_systemd_action --action=stop
|
|
|
|
|
|
|
|
# Set right permissions on new files created at first start
|
2023-04-16 17:12:12 +02:00
|
|
|
chown -R $app:$app $install_dir
|
2021-05-16 16:48:58 +02:00
|
|
|
|
|
|
|
# Wait for lutim to be fully started
|
|
|
|
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
|
|
|
|
2019-01-30 16:19:40 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-11-12 15:30:00 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|