2016-08-21 01:03:46 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-02-17 23:50:49 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
2023-01-27 18:12:14 +01:00
|
|
|
fpm_footprint="low"
|
|
|
|
fpm_free_footprint=0
|
|
|
|
fpm_usage="low"
|
2021-02-17 23:50:49 +01:00
|
|
|
|
2023-01-27 18:12:14 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
|
|
|
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
|
|
|
|
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
2021-02-17 23:50:49 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2021-03-15 23:14:42 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
2021-02-17 23:50:49 +01:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-04-27 09:44:41 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2021-02-17 23:50:49 +01:00
|
|
|
|
2023-04-27 09:44:41 +02:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2021-02-17 23:50:49 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
2021-03-15 23:14:42 +01:00
|
|
|
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
|
2021-02-17 23:50:49 +01:00
|
|
|
|
|
|
|
# Create a dedicated PHP-FPM config
|
2023-01-27 18:12:14 +01:00
|
|
|
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
|
2021-02-17 23:50:49 +01:00
|
|
|
|
2022-07-19 03:18:49 +02:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2021-02-17 23:50:49 +01:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
2021-03-01 09:43:17 +01:00
|
|
|
# SETUP SQL CREDENTIALS
|
2021-02-17 23:50:49 +01:00
|
|
|
#=================================================
|
|
|
|
|
2023-12-27 18:38:29 +01:00
|
|
|
ynh_add_config --template="common.php" --destination="$install_dir/protected/config/common.php"
|
2021-03-01 09:43:17 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DEACTIVATE DEBUG MODE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_replace_string --match_string="defined('YII_DEBUG') or define('YII_DEBUG', true);"\
|
|
|
|
--replace_string="// defined('YII_DEBUG') or define('YII_DEBUG', true);"\
|
2023-04-27 09:44:41 +02:00
|
|
|
--target_file="$install_dir/index.php"
|
2021-03-01 09:43:17 +01:00
|
|
|
ynh_replace_string --match_string="defined('YII_ENV') or define('YII_ENV', 'dev');"\
|
|
|
|
--replace_string="// defined('YII_ENV') or define('YII_ENV', 'dev');"\
|
2023-04-27 09:44:41 +02:00
|
|
|
--target_file="$install_dir/index.php"
|
2021-03-01 09:43:17 +01:00
|
|
|
|
2021-02-17 23:50:49 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP APPLICATION WITH CURL
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Set right permissions for curl install
|
2023-04-27 09:44:41 +02:00
|
|
|
chown -R $app: $install_dir
|
2021-02-17 23:50:49 +01:00
|
|
|
|
|
|
|
# Set the app as temporarily public for curl call
|
2021-03-15 23:14:42 +01:00
|
|
|
ynh_script_progression --message="Configuring SSOwat..." --weight=30
|
2023-04-27 09:51:02 +02:00
|
|
|
|
2021-02-17 23:50:49 +01:00
|
|
|
# Reload SSOwat config
|
|
|
|
yunohost app ssowatconf
|
|
|
|
|
|
|
|
# Installation with curl
|
2021-03-15 23:14:42 +01:00
|
|
|
ynh_script_progression --message="Finalizing installation..." --weight=2
|
2021-03-01 09:43:17 +01:00
|
|
|
|
2022-05-18 15:24:23 +02:00
|
|
|
install_sso
|
|
|
|
|
2023-04-27 09:44:41 +02:00
|
|
|
pushd $install_dir/protected
|
2022-08-30 00:36:35 +02:00
|
|
|
php$phpversion yii migrate/up --includeModuleMigrations=1 --interactive=0
|
|
|
|
|
|
|
|
php$phpversion yii settings/set ldap enabled '1'
|
|
|
|
php$phpversion yii settings/set ldap hostname 'localhost'
|
|
|
|
php$phpversion yii settings/set ldap port 389
|
|
|
|
php$phpversion yii settings/set ldap encryption ''
|
|
|
|
php$phpversion yii settings/set ldap username ''
|
|
|
|
php$phpversion yii settings/set ldap password ''
|
|
|
|
php$phpversion yii settings/set ldap baseDn 'ou=users,dc=yunohost,dc=org'
|
|
|
|
php$phpversion yii settings/set ldap loginFilter '(uid=%s)'
|
|
|
|
php$phpversion yii settings/set ldap userFilter 'objectClass=mailAccount'
|
|
|
|
php$phpversion yii settings/set ldap emailAttribute 'mail'
|
|
|
|
php$phpversion yii settings/set ldap usernameAttribute 'uid'
|
|
|
|
php$phpversion yii settings/set ldap idAttribute 'uid'
|
|
|
|
php$phpversion yii settings/set ldap refreshUsers '1'
|
|
|
|
php$phpversion yii settings/set ldap refreshUsers '1'
|
|
|
|
|
|
|
|
php$phpversion yii ldap/sync
|
|
|
|
php$phpversion yii user/make-admin ${admin}
|
2021-10-25 23:03:08 +02:00
|
|
|
|
|
|
|
ynh_local_curl "/index.php?r=installer/index/go"
|
|
|
|
|
|
|
|
local_curl_csrf "/index.php?r=installer/config/basic" \
|
|
|
|
"ConfigBasicForm[name]=YunoHost"
|
|
|
|
|
|
|
|
local_curl_csrf "/index.php?r=installer/config/use-case" \
|
|
|
|
"UseCaseForm[useCase]=" \
|
|
|
|
"UseCaseForm[useCase]=other"
|
|
|
|
|
|
|
|
local_curl_csrf "/index.php?r=installer/config/sample-data" \
|
|
|
|
"SampleDataForm[sampleData]=0"
|
|
|
|
|
2022-08-30 00:36:35 +02:00
|
|
|
php$phpversion yii settings/set user auth.anonymousRegistration '0'
|
|
|
|
php$phpversion yii settings/set user auth.allowGuestAccess '0'
|
|
|
|
php$phpversion yii settings/set user auth.internalUsersCanInvite '0'
|
2021-10-25 23:03:08 +02:00
|
|
|
|
2022-08-30 00:36:35 +02:00
|
|
|
php$phpversion yii module/enable auth-basic
|
2021-02-17 23:50:49 +01:00
|
|
|
|
2022-05-18 15:24:23 +02:00
|
|
|
popd
|
2022-05-18 14:52:14 +02:00
|
|
|
|
2023-04-27 09:44:41 +02:00
|
|
|
ynh_store_file_checksum --file="$install_dir/protected/config/common.php"
|
2021-02-17 23:50:49 +01:00
|
|
|
|
2023-04-27 09:44:41 +02:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2022-08-30 00:36:35 +02:00
|
|
|
|
2021-02-17 23:50:49 +01:00
|
|
|
#=================================================
|
2022-07-19 03:18:49 +02:00
|
|
|
# SETUP CRON CONFIGURATION
|
2021-02-17 23:50:49 +01:00
|
|
|
#=================================================
|
2022-08-30 00:36:35 +02:00
|
|
|
ynh_script_progression --message="Setuping crontab..." --weight=1
|
2021-02-17 23:50:49 +01:00
|
|
|
|
2023-12-27 18:38:29 +01:00
|
|
|
ynh_add_config --template="cron" --destination="/etc/cron.d/${app}"
|
2021-02-17 23:50:49 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|