1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/overleaf_ynh.git synced 2024-09-03 19:56:27 +02:00

first try fo v2

This commit is contained in:
Thomas 2023-11-19 17:01:44 +01:00 committed by GitHub
parent fd77397a23
commit b2a0747ccb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 395 additions and 816 deletions

View file

@ -1,22 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
is_public=1
language="fr"
admin="john"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
#upgrade=1 from_commit=CommitHash
backup_restore=1
multi_instance=0
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none

View file

@ -1,55 +0,0 @@
{
"name": "Overleaf",
"id": "overleaf",
"packaging_format": 1,
"description": {
"en": "Open-source online real-time collaborative LaTeX editor."
},
"version": "2022.04.23~ynh1",
"url": "https://www.overleaf.com",
"upstream": {
"license": "AGPL-3.0-or-later",
"website": "https://www.overleaf.com",
"userdoc": "https://www.overleaf.com/learn",
"code": "https://github.com/overleaf/overleaf"
},
"license": "AGPL-3.0-or-later",
"maintainer": {
"name": "",
"email": ""
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "is_public",
"type": "boolean",
"default": true
},
{
"name": "language",
"type": "string",
"ask": {
"en": "Choose the application language",
"fr": "Choisissez la langue de l'application"
},
"choices": ["fr", "en"],
"default": "fr"
},
{
"name": "admin",
"type": "user"
}
]
}
}

View file

@ -19,18 +19,17 @@ cpe = "???" # FIXME: optional but recommended if relevant, this is meant to cont
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
[integration] [integration]
yunohost = ">= 4.3.0" yunohost = ">= 11.2.0"
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] architectures = "all"
multi_instance = false multi_instance = false
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. ldap = true
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. sso = "?"
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... disk = "50M"
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... ram.build = "50M"
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... ram.runtime = "50M"
[install] [install]
[install.domain] [install.domain]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "domain" type = "domain"
[install.init_main_permission] [install.init_main_permission]
@ -40,23 +39,22 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen
[install.language] [install.language]
ask.en = "Choose the application language" ask.en = "Choose the application language"
ask.fr = "Choisissez la langue de l'application" ask.fr = "Choisissez la langue de l'application"
type = "string" type = "select"
choices = ["fr", "en"] choices = ["fr", "en"]
default = "fr" default = "fr"
[install.admin] [install.admin]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "user" type = "user"
[resources] [resources]
[resources.sources] [resources.sources]
[resources.sources.ldap] [resources.sources.ldap]
url = "https://github.com/smhaller/ldap-overleaf-sl/archive/a0e70e4f1f618a23503eb80a4e7cb1a93b568b40.tar.gz" url = "https://github.com/smhaller/ldap-overleaf-sl/archive/ba1e78f2a8032ac7c53847a6746daba6fc194ed6.zip"
sha256 = "18a3af6ee0f93aa20fa7c3f08da5264c5d052911a70a3edd4264fe929789e8f3" sha256 = "3df1ed8dbfb7953fc5cd18f59131f5fdacea35d0312b0c28c1f68fbfbe20954f"
[resources.sources.main] [resources.sources.main]
url = "https://github.com/overleaf/overleaf/archive/c90fafa8ac5cc5c40a2d61b1aba413a7f9102729.tar.gz" url = "https://github.com/overleaf/overleaf/archive/11ce29197bf239f9645aa8df198dd042659fe99d.zip"
sha256 = "322d906ad7bfda189cd8e6a68f6b0893f05d3085d87df9395e5af1a72964bbae" sha256 = "9bffc128d2a833090801566635ded4ced2a769b17921c9b19712ce841f17f80f"
[resources.system_user] [resources.system_user]
@ -67,9 +65,11 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen
[resources.permissions] [resources.permissions]
main.url = "/" main.url = "/"
auth_header = false
admin.allowed = "admins"
[resources.ports] [resources.ports]
main.default = 8095 main.default = 8095
[resources.apt] [resources.apt]
packages = "texlive, redis-server, latexmk, python3-pygments" packages = "texlive, texlive-xetex, redis-server, latexmk, python3-pygments"

View file

