2021-08-12 13:28:44 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2024-02-29 11:12:03 +01:00
|
|
|
# INITIALIZE AND STORE SETTINGS
|
2021-08-12 13:28:44 +02:00
|
|
|
#=================================================
|
|
|
|
|
2022-05-17 12:34:04 +02:00
|
|
|
secret_key=$(ynh_string_random --length=137)
|
2024-02-29 11:12:03 +01:00
|
|
|
ynh_app_setting_set --app=$app --key="secret_key" --value="$secret_key"
|
2021-08-12 13:28:44 +02:00
|
|
|
|
2021-11-20 09:43:20 +01:00
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
2024-02-29 11:12:03 +01:00
|
|
|
ynh_script_progression --message="Installing NodeJS..." --weight=1
|
2021-11-20 09:43:20 +01:00
|
|
|
|
2022-05-17 19:05:53 +02:00
|
|
|
ynh_install_nodejs --nodejs_version=$nodejs_version
|
|
|
|
|
2021-08-12 13:28:44 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=7
|
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-02-29 11:12:03 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir/sources"
|
|
|
|
mkdir -p "$install_dir/sources/"{cache,uploads}
|
2021-08-12 13:28:44 +02:00
|
|
|
|
2024-02-29 11:12:03 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2021-11-20 09:43:20 +01:00
|
|
|
|
2021-08-12 13:28:44 +02:00
|
|
|
#=================================================
|
|
|
|
# INSTALL AND INITIALIZE COMPOSER
|
|
|
|
#=================================================
|
2024-03-03 12:33:18 +01:00
|
|
|
ynh_script_progression --message="Installing $app with Composer..." --weight=30
|
2021-08-12 13:28:44 +02:00
|
|
|
|
2024-02-29 11:12:03 +01:00
|
|
|
pushd "$install_dir/sources"
|
2024-03-03 14:53:14 +01:00
|
|
|
ynh_install_composer --workdir="$install_dir/sources" --install_args="--no-dev"
|
2024-03-03 12:33:18 +01:00
|
|
|
|
2024-05-29 10:23:38 +02:00
|
|
|
corepack enable
|
|
|
|
corepack prepare pnpm@latest --activate
|
|
|
|
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" pnpm install --pure-lockfile --prod
|
|
|
|
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" pnpm run buildall
|
2021-08-12 17:09:43 +02:00
|
|
|
|
2024-03-03 14:53:14 +01:00
|
|
|
ynh_composer_exec --workdir="$install_dir/sources" --commands="install --prefer-dist --no-cache --no-progress --no-dev -a"
|
2021-08-12 13:28:44 +02:00
|
|
|
|
2024-02-29 11:12:03 +01:00
|
|
|
ynh_secure_remove node_modules
|
2024-05-29 10:23:38 +02:00
|
|
|
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" pnpm cache clean
|
2021-08-12 17:09:43 +02:00
|
|
|
|
2024-02-29 11:12:03 +01:00
|
|
|
ynh_add_config --template="config.php" --destination="$install_dir/sources/config.php"
|
|
|
|
ynh_exec_as "$app" "php$phpversion" "bin/install" start -q
|
|
|
|
popd
|
2021-08-12 13:28:44 +02:00
|
|
|
|
2024-02-29 11:12:03 +01:00
|
|
|
# ynh_script_progression --message="Configuring LDAP and emails..." --weight=2
|
|
|
|
# ynh_add_config --template="sql.template" --destination="$install_dir/ldap_sql"
|
|
|
|
# ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < "$install_dir/ldap_sql"
|
|
|
|
# ynh_secure_remove --file="$install_dir/ldap_sql"
|
2022-05-17 16:32:45 +02:00
|
|
|
|
2024-02-29 11:12:03 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2021-08-12 13:28:44 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-02-29 11:12:03 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2021-08-12 13:28:44 +02:00
|
|
|
#=================================================
|
2024-02-29 11:12:03 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
2021-08-12 13:28:44 +02:00
|
|
|
|
2024-02-29 11:12:03 +01:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2021-08-12 13:28:44 +02:00
|
|
|
|
2024-02-29 11:12:03 +01:00
|
|
|
# Create a dedicated PHP-FPM config
|
|
|
|
ynh_add_fpm_config
|
2021-08-12 13:28:44 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|