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

Apply last example_ynh

This commit is contained in:
yalh76 2022-08-30 00:36:35 +02:00
parent 3c865af741
commit 1bd6804439
6 changed files with 97 additions and 91 deletions

View file

@ -1,9 +1,9 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER)
is_public=1 (PUBLIC|public=1|private=0)
domain="domain.tld"
path="/path"
is_public=1
admin="john"
; Checks
pkg_linter=1
setup_sub_dir=1
@ -16,6 +16,8 @@
upgrade=1 from_commit=83500d6e866539d56a0aed6f288a8a8ce02a674b
# 1.8.2~ynh3
upgrade=1 from_commit=50c74393ad4376bc18676b4be86fce74629ad60a
# 1.8.2~ynh4
upgrade=1 from_commit=7da020da5079b580cc2a418e2f6fb48f637a989a
backup_restore=1
multi_instance=1
port_already_use=0
@ -27,5 +29,3 @@ Notification=none
; commit=83500d6e866539d56a0aed6f288a8a8ce02a674b
name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&

View file

@ -26,7 +26,7 @@
"multi_instance": true,
"services": [
"nginx",
"php7.3-fpm",
"php7.4-fpm",
"mysql"
],
"arguments": {

View file

@ -4,9 +4,12 @@
# COMMON VARIABLES
#=================================================
YNH_PHP_VERSION="7.4"
YNH_PHP_VERSION=7.4
pkg_dependencies="php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-apcu-bc php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-ldap"
php_dependencies="php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-apcu-bc php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-ldap"
# dependencies used by the app (must be on a single line)
pkg_dependencies="$php_dependencies"
HUMHUB_AUTH_BASIC_VERSION=0.1.0
HUMHUB_AUTH_BASIC_PATH="/protected/modules/auth-basic"

View file

@ -55,7 +55,7 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
@ -149,25 +149,25 @@ ynh_script_progression --message="Finalizing installation..." --weight=2
install_sso
pushd $final_path/protected
php${YNH_PHP_VERSION} yii migrate/up --includeModuleMigrations=1 --interactive=0
php$phpversion yii migrate/up --includeModuleMigrations=1 --interactive=0
php${YNH_PHP_VERSION} yii settings/set ldap enabled '1'
php${YNH_PHP_VERSION} yii settings/set ldap hostname 'localhost'
php${YNH_PHP_VERSION} yii settings/set ldap port 389
php${YNH_PHP_VERSION} yii settings/set ldap encryption ''
php${YNH_PHP_VERSION} yii settings/set ldap username ''
php${YNH_PHP_VERSION} yii settings/set ldap password ''
php${YNH_PHP_VERSION} yii settings/set ldap baseDn 'ou=users,dc=yunohost,dc=org'
php${YNH_PHP_VERSION} yii settings/set ldap loginFilter '(uid=%s)'
php${YNH_PHP_VERSION} yii settings/set ldap userFilter 'objectClass=mailAccount'
php${YNH_PHP_VERSION} yii settings/set ldap emailAttribute 'mail'
php${YNH_PHP_VERSION} yii settings/set ldap usernameAttribute 'uid'
php${YNH_PHP_VERSION} yii settings/set ldap idAttribute 'uid'
php${YNH_PHP_VERSION} yii settings/set ldap refreshUsers '1'
php${YNH_PHP_VERSION} yii settings/set ldap refreshUsers '1'
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${YNH_PHP_VERSION} yii ldap/sync
php${YNH_PHP_VERSION} yii user/make-admin ${admin}
php$phpversion yii ldap/sync
php$phpversion yii user/make-admin ${admin}
ynh_local_curl "/index.php?r=installer/index/go"
@ -181,11 +181,11 @@ pushd $final_path/protected
local_curl_csrf "/index.php?r=installer/config/sample-data" \
"SampleDataForm[sampleData]=0"
php${YNH_PHP_VERSION} yii settings/set user auth.anonymousRegistration '0'
php${YNH_PHP_VERSION} yii settings/set user auth.allowGuestAccess '0'
php${YNH_PHP_VERSION} yii settings/set user auth.internalUsersCanInvite '0'
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'
php${YNH_PHP_VERSION} yii module/enable auth-basic
php$phpversion yii module/enable auth-basic
popd
@ -194,20 +194,17 @@ ynh_permission_update --permission="main" --remove="visitors"
ynh_store_file_checksum --file="$final_path/protected/config/common.php"
#=================================================
# SETUP CRON CONFIGURATION
#=================================================
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/${app}"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# SETUP CRON CONFIGURATION
#=================================================
ynh_script_progression --message="Setuping crontab..." --weight=1
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/${app}"
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -68,7 +68,7 @@ chown -R $app:www-data "$final_path"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
@ -99,7 +99,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app"

View file

@ -94,26 +94,12 @@ then
# Delete old source
ynh_secure_remove --file="$final_path.old"
if [[ ! -d $final_path/$HUMHUB_AUTH_BASIC_PATH ]]; then
install_sso
pushd $final_path/protected
php${YNH_PHP_VERSION} yii module/enable auth-basic
popd
else
current_version=$(cat $final_path/$HUMHUB_AUTH_BASIC_PATH/module.json | jq -j '.version')
if [ "$current_version" != "$HUMHUB_AUTH_BASIC_VERSION" ]; then
ynh_secure_remove $final_path/$HUMHUB_AUTH_BASIC_PATH
install_sso
fi
fi
fi
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
@ -124,6 +110,7 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# NGINX CONFIGURATION
@ -146,6 +133,29 @@ ynh_replace_string --match_string="defined('YII_ENV') or define('YII_ENV', 'dev'
--replace_string="// defined('YII_ENV') or define('YII_ENV', 'dev');"\
--target_file="$final_path/index.php"
#=================================================
# SETUP APPLICATION
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Setuping application..." --weight=1
if [[ ! -d $final_path/$HUMHUB_AUTH_BASIC_PATH ]]; then
install_sso
pushd $final_path/protected
php$phpversion yii module/enable auth-basic
popd
else
current_version=$(cat $final_path/$HUMHUB_AUTH_BASIC_PATH/module.json | jq -j '.version')
if [ "$current_version" != "$HUMHUB_AUTH_BASIC_VERSION" ]; then
ynh_secure_remove $final_path/$HUMHUB_AUTH_BASIC_PATH
install_sso
fi
fi
fi
#=================================================
# MIGRATE DATABASE
#=================================================
@ -153,30 +163,26 @@ ynh_script_progression --message="Migrating database..." --weight=1
chown -R $app $final_path/
sudo -u $app /usr/bin/php$YNH_PHP_VERSION $final_path/protected/yii migrate/up --includeModuleMigrations=1
sudo -u $app /usr/bin/php$phpversion $final_path/protected/yii migrate/up --includeModuleMigrations=1
#=================================================
# UPDATE MODULES
#=================================================
ynh_script_progression --message="Updating modules..." --weight=1
sudo -u $app /usr/bin/php$YNH_PHP_VERSION $final_path/protected/yii module/update-all
#=================================================
# REINSTALL CRONTAB
#=================================================
ynh_script_progression --message="Upgrading crontab..." --weight=1
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/${app}"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
sudo -u $app /usr/bin/php$phpversion $final_path/protected/yii module/update-all
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# UPGRADE CRONTAB
#=================================================
ynh_script_progression --message="Upgrading crontab..." --weight=1
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/${app}"
#=================================================
# GENERIC FINALIZATION
#=================================================