diff --git a/conf/.env b/conf/.env index f8eb9ff..bf9a919 100644 --- a/conf/.env +++ b/conf/.env @@ -2,4 +2,5 @@ ME_CONFIG_SITE_BASEURL=__PATH__ ME_CONFIG_BASICAUTH=false ME_CONFIG_BASICAUTH_USERNAME= ME_CONFIG_MONGODB_ENABLE_ADMIN=true +ME_CONFIG_SITE_SESSIONSECRET=SomeSecret6533 PORT=__PORT__ diff --git a/manifest.toml b/manifest.toml index 87d42dc..3b1e971 100644 --- a/manifest.toml +++ b/manifest.toml @@ -39,7 +39,7 @@ ram.runtime = "50M" [install.init_main_permission] type = "group" - default = false + default = "visitors" [install.mongo_version] ask.en = "Select the major version of Mongo to install or 'None' if already installed" diff --git a/scripts/_common.sh b/scripts/_common.sh index b818f0f..334340f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -13,6 +13,11 @@ nodejs_version=16 #================================================= # EXPERIMENTAL HELPERS #================================================= +_install_yarn () { + ynh_exec_as "$app" "$ynh_node_load_PATH" npm install yarn + ynh_yarn="$install_dir/node_modules/.bin/yarn" + alias ynh_yarn="$ynh_yarn" +} #================================================= # FUTURE OFFICIAL HELPERS diff --git a/scripts/install b/scripts/install index 483cab4..2086fa5 100755 --- a/scripts/install +++ b/scripts/install @@ -13,10 +13,15 @@ source /usr/share/yunohost/helpers #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing NodeJS..." --weight=3 +ynh_script_progression --message="Installing NodeJS & Yarn..." --weight=3 ynh_install_nodejs --nodejs_version="$nodejs_version" +pushd "$install_dir" + ynh_use_nodejs + _install_yarn +popd + # Install mongo server only if asked to if [ "$mongo_version" != "None" ]; then ynh_script_progression --message="Installing MongoDB..." --weight=3 @@ -46,12 +51,13 @@ chown "$app:$app" "$install_dir/.env" #================================================= # BUILD NODEJS CODE #================================================= -ynh_script_progression --message="Building NodeJS code and dependencies..." --weight=6 +ynh_script_progression --message="Building NodeJS code ..." --weight=6 -# Install Nodejs dependencies +# Build using Yarn pushd "$install_dir" ynh_use_nodejs - ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install + ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_yarn" install + ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" run build popd #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index d6d6637..64b53bf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,10 +22,15 @@ ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$a #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing NodeJS..." --weight=3 +ynh_script_progression --message="Installing NodeJS & Yarn" --weight=3 ynh_install_nodejs --nodejs_version="$nodejs_version" +pushd "$install_dir" + ynh_use_nodejs + _install_yarn +popd + # Install mongo server only if asked to if [ "$mongo_version" != "None" ]; then ynh_script_progression --message="Installing MongoDB..." --weight=3 @@ -57,10 +62,11 @@ chown "$app:$app" "$install_dir/.env" #================================================= ynh_script_progression --message="Building NodeJS code and dependencies..." --weight=6 -# Install Nodejs dependencies +# Build using Yarn pushd "$install_dir" ynh_use_nodejs - ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install + ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_yarn" install + ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" run build popd #================================================= diff --git a/scripts/ynh_mongo_db__2 b/scripts/ynh_mongo_db__2 index e1c17a6..cb7317b 100644 --- a/scripts/ynh_mongo_db__2 +++ b/scripts/ynh_mongo_db__2 @@ -314,17 +314,19 @@ ynh_install_mongo() { ynh_print_info --message="Installing MongoDB Community Edition ..." local mongo_debian_release=$(ynh_get_debian_release) + local mongo_packages="mongodb-org-server mongodb-database-tools mongodb-org-shell" if [[ $(cat /proc/cpuinfo) != *"avx"* && "$mongo_version" != "4.4" ]]; then ynh_print_warn --message="Installing Mongo 4.4 as $mongo_version is not compatible with your cpu (see https://docs.mongodb.com/manual/administration/production-notes/#x86_64)." mongo_version="4.4" fi - if [[ "$mongo_version" == "4.4" && "$mongo_debian_release" != "buster" ]]; then - ynh_print_warn --message="Switched to buster install as Mongo 4.4 is not compatible with $mongo_debian_release." + if [[ "$mongo_version" == "4.4" ]]; then + ynh_print_warn --message="Switching to buster package install for Mongo 4.4." mongo_debian_release=buster + mongo_packages="mongodb-org-server mongodb-database-tools mongodb-mongosh-shared-openssl11" fi - ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian $mongo_debian_release/mongodb-org/$mongo_version main" --package="mongodb-org mongodb-org-server mongodb-org-tools mongodb-mongosh" --key="https://www.mongodb.org/static/pgp/server-$mongo_version.asc" + ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian $mongo_debian_release/mongodb-org/$mongo_version main" --package="$mongo_packages" --key="https://www.mongodb.org/static/pgp/server-$mongo_version.asc" mongodb_servicename=mongod # Make sure MongoDB is started and enabled