@ -4,10 +4,7 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app nodejs_version=20
#REMOVEME? pkg_dependencies="texlive redis-server latexmk python3-pygments"
nodejs_version=18
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
@ -17,6 +14,363 @@ nodejs_version=18
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================
#!/bin/bash
MONGO_DEBIAN_SERVICENAME="mongodb"
MONGO_CE_SERVICENAME="mongod"
MONGO_DEBIAN_DEPENDENCIES="mongodb mongodb-server mongo-tools"
MONGO_CE_DEPENDENCIES="mongodb-org mongodb-org-server mongodb-org-tools"
MONGO_DEBIAN_CONFIG="/etc/mongodb.conf"
MONGO_CE_CONFIG="/etc/mongod.conf"
MONGO_CE_REPO="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main"
MONGO_CE_KEY="https://www.mongodb.org/static/pgp/server-4.4.asc"
# Execute a mongo command
#
# example: ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("wekan")'
# example: ynh_mongo_exec --command="db.getMongo().getDBNames().indexOf(\"wekan\")"
#
# usage: ynh_mongo_exec [--user=user] [--password=password] [--authenticationdatabase=authenticationdatabase] [--database=database] [--host=host] [--port=port] --command="command" [--eval]
# | arg: -u, --user= - The user name to connect as
# | arg: -p, --password= - The user password
# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to
# | arg: -d, --database= - The database to connect to
# | arg: -h, --host= - The host to connect to
# | arg: -P, --port= - The port to connect to
# | arg: -c, --command= - The command to evaluate
# | arg: -e, --eval - Evaluate instead of execute the command.
#
#
ynh_mongo_exec() {
# Declare an array to define the options of this helper.
local legacy_args=upadhPce
local -A args_array=( [u]=user= [p]=password= [a]=authenticationdatabase= [d]=database= [h]=host= [P]=port= [c]=command= [e]=eval )
local user
local password
local authenticationdatabase
local database
local host
local port
local command
local eval
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
user="${user:-}"
password="${password:-}"
authenticationdatabase="${authenticationdatabase:-}"
database="${database:-}"
host="${host:-}"
port="${port:-}"
eval=${eval:-0}
# If user is provided
if [ -n "$user" ]
then
user="--username=$user"
# If password is provided
if [ -n "$password" ]
then
password="--password=$password"
fi
# If authenticationdatabase is provided
if [ -n "$authenticationdatabase" ]
then
authenticationdatabase="--authenticationDatabase=$authenticationdatabase"
else
authenticationdatabase="--authenticationDatabase=admin"
fi
else
password=""
authenticationdatabase=""
fi
# If host is provided
if [ -n "$host" ]
then
host="--host=$host"
fi
# If port is provided
if [ -n "$port" ]
then
port="--port=$port"
fi
# If eval is not provided
if [ $eval -eq 0 ]
then
# If database is provided
if [ -n "$database" ]
then
database="use $database"
else
database=""
fi
mongo --quiet $user $password $authenticationdatabase $host $port <<EOF
$database
${command}
quit()
EOF
else
# If database is provided
if [ -n "$database" ]
then
database="$database"
else
database=""
fi
mongo --quiet $database $user $password $authenticationdatabase $host $port --eval="$command"
fi
}
# Drop a database
#
# [internal]
#
# If you intend to drop the database *and* the associated user,
# consider using ynh_mongo_remove_db instead.
#
# usage: ynh_mongo_drop_db --database=database
# | arg: -d, --database= - The database name to drop
#
#
ynh_mongo_drop_db() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=( [d]=database= )
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
ynh_mongo_exec --database="$database" --command='db.runCommand({dropDatabase: 1})'
}
# Dump a database
#
# example: ynh_mongo_dump_db --database=wekan > ./dump.bson
#
# usage: ynh_mongo_dump_db --database=database
# | arg: -d, --database= - The database name to dump
# | ret: the mongodump output
#
#
ynh_mongo_dump_db() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=( [d]=database= )
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
mongodump --quiet --db="$database" --archive
}
# Create a user
#
# [internal]
#
# usage: ynh_mongo_create_user --db_user=user --db_pwd=pwd --db_name=name
# | arg: -u, --db_user= - The user name to create
# | arg: -p, --db_pwd= - The password to identify user by
# | arg: -n, --db_name= - Name of the database to grant privilegies
#
#
ynh_mongo_create_user() {
# Declare an array to define the options of this helper.
local legacy_args=unp
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
local db_user
local db_name
local db_pwd
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# Create the user and set the user as admin of the db
ynh_mongo_exec --database="$db_name" --command='db.createUser( { user: "'${db_user}'", pwd: "'${db_pwd}'", roles: [ { role: "readWrite", db: "'${db_name}'" } ] } );'
# Add clustermonitoring rights
ynh_mongo_exec --database="$db_name" --command='db.grantRolesToUser("'${db_user}'",[{ role: "clusterMonitor", db: "admin" }]);'
}
# Check if a mongo database exists
#
# usage: ynh_mongo_database_exists --database=database
# | arg: -d, --database= - The database for which to check existence
# | exit: Return 1 if the database doesn't exist, 0 otherwise
#
#
ynh_mongo_database_exists() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=([d]=database=)
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")' --eval) -lt 0 ]
then
return 1
else
return 0
fi
}
# Restore a database
#
# example: ynh_mongo_restore_db --database=wekan < ./dump.bson
#
# usage: ynh_mongo_restore_db --database=database
# | arg: -d, --database= - The database name to restore
#
#
ynh_mongo_restore_db() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=( [d]=database= )
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
mongorestore --quiet --db="$database" --archive
}
# Drop a user
#
# [internal]
#
# usage: ynh_mongo_drop_user --db_user=user --db_name=name
# | arg: -u, --db_user= - The user to drop
# | arg: -n, --db_name= - Name of the database
#
#
ynh_mongo_drop_user() {
# Declare an array to define the options of this helper.
local legacy_args=un
local -A args_array=( [u]=db_user= [n]=db_name= )
local db_user
local db_name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
ynh_mongo_exec --database="$db_name" --command='db.dropUser("'$db_user'", {w: "majority", wtimeout: 5000})'
}
# Create a database, an user and its password. Then store the password in the app's config
#
# usage: ynh_mongo_setup_db --db_user=user --db_name=name [--db_pwd=pwd]
# | arg: -u, --db_user= - Owner of the database
# | arg: -n, --db_name= - Name of the database
# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated
#
# After executing this helper, the password of the created database will be available in $db_pwd
# It will also be stored as "mongopwd" into the app settings.
#
#
ynh_mongo_setup_db() {
# Declare an array to define the options of this helper.
local legacy_args=unp
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
local db_user
local db_name
db_pwd=""
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local new_db_pwd=$(ynh_string_random) # Generate a random password
# If $db_pwd is not provided, use new_db_pwd instead for db_pwd
db_pwd="${db_pwd:-$new_db_pwd}"
# Create the user and grant access to the database
ynh_mongo_create_user --db_user="$db_user" --db_pwd="$db_pwd" --db_name="$db_name"
# Store the password in the app's config
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
}
# Remove a database if it exists, and the associated user
#
# usage: ynh_mongo_remove_db --db_user=user --db_name=name
# | arg: -u, --db_user= - Owner of the database
# | arg: -n, --db_name= - Name of the database
#
#
ynh_mongo_remove_db() {
# Declare an array to define the options of this helper.
local legacy_args=un
local -A args_array=( [u]=db_user= [n]=db_name= )
local db_user
local db_name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
if ynh_mongo_database_exists --database=$db_name; then # Check if the database exists
ynh_mongo_drop_db --database=$db_name # Remove the database
else
ynh_print_warn --message="Database $db_name not found"
fi
# Remove mongo user if it exists
ynh_mongo_drop_user --db_user=$db_user --db_name=$db_name
}
# Install MongoDB and integrate MongoDB service in YunoHost
#
# usage: ynh_install_mongo
#
#
ynh_install_mongo() {
ynh_print_info --message="Installing MongoDB..."
# Define Mongo Service Name
if dpkg --compare-versions $(cat /etc/debian_version) ge 10.0
then
ynh_print_info --message="Installing MongoDB Community Edition..."
ynh_install_extra_app_dependencies --repo="$MONGO_CE_REPO" --package="$MONGO_CE_DEPENDENCIES" --key="$MONGO_CE_KEY"
MONGODB_SERVICENAME=$MONGO_CE_SERVICENAME
else
ynh_print_info --message="Installing MongoDB Debian..."
ynh_install_app_dependencies $MONGO_DEBIAN_DEPENDENCIES
MONGODB_SERVICENAME=$MONGO_DEBIAN_SERVICENAME
fi
mongodb_servicename=$MONGODB_SERVICENAME
# Make sure MongoDB is started and enabled
systemctl is-enabled $MONGODB_SERVICENAME -q || systemctl enable $MONGODB_SERVICENAME --quiet
systemctl is-active $MONGODB_SERVICENAME -q || ynh_systemd_action --service_name=$MONGODB_SERVICENAME --action=restart --line_match="aiting for connections" --log_path="/var/log/mongodb/$MONGODB_SERVICENAME.log"
# Integrate MongoDB service in YunoHost
yunohost service add $MONGODB_SERVICENAME --description="MongoDB daemon" --log="/var/log/mongodb/$MONGODB_SERVICENAME.log"
}
# Remove MongoDB
# Only remove the MongoDB service integration in YunoHost for now
# if MongoDB package as been removed
#
# usage: ynh_remove_mongo
#
#
ynh_remove_mongo() {
# Only remove the mongodb service if it is not installed.
if ! ynh_package_is_installed --package="mongodb*"
then
ynh_print_info --message="Removing MongoDB service..."
# Define Mongo Service Name
if [ "$(lsb_release --codename --short)" = "buster" ]; then
MONGODB_SERVICENAME=$MONGO_CE_SERVICENAME
else
MONGODB_SERVICENAME=$MONGO_DEBIAN_SERVICENAME
fi
# Remove the mongodb service
yunohost service remove $MONGODB_SERVICENAME
# ynh_secure_remove --file=$MONGO_ROOT_PWD_FILE
fi
}
#================================================= #=================================================
# FUTURE OFFICIAL HELPERS # FUTURE OFFICIAL HELPERS
#================================================= #=================================================

