From 7de0fedb0cbb3f2882229733e5f5555bbc9d0428 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 12 Feb 2024 13:22:40 +0100 Subject: [PATCH] some cleanings --- conf/variables.env | 25 ++++++------- manifest.toml | 9 +---- scripts/install | 33 ++++------------ scripts/upgrade | 93 +++++++++++++++++++--------------------------- 4 files changed, 57 insertions(+), 103 deletions(-) diff --git a/conf/variables.env b/conf/variables.env index 8b2aabe..436328d 100644 --- a/conf/variables.env +++ b/conf/variables.env @@ -4,7 +4,6 @@ SHARELATEX_PORT=__PORT__ SHARELATEX_CONFIG="__INSTALL_DIR__/settings.js" ADMIN_PRIVILEGE_AVAILABLE=true OPTIMISE_PDF=true -SHARELATEX_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING=true NODE_ENV=production LOG_LEVEL=info @@ -54,9 +53,9 @@ OVERLEAF_EMAIL_FROM_ADDRESS=__APP__@__DOMAIN__ # SHARELATEX_EMAIL_AWS_SES_ACCESS_KEY_ID= # SHARELATEX_EMAIL_AWS_SES_SECRET_KEY= -OVERLEAF_EMAIL_SMTP_HOST=localhost +OVERLEAF_EMAIL_SMTP_HOST=__MAIN_DOMAIN__ OVERLEAF_EMAIL_SMTP_PORT=587 -OVERLEAF_EMAIL_SMTP_SECURE=true +# OVERLEAF_EMAIL_SMTP_SECURE=true OVERLEAF_EMAIL_SMTP_USER=__APP__ OVERLEAF_EMAIL_SMTP_PASS=__MAIL_PWD__ OVERLEAF_EMAIL_SMTP_NAME=__APP__@__DOMAIN__ @@ -71,8 +70,6 @@ OT_JWT_AUTH_KEY=__JWT_KEY__ ## Server Pro ## ################ -OVERLEAF_IS_SERVER_PRO=true - #LDAP_SERVER=ldap://localhost:389 #LDAP_BASE=ou=users,dc=yunohost,dc=org #LDAP_BINDDN=uid=%u,ou=users,dc=yunohost,dc=org @@ -82,16 +79,16 @@ OVERLEAF_IS_SERVER_PRO=true #LDAP_CONTACT_FILTER='(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org)' #LDAP_CONTACTS=false -EXTERNAL_AUTH=ldap -OVERLEAF_LDAP_URL=ldap://localhost:389 -OVERLEAF_LDAP_SEARCH_BASE=ou=users,dc=yunohost,dc=org -OVERLEAF_LDAP_SEARCH_FILTER="(uid={{username}})" +# EXTERNAL_AUTH=ldap +# OVERLEAF_LDAP_URL=ldap://localhost:389 +# OVERLEAF_LDAP_SEARCH_BASE=ou=users,dc=yunohost,dc=org +# OVERLEAF_LDAP_SEARCH_FILTER="(uid={{username}})" # OVERLEAF_LDAP_BIND_DN='' # OVERLEAF_LDAP_BIND_CREDENTIALS='' -OVERLEAF_LDAP_EMAIL_ATT=mail -OVERLEAF_LDAP_NAME_ATT=cn -OVERLEAF_LDAP_LAST_NAME_ATT=sn -OVERLEAF_LDAP_UPDATE_USER_DETAILS_ON_LOGIN=true +# OVERLEAF_LDAP_EMAIL_ATT=mail +# OVERLEAF_LDAP_NAME_ATT=cn +# OVERLEAF_LDAP_LAST_NAME_ATT=sn +# OVERLEAF_LDAP_UPDATE_USER_DETAILS_ON_LOGIN=true # OVERLEAF_TEMPLATES_USER_ID=578773160210479700917ee5 # OVERLEAF_NEW_PROJECT_TEMPLATE_LINKS=[{"name":"All Templates","url":"/templates/all"}] @@ -99,4 +96,4 @@ OVERLEAF_LDAP_UPDATE_USER_DETAILS_ON_LOGIN=true # TEX_LIVE_DOCKER_IMAGE=quay.io/sharelatex/texlive-full:2021.1 # ALL_TEX_LIVE_DOCKER_IMAGES=quay.io/sharelatex/texlive-full:2021.1,quay.io/sharelatex/texlive-full:2020.1 -OVERLEAF_PROXY_LEARN=true +# OVERLEAF_PROXY_LEARN=true diff --git a/manifest.toml b/manifest.toml index b7f5e47..4f9d092 100644 --- a/manifest.toml +++ b/manifest.toml @@ -54,13 +54,6 @@ ram.runtime = "50M" url = "https://github.com/overleaf/overleaf/archive/ea4d63876aec15eea2b65923574d41a066b71477.tar.gz" sha256 = "9c9cbae9db51b9da7de06a4486fc8e676ead6336732ea5057c0008821003642a" autoupdate.stategy = "latest_github_commit" - - # [resources.sources.ldap] - # url = "https://github.com/smhaller/ldap-overleaf-sl/archive/38887b9a152a7f35de1637789179ca1b60a63143.tar.gz" - # sha256 = "dc09531ee2dac273e3122a78dbcc3fedee4c90fcdac55a5dffe540247b5e5449" - # in_subdir = 2 - # autoupdate.strategy = "latest_github_tag" - [resources.system_user] allow_email = true @@ -68,7 +61,7 @@ ram.runtime = "50M" [resources.install_dir] [resources.data_dir] - subdirs = [ "compiles", "output", "cache", "user_files", "template_files" ] + subdirs = [ "compiles", "output", "cache", "user_files", "template_files", "history" ] [resources.permissions] main.url = "/" diff --git a/scripts/install b/scripts/install index 99ff83a..5c73b54 100755 --- a/scripts/install +++ b/scripts/install @@ -20,6 +20,9 @@ ynh_app_setting_set --app=$app --key=web_api_password --value=$web_api_password jwt_key=$(ynh_string_random --length=45 | base64) ynh_app_setting_set --app=$app --key=jwt_key --value=$jwt_key +// Retrieve YunoHost main domain for mails to work +$main_domain = exec('cat /etc/yunohost/current_host'); + #================================================= # STANDARD MODIFICATIONS #================================================= @@ -49,7 +52,10 @@ ynh_script_progression --message="Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/build" -#ynh_setup_source --dest_dir="$install_dir/build_ldap" --source_id="ldap" + +mkdir -p $install_dir/tmp +mkdir -p $install_dir/tmp/{projectHistories,dumpFolder,uploads} + chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" @@ -107,28 +113,7 @@ ynh_add_config --template="../conf/production.json" --destination="$install_dir/ ynh_add_config --template="../conf/production.json" --destination="$install_dir/live/services/history-v1/config/production.json" cp "$install_dir/build/server-ce/config/custom-environment-variables.json" "$install_dir/live/services/history-v1/config/" - - -#patch files for LDAP integration -#patch "$install_dir/live/services/web/app/src/Features/Authentication/AuthenticationController.js" "$install_dir/build_ldap/sharelatex_diff/AuthenticationController.js.diff" -#patch "$install_dir/live/services/web/app/src/Features/Authentication/AuthenticationManager.js" "$install_dir/build_ldap/sharelatex_diff/AuthenticationManager.js.diff" -#patch "$install_dir/live/services/web/app/src/Features/Contacts/ContactController.js" "$install_dir/build_ldap/sharelatex_diff/ContactController.js.diff" -#patch "$install_dir/live/services/web/app/views/admin/index.pug" "$install_dir/build_ldap/sharelatex_diff/admin-index.pug.diff" -#patch "$install_dir/live/services/web/app/views/admin/index.pug" "$install_dir/build_ldap/sharelatex_diff/admin-sysadmin.pug.diff" -#patch "$install_dir/live/services/web/app/views/user/login.pug" "$install_dir/build_ldap/sharelatex_diff/login.pug.diff" -#patch "$install_dir/live/services/web/app/views/layout/navbar-marketing.pug" "$install_dir/build_ldap/sharelatex_diff/navbar-marketing.pug.diff" -#patch "$install_dir/live/services/web/app/views/layout/navbar.pug" "$install_dir/build_ldap/sharelatex_diff/navbar.pug.diff" -#patch "$install_dir/live/services/web/app/src/router.js" "$install_dir/build_ldap/sharelatex_diff/router.js.diff" -#patch "$install_dir/live/services/web/app/views/user/settings.pug" "$install_dir/build_ldap/sharelatex_diff/settings.pug.diff" -#sed -iE '/type=.*email.*/d' $install_dir/live/services/web/app/views/user/login.pug -#sed -iE "s/email@example.com/${login_text:-user}/g" $install_dir/live/services/web/app/views/user/login.pug -#sed -iE '/email@example.com/{n;N;N;d}' $install_dir/live/services/web/app/views/user/login.pug -#sed -iE "s%-synctex=1\",%-synctex=1\", \"-shell-escape\",%g" $install_dir/live/services/clsi/app/js/LatexRunner.js -#sed -iE "s%'-synctex=1',%'-synctex=1', '-shell-escape',%g" $install_dir/live/services/clsi/app/js/LatexRunner.js -#touch "$install_dir/live/services/web/app/views/project/editor/review-panel.pug" - ynh_secure_remove --file="$install_dir/build" -#ynh_secure_remove --file="$install_dir/build_ldap" ynh_script_progression --message="Building app..." pushd "$install_dir/live" @@ -138,10 +123,6 @@ popd pushd "$install_dir/live/services/web" ynh_exec_warn_less npm run webpack:production - #ynh_exec_warn_less npm install ldap-escape - #ynh_exec_warn_less npm install ldapts-search - #ynh_exec_warn_less npm install ldapts - #ynh_exec_warn_less npm install ldap-escape ynh_secure_remove --file="$install_dir/live/services/web/node_modules/.cache" popd diff --git a/scripts/upgrade b/scripts/upgrade index a8c6138..7559b4e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -36,6 +36,12 @@ ynh_systemd_action --service_name="$app-real-time" --action="stop" --log_path="/ ynh_systemd_action --service_name="$app-spelling" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app-web" --action="stop" --log_path="/var/log/$app/$app.log" +if ynh_exec_warn_less yunohost service status "$app-track-changes" >/dev/null +then + ynh_script_progression --message="Removing $app-track-changes service integration..." + yunohost service remove "$app-track-changes" +fi + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -51,7 +57,6 @@ then # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/build" - #ynh_setup_source --dest_dir="$install_dir/build_ldap" --source_id="ldap" fi chmod 750 "$install_dir" @@ -95,67 +100,45 @@ chown $app:$app "$install_dir/settings.js" #================================================= # BUILDING APP #================================================= +ynh_script_progression --message="Preparing app..." -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Building app..." +mkdir -p "$install_dir/live" +cp "$install_dir/build/server-ce/genScript.js" "$install_dir/live/genScript.js" +cp "$install_dir/build/server-ce/services.js" "$install_dir/live/services.js" +cp "$install_dir/build/package.json" "$install_dir/live/package.json" +cp "$install_dir/build/package-lock.json" "$install_dir/live/package-lock.json" +cp -r "$install_dir/build/libraries/" "$install_dir/live/libraries/" +cp -r "$install_dir/build/services/" "$install_dir/live/services/" +cp -r "$install_dir/build/patches/" "$install_dir/live/patches/" +cp -r "$install_dir/build/server-ce/config" "$install_dir/config/" +ynh_secure_remove --file="$install_dir/config/settings.js" - ynh_secure_remove --file="$install_dir/live" - mkdir -p "$install_dir/live" - cp "$install_dir/build/server-ce/genScript.js" "$install_dir/live/genScript.js" - cp "$install_dir/build/server-ce/services.js" "$install_dir/live/services.js" - cp "$install_dir/build/package.json" "$install_dir/live/package.json" - cp "$install_dir/build/package-lock.json" "$install_dir/live/package-lock.json" - cp -r "$install_dir/build/libraries/" "$install_dir/live/libraries/" - cp -r "$install_dir/build/services/" "$install_dir/live/services/" - cp -r "$install_dir/build/patches/" "$install_dir/live/patches/" - cp -r "$install_dir/build/server-ce/config" "$install_dir/config/" - ynh_secure_remove --file="$install_dir/config/settings.js" +ynh_add_config --template="../conf/production.json" --destination="$install_dir/build/server-ce/config/production.json" +ynh_add_config --template="../conf/production.json" --destination="$install_dir/live/services/history-v1/config/production.json" +cp "$install_dir/build/server-ce/config/custom-environment-variables.json" "$install_dir/live/services/history-v1/config/" +ynh_secure_remove --file="$install_dir/build" -# cp "$install_dir/build_ldap/ldap-overleaf-sl/sharelatex/AuthenticationManager.js" "$install_dir/live/services/web/app/src/Features/Authentication/AuthenticationManager.js" -# cp "$install_dir/build_ldap/ldap-overleaf-sl/sharelatex/ContactController.js" "$install_dir/live/services/web/app/src/Features/Contacts/ContactController.js" -# #sed -iE '/type=.*email.*/d' $install_dir/live/services/web/app/views/user/login.pug -# #sed -iE "s/email@example.com/${login_text:-user}/g" $install_dir/live/services/web/app/views/user/login.pug -# #sed -iE '/email@example.com/{n;N;N;d}' $install_dir/live/services/web/app/views/user/login.pug -# sed -iE "s%-synctex=1\",%-synctex=1\", \"-shell-escape\",%g" $install_dir/live/services/clsi/app/js/LatexRunner.js -# sed -iE "s%'-synctex=1',%'-synctex=1', '-shell-escape',%g" $install_dir/live/services/clsi/app/js/LatexRunner.js -# cp "$install_dir/build_ldap/ldap-overleaf-sl/sharelatex/settings.pug" "$install_dir/live/services/web/app/views/user/settings.pug" -# cp "$install_dir/build_ldap/ldap-overleaf-sl/sharelatex/navbar.pug" "$install_dir/live/services/web/app/views/layout/navbar.pug" -# cp "$install_dir/build_ldap/ldap-overleaf-sl/sharelatex/admin-sysadmin.pug" "$install_dir/live/services/web/app/views/admin/index.pug" -# ynh_secure_remove --file="$install_dir/live/services/web/app/views/project/editor/review-panel.pug" -# touch "$install_dir/live/services/web/app/views/project/editor/review-panel.pug" +ynh_script_progression --message="Building app..." +pushd "$install_dir/live" + ynh_use_nodejs + ynh_exec_warn_less npm ci +popd - ynh_secure_remove --file="$install_dir/build" -# ynh_secure_remove --file="$install_dir/build_ldap" +pushd "$install_dir/live/services/web" + ynh_exec_warn_less npm run webpack:production + ynh_secure_remove --file="$install_dir/live/services/web/node_modules/.cache" +popd - pushd "$install_dir/live" - ynh_use_nodejs - ynh_exec_warn_less $ynh_npm install -g sandboxed-module@latest - npm ci - popd +chmod 750 "$install_dir/live" +chmod -R o-rwx "$install_dir/live" +chown -R $app:www-data "$install_dir/live" +chown -R $app:www-data "$install_dir/config" - pushd "$install_dir/live/services/web" - ynh_exec_warn_less npm run webpack:production - ynh_exec_warn_less npm install -g npm - ynh_exec_warn_less npm install ldap-escape - ynh_exec_warn_less npm install ldapts-search - ynh_exec_warn_less npm install ldapts - ynh_exec_warn_less npm install ldap-escape - ynh_exec_warn_less npm cache clean --force - ynh_secure_remove --file="$install_dir/live/services/web/node_modules/.cache" - popd - - chmod 750 "$install_dir/live" - chmod -R o-rwx "$install_dir/live" - chown -R $app:www-data "$install_dir/live" - - mkdir -p "$install_dir/tmp/uploads" - - chmod 750 "$install_dir/tmp" - chmod -R o-rwx "$install_dir/tmp" - chown -R $app:www-data "$install_dir/tmp" -fi +mkdir -p "$install_dir/tmp/uploads" +chmod 750 "$install_dir/tmp" +chmod -R o-rwx "$install_dir/tmp" +chown -R $app:www-data "$install_dir/tmp" #================================================= # SETUP SYSTEMD