2018-11-27 17:09:29 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
2020-12-12 08:56:05 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=etherpad_instance --value=$etherpad_instance
|
|
|
|
ynh_app_setting_set --app=$app --key=creation_open --value=$creation_open
|
2018-11-27 17:09:29 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2020-12-12 08:56:05 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=4
|
2018-11-27 17:09:29 +01:00
|
|
|
|
2023-03-19 13:57:05 +01:00
|
|
|
git config --system --add safe.directory $install_dir
|
2023-03-19 14:07:55 +01:00
|
|
|
|
2018-11-27 17:09:29 +01:00
|
|
|
# Note: We use git instead of ynh_setup_source, cause this repo use submodules
|
2023-03-19 13:57:05 +01:00
|
|
|
git clone https://github.com/zamentur/libreto.git "$install_dir" --quiet
|
2020-12-12 08:56:05 +01:00
|
|
|
|
2023-03-19 13:57:05 +01:00
|
|
|
pushd "$install_dir"
|
2020-12-12 08:56:05 +01:00
|
|
|
git checkout $COMMIT --quiet
|
|
|
|
git submodule update --init --recursive --quiet
|
2018-11-27 17:09:29 +01:00
|
|
|
popd
|
|
|
|
|
2023-03-19 13:57:05 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2021-07-02 15:19:53 +02:00
|
|
|
|
2018-11-27 17:09:29 +01:00
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
2020-12-12 08:56:05 +01:00
|
|
|
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
|
2020-12-12 09:34:04 +01:00
|
|
|
|
|
|
|
# Create a dedicated PHP-FPM config
|
2023-03-19 14:07:55 +01:00
|
|
|
ynh_add_fpm_config --usage=low --footprint=low
|
2018-11-27 17:09:29 +01:00
|
|
|
|
2022-06-15 22:53:07 +02:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2020-12-12 08:56:05 +01:00
|
|
|
ynh_replace_string --match_string="__INSTANCE__" --replace_string="$etherpad_instance" --target_file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
2018-11-27 17:09:29 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-06-15 22:53:07 +02:00
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
|
|
|
# ADD A CONFIGURATION
|
2018-11-27 17:09:29 +01:00
|
|
|
#=================================================
|
2022-06-15 22:53:07 +02:00
|
|
|
ynh_script_progression --message="Adding a configuration file..."
|
2020-12-12 08:56:05 +01:00
|
|
|
|
2023-03-19 13:57:05 +01:00
|
|
|
cp "../conf/config.dist.php" "$install_dir/config.php"
|
2018-11-27 17:09:29 +01:00
|
|
|
|
2018-11-27 18:14:40 +01:00
|
|
|
provider="${domain%%.*}"
|
2018-11-27 17:09:29 +01:00
|
|
|
if [ "$etherpad_instance" != "https://annuel2.framapad.org" ]; then
|
2023-03-19 13:57:05 +01:00
|
|
|
ynh_replace_string --match_string="// CUSTOM_PROVIDER" --replace_string="" --target_file="$install_dir/config.php"
|
|
|
|
ynh_replace_string --match_string="__PROVIDER__" --replace_string="$provider" --target_file="$install_dir/config.php"
|
|
|
|
ynh_replace_string --match_string="__INSTANCE__" --replace_string="$etherpad_instance" --target_file="$install_dir/config.php"
|
2018-11-27 17:09:29 +01:00
|
|
|
else
|
2023-03-19 13:57:05 +01:00
|
|
|
ynh_replace_string --match_string="__PROVIDER__" --replace_string="framapad" --target_file="$install_dir/config.php"
|
2018-11-27 17:09:29 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Calculate and store the config file checksum into the app settings
|
2023-03-19 13:57:05 +01:00
|
|
|
ynh_store_file_checksum "$install_dir/config.php"
|
2018-11-27 17:09:29 +01:00
|
|
|
|
2020-12-12 08:56:05 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2018-11-27 17:09:29 +01:00
|
|
|
|
2020-12-12 08:56:05 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|