View file

@ -8,31 +8,8 @@
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source ../settings/scripts/ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
#REMOVEME? ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_print_info --message="Loading installation settings..."
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================

View file

@ -9,70 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
#REMOVEME? old_path=$YNH_APP_OLD_PATH
#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
#REMOVEME? new_path="/"
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
#REMOVEME? # Needed for helper "ynh_add_nginx_config"
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
# Add settings here as needed by your application
#REMOVEME? language=$(ynh_app_setting_get --app=$app --key=language)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_user=$db_name
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
#REMOVEME? web_api_password=$(ynh_app_setting_get --app=$app --key=web_api_password)
#REMOVEME? crypto_random=$(ynh_app_setting_get --app=$app --key=crypto_random)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
#REMOVEME? ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
#REMOVEME? ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
#REMOVEME? change_domain=0
#REMOVEME? if [ "$old_domain" != "$new_domain" ]
then
#REMOVEME? change_domain=1
fi
#REMOVEME? change_path=0
#REMOVEME? if [ "$old_path" != "$new_path" ]
then
#REMOVEME? change_path=1
fi
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
@ -99,37 +35,13 @@ ynh_script_progression --message="Updating NGINX web server configuration..."
ynh_change_url_nginx_config ynh_change_url_nginx_config
#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
#REMOVEME? domain="$old_domain"
#REMOVEME? path="$new_path"
# Create a dedicated NGINX config
#REMOVEME? ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression --message="Updating a configuration file..."
#REMOVEME?
domain=$new_domain domain=$new_domain
path=$new_path path=$new_path
@ -161,13 +73,6 @@ ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/
ynh_systemd_action --service_name="$app-track-changes" --action="start" --log_path="/var/log/$app/track-changes.log" --line_match="listening on" ynh_systemd_action --service_name="$app-track-changes" --action="start" --log_path="/var/log/$app/track-changes.log" --line_match="listening on"
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="listening on" ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="listening on"
#=================================================
# RELOAD NGINX
#=================================================
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -7,94 +7,39 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
#REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
path="/"
#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
#REMOVEME? language=$YNH_APP_ARG_LANGUAGE
#REMOVEME? admin=$YNH_APP_ARG_ADMIN
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
web_api_password=$(ynh_string_random --length=32 | base64 -w 0 | rev | cut -b 2- | rev | tr -d '\n+/') web_api_password=$(ynh_string_random --length=32 | base64 -w 0 | rev | cut -b 2- | rev | tr -d '\n+/')
crypto_random=$(ynh_string_random --length=32 | base64 -w 0 | rev | cut -b 2- | rev | tr -d '\n+/') crypto_random=$(ynh_string_random --length=32 | base64 -w 0 | rev | cut -b 2- | rev | tr -d '\n+/')
admin_mail=$(ynh_user_get_info --username=$admin --key=mail) admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
#REMOVEME? ynh_script_progression --message="Validating installation parameters..."
#REMOVEME? install_dir=/var/www/$app
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
# Register (book) web path
#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
#REMOVEME? ynh_script_progression --message="Storing installation settings..."
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=language --value=$language
#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin
#REMOVEME? ynh_app_setting_set --app=$app --key=web_api_password --value=$web_api_password
ynh_app_setting_set --app=$app --key=crypto_random --value=$crypto_random ynh_app_setting_set --app=$app --key=crypto_random --value=$crypto_random
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
#REMOVEME? ynh_script_progression --message="Finding an available port..."
# Find an available port
#REMOVEME? port=$(ynh_find_port --port=8095)
#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
#REMOVEME? ynh_script_progression --message="Installing dependencies..."
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies # Upgrade NPM
ynh_npm install --global npm@latest
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_mongo ynh_install_mongo
#=================================================
# CREATE DEDICATED USER
#=================================================
#REMOVEME? ynh_script_progression --message="Configuring system user..."
# Create a system user
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#================================================= #=================================================
# CREATE A MONGODB DATABASE # CREATE A MONGODB DATABASE
#================================================= #=================================================
ynh_script_progression --message="Creating a MongoDB database..." ynh_script_progression --message="Creating a MongoDB database..."
#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) db_name=$(ynh_sanitize_dbid --db_name=$app)
#REMOVEME? db_user=$db_name db_user=$db_name
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
@ -102,7 +47,6 @@ ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." ynh_script_progression --message="Setting up source files..."
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
# Download, check integrity, uncompress and patch the source from app.src # 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"
ynh_setup_source --dest_dir="$install_dir/build_ldap" --source_id="ldap" ynh_setup_source --dest_dir="$install_dir/build_ldap" --source_id="ldap"
@ -126,11 +70,6 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Creating a data directory..." ynh_script_progression --message="Creating a data directory..."
#REMOVEME? data_dir=/home/yunohost.app/$app
#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
mkdir -p $data_dir
chmod 750 "$data_dir" chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir" chmod -R o-rwx "$data_dir"
chown -R $app:www-data "$data_dir" chown -R $app:www-data "$data_dir"
@ -171,12 +110,12 @@ sed -iE "s%'-synctex=1',%'-synctex=1', '-shell-escape',%g" $install_dir/live/ser
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/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/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" cp "$install_dir/build_ldap/ldap-overleaf-sl/sharelatex/admin-sysadmin.pug" "$install_dir/live/services/web/app/views/admin/index.pug"
#REMOVEME? ynh_secure_remove --file="$install_dir/live/services/web/app/views/admin/register.pug" ynh_secure_remove --file="$install_dir/live/services/web/app/views/admin/register.pug"
#REMOVEME? ynh_secure_remove --file="$install_dir/live/services/web/app/views/project/editor/review-panel.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" touch "$install_dir/live/services/web/app/views/project/editor/review-panel.pug"
#REMOVEME? ynh_secure_remove --file="$install_dir/build" ynh_secure_remove --file="$install_dir/build"
#REMOVEME? ynh_secure_remove --file="$install_dir/build_ldap" ynh_secure_remove --file="$install_dir/build_ldap"
pushd "$install_dir/live" pushd "$install_dir/live"
ynh_use_nodejs ynh_use_nodejs
@ -192,7 +131,7 @@ pushd "$install_dir/live/services/web"
ynh_exec_warn_less npm install ldapts ynh_exec_warn_less npm install ldapts
ynh_exec_warn_less npm install ldap-escape ynh_exec_warn_less npm install ldap-escape
ynh_exec_warn_less npm cache clean --force ynh_exec_warn_less npm cache clean --force
#REMOVEME? ynh_secure_remove --file="$install_dir/live/services/web/node_modules/.cache" ynh_secure_remove --file="$install_dir/live/services/web/node_modules/.cache"
popd popd
chmod 750 "$install_dir/live" chmod 750 "$install_dir/live"
@ -270,30 +209,6 @@ ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/
ynh_systemd_action --service_name="$app-track-changes" --action="start" --log_path="/var/log/$app/track-changes.log" --line_match="listening on" ynh_systemd_action --service_name="$app-track-changes" --action="start" --log_path="/var/log/$app/track-changes.log" --line_match="listening on"
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="listening on" ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="listening on"
#=================================================
# SETUP SSOWAT
#=================================================
#REMOVEME? ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary
#REMOVEME? if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
fi
ynh_permission_url --permission="main" --auth_header=false
#REMOVEME? ynh_permission_create --permission="admin" --allowed="$admin"
#=================================================
# RELOAD NGINX
#=================================================
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -7,23 +7,8 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_user=$db_name
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
@ -121,25 +106,6 @@ ynh_script_progression --message="Removing the MongoDB database..."
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
#REMOVEME? ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
#REMOVEME? ynh_secure_remove --file="$install_dir"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..."
#REMOVEME? ynh_secure_remove --file="$data_dir"
fi
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
@ -151,12 +117,11 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
#REMOVEME? ynh_script_progression --message="Removing dependencies..." ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_mongo ynh_remove_mongo
ynh_remove_nodejs ynh_remove_nodejs
#REMOVEME? ynh_remove_app_dependencies
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
@ -168,16 +133,6 @@ ynh_script_progression --message="Removing various files..."
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
#REMOVEME? ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -8,42 +8,8 @@
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source ../settings/scripts/ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
#REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_user=$db_name
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..."
#REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $install_dir "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
@ -53,14 +19,6 @@ ynh_script_progression --message="Restoring the NGINX web server configuration..
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
@ -79,8 +37,6 @@ ynh_script_progression --message="Restoring the data directory..."
ynh_restore_file --origin_path="$data_dir" --not_mandatory ynh_restore_file --origin_path="$data_dir" --not_mandatory
mkdir -p $data_dir
chmod 750 "$data_dir" chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir" chmod -R o-rwx "$data_dir"
chown -R $app:www-data "$data_dir" chown -R $app:www-data "$data_dir"
@ -90,10 +46,10 @@ chown -R $app:www-data "$data_dir"
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies # Define and install dependencies
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies ynh_npm install --global npm@latest
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_mongo ynh_install_mongo
@ -102,7 +58,7 @@ ynh_install_mongo
#================================================= #=================================================
ynh_script_progression --message="Restoring the MongoDB database..." ynh_script_progression --message="Restoring the MongoDB database..."
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mongo_restore_db --database="$db_name" < ./dump.bson ynh_mongo_restore_db --database="$db_name" < ./dump.bson

