1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/libreto_ynh.git synced 2024-09-03 19:36:14 +02:00
libreto_ynh/scripts/install
Félix Piédallu 6f31241bfe Remove path question and subdir installation.
Add args.path = "/" for old test_upgrade_from.
2024-01-24 11:18:40 +01:00

89 lines
3.3 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INITIALIZE AND STORE SETTINGS
#=================================================
# FIXME: subdir install does not seem to be supported anymore.
path="/"
ynh_app_setting_set --app="$app" --key=path --value="$path"
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set --app=$app --key=etherpad_instance --value=$etherpad_instance
ynh_app_setting_set --app=$app --key=creation_open --value=$creation_open
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=4
git config --system --add safe.directory $install_dir
# Note: We use git instead of ynh_setup_source, cause this repo use submodules
git clone https://github.com/zamentur/libreto.git "$install_dir" --quiet
chown -R $app:www-data "$install_dir"
pushd "$install_dir"
ynh_exec_as $app git checkout $COMMIT --quiet
ynh_exec_as $app git submodule update --init --recursive --quiet
popd
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_replace_string --match_string="__INSTANCE__" --replace_string="$etherpad_instance" --target_file="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC SETUP
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
cp "../conf/config.dist.php" "$install_dir/config.php"
provider="${domain%%.*}"
if [ "$etherpad_instance" != "https://annuel2.framapad.org" ]; then
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"
else
ynh_replace_string --match_string="__PROVIDER__" --replace_string="framapad" --target_file="$install_dir/config.php"
fi
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$install_dir/config.php"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last