diff --git a/scripts/_common.sh b/scripts/_common.sh index 7123bfb..47bdf5a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,6 +8,9 @@ YNH_PHP_VERSION="7.3" extra_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" +HUMHUB_AUTH_BASIC_VERSION=0.1.0 +HUMHUB_AUTH_BASIC_PATH="/protected/modules/auth-basic" + #================================================= # PERSONAL HELPERS #================================================= @@ -70,6 +73,19 @@ myynh_urlencode() { return 0 } +enable_sso() { + tmp_auth_basic_module="$(mktemp /tmp/humhub_ynh.XXXXXX)" + wget -q -O $tmp_auth_basic_module "https://github.com/smart4life/humhub-auth-basic/archive/refs/tags/$HUMHUB_AUTH_BASIC_VERSION.tar.gz" + + tar xf $tmp_auth_basic_module -C $final_path/protected/modules + mv $final_path/protected/modules/humhub-auth-basic* $final_path/$HUMHUB_AUTH_BASIC_PATH + + pushd $final_path/protected/ + php${YNH_PHP_VERSION} yii module/enable auth-basic + popd + rm -rf $tmp_auth_basic_module +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 9f2bc78..2446443 100644 --- a/scripts/install +++ b/scripts/install @@ -175,6 +175,8 @@ pushd $final_path/protected popd +enable_sso + # Remove the public access ynh_permission_update --permission="main" --remove="visitors" diff --git a/scripts/upgrade b/scripts/upgrade index bcd484c..60d5694 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -84,6 +84,16 @@ then # Delete old source ynh_secure_remove --file="$final_path.old" + + if [[ ! -d $final_path/$HUMHUB_AUTH_BASIC_PATH ]]; then + enable_sso + else + current_version=$(cat $final_path/$HUMHUB_AUTH_BASIC_PATH/module.json | jq -j '.version') + if [ "$current_version" != "$HUMHUB_AUTH_BASIC_VERSION" ]; then + rm -rf $final_path/$HUMHUB_AUTH_BASIC_PATH + enable_sso + fi + fi fi #=================================================