View file

@ -7,28 +7,8 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? language=$(ynh_app_setting_get --app=$app --key=language)
#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_user=$db_name
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
#REMOVEME? web_api_password=$(ynh_app_setting_get --app=$app --key=web_api_password)
#REMOVEME? crypto_random=$(ynh_app_setting_get --app=$app --key=crypto_random)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -37,21 +17,6 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails
#REMOVEME? ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -76,14 +41,6 @@ ynh_systemd_action --service_name="$app-web" --action="stop" --log_path="/var/lo
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." ynh_script_progression --message="Ensuring downward compatibility..."
#=================================================
# CREATE DEDICATED USER
#=================================================
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -114,7 +71,6 @@ ynh_add_nginx_config
#================================================= #=================================================
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." #REMOVEME? ynh_script_progression --message="Upgrading dependencies..."
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_mongo ynh_install_mongo
@ -141,7 +97,7 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Building app..." ynh_script_progression --message="Building app..."
#REMOVEME? ynh_secure_remove --file="$install_dir/live" ynh_secure_remove --file="$install_dir/live"
mkdir -p "$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/genScript.js" "$install_dir/live/genScript.js"
cp "$install_dir/build/server-ce/services.js" "$install_dir/live/services.js" cp "$install_dir/build/server-ce/services.js" "$install_dir/live/services.js"
@ -160,12 +116,12 @@ then
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/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/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" cp "$install_dir/build_ldap/ldap-overleaf-sl/sharelatex/admin-sysadmin.pug" "$install_dir/live/services/web/app/views/admin/index.pug"
#REMOVEME? ynh_secure_remove --file="$install_dir/live/services/web/app/views/admin/register.pug" ynh_secure_remove --file="$install_dir/live/services/web/app/views/admin/register.pug"
#REMOVEME? ynh_secure_remove --file="$install_dir/live/services/web/app/views/project/editor/review-panel.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" touch "$install_dir/live/services/web/app/views/project/editor/review-panel.pug"
#REMOVEME? ynh_secure_remove --file="$install_dir/build" ynh_secure_remove --file="$install_dir/build"
#REMOVEME? ynh_secure_remove --file="$install_dir/build_ldap" ynh_secure_remove --file="$install_dir/build_ldap"
pushd "$install_dir/live" pushd "$install_dir/live"
ynh_use_nodejs ynh_use_nodejs
@ -181,7 +137,7 @@ then
ynh_exec_warn_less npm install ldapts ynh_exec_warn_less npm install ldapts
ynh_exec_warn_less npm install ldap-escape ynh_exec_warn_less npm install ldap-escape
ynh_exec_warn_less npm cache clean --force ynh_exec_warn_less npm cache clean --force
#REMOVEME? ynh_secure_remove --file="$install_dir/live/services/web/node_modules/.cache" ynh_secure_remove --file="$install_dir/live/services/web/node_modules/.cache"
popd popd
chmod 750 "$install_dir/live" chmod 750 "$install_dir/live"
@ -259,13 +215,6 @@ ynh_systemd_action --service_name="$app-spelling" --action="start" --log_path="/
ynh_systemd_action --service_name="$app-track-changes" --action="start" --log_path="/var/log/$app/track-changes.log" --line_match="listening on" ynh_systemd_action --service_name="$app-track-changes" --action="start" --log_path="/var/log/$app/track-changes.log" --line_match="listening on"
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="listening on" ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/web.log" --line_match="listening on" --line_match="listening on"
#=================================================
# RELOAD NGINX
#=================================================
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -1,355 +0,0 @@
#!/bin/bash
MONGO_DEBIAN_SERVICENAME="mongodb"
MONGO_CE_SERVICENAME="mongod"
MONGO_DEBIAN_DEPENDENCIES="mongodb mongodb-server mongo-tools"
MONGO_CE_DEPENDENCIES="mongodb-org mongodb-org-server mongodb-org-tools"
MONGO_DEBIAN_CONFIG="/etc/mongodb.conf"
MONGO_CE_CONFIG="/etc/mongod.conf"
MONGO_CE_REPO="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main"
MONGO_CE_KEY="https://www.mongodb.org/static/pgp/server-4.4.asc"
# Execute a mongo command
#
# example: ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("wekan")'
# example: ynh_mongo_exec --command="db.getMongo().getDBNames().indexOf(\"wekan\")"
#
# usage: ynh_mongo_exec [--user=user] [--password=password] [--authenticationdatabase=authenticationdatabase] [--database=database] [--host=host] [--port=port] --command="command" [--eval]
# | arg: -u, --user= - The user name to connect as
# | arg: -p, --password= - The user password
# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to
# | arg: -d, --database= - The database to connect to
# | arg: -h, --host= - The host to connect to
# | arg: -P, --port= - The port to connect to
# | arg: -c, --command= - The command to evaluate
# | arg: -e, --eval - Evaluate instead of execute the command.
#
#
ynh_mongo_exec() {
# Declare an array to define the options of this helper.
local legacy_args=upadhPce
local -A args_array=( [u]=user= [p]=password= [a]=authenticationdatabase= [d]=database= [h]=host= [P]=port= [c]=command= [e]=eval )
local user
local password
local authenticationdatabase
local database
local host
local port
local command
local eval
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
user="${user:-}"
password="${password:-}"
authenticationdatabase="${authenticationdatabase:-}"
database="${database:-}"
host="${host:-}"
port="${port:-}"
eval=${eval:-0}
# If user is provided
if [ -n "$user" ]
then
user="--username=$user"
# If password is provided
if [ -n "$password" ]
then
password="--password=$password"
fi
# If authenticationdatabase is provided
if [ -n "$authenticationdatabase" ]
then
authenticationdatabase="--authenticationDatabase=$authenticationdatabase"
else
authenticationdatabase="--authenticationDatabase=admin"
fi
else
password=""
authenticationdatabase=""
fi
# If host is provided
if [ -n "$host" ]
then
host="--host=$host"
fi
# If port is provided
if [ -n "$port" ]
then
port="--port=$port"
fi
# If eval is not provided
if [ $eval -eq 0 ]
then
# If database is provided
if [ -n "$database" ]
then
database="use $database"
else
database=""
fi
mongo --quiet $user $password $authenticationdatabase $host $port <<EOF
$database
${command}
quit()
EOF
else
# If database is provided
if [ -n "$database" ]
then
database="$database"
else
database=""
fi
mongo --quiet $database $user $password $authenticationdatabase $host $port --eval="$command"
fi
}
# Drop a database
#
# [internal]
#
# If you intend to drop the database *and* the associated user,
# consider using ynh_mongo_remove_db instead.
#
# usage: ynh_mongo_drop_db --database=database
# | arg: -d, --database= - The database name to drop
#
#
ynh_mongo_drop_db() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=( [d]=database= )
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
ynh_mongo_exec --database="$database" --command='db.runCommand({dropDatabase: 1})'
}
# Dump a database
#
# example: ynh_mongo_dump_db --database=wekan > ./dump.bson
#
# usage: ynh_mongo_dump_db --database=database
# | arg: -d, --database= - The database name to dump
# | ret: the mongodump output
#
#
ynh_mongo_dump_db() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=( [d]=database= )
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
mongodump --quiet --db="$database" --archive
}
# Create a user
#
# [internal]
#
# usage: ynh_mongo_create_user --db_user=user --db_pwd=pwd --db_name=name
# | arg: -u, --db_user= - The user name to create
# | arg: -p, --db_pwd= - The password to identify user by
# | arg: -n, --db_name= - Name of the database to grant privilegies
#
#
ynh_mongo_create_user() {
# Declare an array to define the options of this helper.
local legacy_args=unp
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
local db_user
local db_name
local db_pwd
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# Create the user and set the user as admin of the db
ynh_mongo_exec --database="$db_name" --command='db.createUser( { user: "'${db_user}'", pwd: "'${db_pwd}'", roles: [ { role: "readWrite", db: "'${db_name}'" } ] } );'
# Add clustermonitoring rights
ynh_mongo_exec --database="$db_name" --command='db.grantRolesToUser("'${db_user}'",[{ role: "clusterMonitor", db: "admin" }]);'
}
# Check if a mongo database exists
#
# usage: ynh_mongo_database_exists --database=database
# | arg: -d, --database= - The database for which to check existence
# | exit: Return 1 if the database doesn't exist, 0 otherwise
#
#
ynh_mongo_database_exists() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=([d]=database=)
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")' --eval) -lt 0 ]
then
return 1
else
return 0
fi
}
# Restore a database
#
# example: ynh_mongo_restore_db --database=wekan < ./dump.bson
#
# usage: ynh_mongo_restore_db --database=database
# | arg: -d, --database= - The database name to restore
#
#
ynh_mongo_restore_db() {
# Declare an array to define the options of this helper.
local legacy_args=d
local -A args_array=( [d]=database= )
local database
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
mongorestore --quiet --db="$database" --archive
}
# Drop a user
#
# [internal]
#
# usage: ynh_mongo_drop_user --db_user=user --db_name=name
# | arg: -u, --db_user= - The user to drop
# | arg: -n, --db_name= - Name of the database
#
#
ynh_mongo_drop_user() {
# Declare an array to define the options of this helper.
local legacy_args=un
local -A args_array=( [u]=db_user= [n]=db_name= )
local db_user
local db_name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
ynh_mongo_exec --database="$db_name" --command='db.dropUser("'$db_user'", {w: "majority", wtimeout: 5000})'
}
# Create a database, an user and its password. Then store the password in the app's config
#
# usage: ynh_mongo_setup_db --db_user=user --db_name=name [--db_pwd=pwd]
# | arg: -u, --db_user= - Owner of the database
# | arg: -n, --db_name= - Name of the database
# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated
#
# After executing this helper, the password of the created database will be available in $db_pwd
# It will also be stored as "mongopwd" into the app settings.
#
#
ynh_mongo_setup_db() {
# Declare an array to define the options of this helper.
local legacy_args=unp
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
local db_user
local db_name
db_pwd=""
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local new_db_pwd=$(ynh_string_random) # Generate a random password
# If $db_pwd is not provided, use new_db_pwd instead for db_pwd
db_pwd="${db_pwd:-$new_db_pwd}"
# Create the user and grant access to the database
ynh_mongo_create_user --db_user="$db_user" --db_pwd="$db_pwd" --db_name="$db_name"
# Store the password in the app's config
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
}
# Remove a database if it exists, and the associated user
#
# usage: ynh_mongo_remove_db --db_user=user --db_name=name
# | arg: -u, --db_user= - Owner of the database
# | arg: -n, --db_name= - Name of the database
#
#
ynh_mongo_remove_db() {
# Declare an array to define the options of this helper.
local legacy_args=un
local -A args_array=( [u]=db_user= [n]=db_name= )
local db_user
local db_name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
if ynh_mongo_database_exists --database=$db_name; then # Check if the database exists
ynh_mongo_drop_db --database=$db_name # Remove the database
else
ynh_print_warn --message="Database $db_name not found"
fi
# Remove mongo user if it exists
ynh_mongo_drop_user --db_user=$db_user --db_name=$db_name
}
# Install MongoDB and integrate MongoDB service in YunoHost
#
# usage: ynh_install_mongo
#
#
ynh_install_mongo() {
ynh_print_info --message="Installing MongoDB..."
# Define Mongo Service Name
if dpkg --compare-versions $(cat /etc/debian_version) ge 10.0
then
ynh_print_info --message="Installing MongoDB Community Edition..."
ynh_install_extra_app_dependencies --repo="$MONGO_CE_REPO" --package="$MONGO_CE_DEPENDENCIES" --key="$MONGO_CE_KEY"
MONGODB_SERVICENAME=$MONGO_CE_SERVICENAME
else
ynh_print_info --message="Installing MongoDB Debian..."
ynh_install_app_dependencies $MONGO_DEBIAN_DEPENDENCIES
MONGODB_SERVICENAME=$MONGO_DEBIAN_SERVICENAME
fi
mongodb_servicename=$MONGODB_SERVICENAME
# Make sure MongoDB is started and enabled
systemctl is-enabled $MONGODB_SERVICENAME -q || systemctl enable $MONGODB_SERVICENAME --quiet
systemctl is-active $MONGODB_SERVICENAME -q || ynh_systemd_action --service_name=$MONGODB_SERVICENAME --action=restart --line_match="aiting for connections" --log_path="/var/log/mongodb/$MONGODB_SERVICENAME.log"
# Integrate MongoDB service in YunoHost
yunohost service add $MONGODB_SERVICENAME --description="MongoDB daemon" --log="/var/log/mongodb/$MONGODB_SERVICENAME.log"
}
# Remove MongoDB
# Only remove the MongoDB service integration in YunoHost for now
# if MongoDB package as been removed
#
# usage: ynh_remove_mongo
#
#
ynh_remove_mongo() {
# Only remove the mongodb service if it is not installed.
if ! ynh_package_is_installed --package="mongodb*"
then
ynh_print_info --message="Removing MongoDB service..."
# Define Mongo Service Name
if [ "$(lsb_release --codename --short)" = "buster" ]; then
MONGODB_SERVICENAME=$MONGO_CE_SERVICENAME
else
MONGODB_SERVICENAME=$MONGO_DEBIAN_SERVICENAME
fi
# Remove the mongodb service
yunohost service remove $MONGODB_SERVICENAME
# ynh_secure_remove --file=$MONGO_ROOT_PWD_FILE
fi
}