1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/humhub_ynh.git synced 2024-09-03 19:26:11 +02:00
humhub_ynh/scripts/install

135 lines
6.1 KiB
Bash

#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
ynh_app_setting_set --key=php_upload_max_filesize --value=1G
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | fpm_footprint="low"
#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | fpm_free_footprint=0
#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | fpm_usage="low"
#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_footprint --value=$fpm_footprint
#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_free_footprint --value=$fpm_free_footprint
#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | ynh_app_setting_set --key=fpm_usage --value=$fpm_usage
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression "Configuring PHP-FPM..."
# Create a dedicated PHP-FPM config
ynh_config_add_phpfpm
# Create a dedicated NGINX config
ynh_config_add_nginx
#=================================================
# SPECIFIC SETUP
#=================================================
# SETUP SQL CREDENTIALS
#=================================================
ynh_config_add --template="common.php" --destination="$install_dir/protected/config/common.php"
#=================================================
# DEACTIVATE DEBUG MODE
#=================================================
ynh_replace --match="defined('YII_DEBUG') or define('YII_DEBUG', true);"\
--replace="// defined('YII_DEBUG') or define('YII_DEBUG', true);"\
--file="$install_dir/index.php"
ynh_replace --match="defined('YII_ENV') or define('YII_ENV', 'dev');"\
--replace="// defined('YII_ENV') or define('YII_ENV', 'dev');"\
--file="$install_dir/index.php"
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
# Set right permissions for curl install
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: $install_dir
# Set the app as temporarily public for curl call
ynh_script_progression "Configuring SSOwat..."
# Reload SSOwat config
yunohost app ssowatconf
# Installation with curl
ynh_script_progression "Finalizing installation..."
install_sso
pushd $install_dir/protected
php$php_version yii migrate/up --includeModuleMigrations=1 --interactive=0
php$php_version yii settings/set ldap enabled '1'
php$php_version yii settings/set ldap hostname 'localhost'
php$php_version yii settings/set ldap port 389
php$php_version yii settings/set ldap encryption ''
php$php_version yii settings/set ldap username ''
php$php_version yii settings/set ldap password ''
php$php_version yii settings/set ldap baseDn 'ou=users,dc=yunohost,dc=org'
php$php_version yii settings/set ldap loginFilter '(uid=%s)'
php$php_version yii settings/set ldap userFilter 'objectClass=mailAccount'
php$php_version yii settings/set ldap emailAttribute 'mail'
php$php_version yii settings/set ldap usernameAttribute 'uid'
php$php_version yii settings/set ldap idAttribute 'uid'
php$php_version yii settings/set ldap refreshUsers '1'
php$php_version yii settings/set ldap refreshUsers '1'
php$php_version yii ldap/sync
php$php_version yii user/make-admin ${admin}
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"
php$php_version yii settings/set user auth.anonymousRegistration '0'
php$php_version yii settings/set user auth.allowGuestAccess '0'
php$php_version yii settings/set user auth.internalUsersCanInvite '0'
php$php_version yii module/enable auth-basic
popd
ynh_store_file_checksum "$install_dir/protected/config/common.php"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
#=================================================
# SETUP CRON CONFIGURATION
#=================================================
ynh_script_progression "Setuping crontab..."
ynh_config_add --template="cron" --destination="/etc/cron.d/${app}"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Installation of $app completed"