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

fix mongo

This commit is contained in:
Thomas 2024-06-01 20:07:13 +02:00 committed by GitHub
parent 3108341570
commit e8d5f35ad2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,27 +1,19 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
nodejs_version=18.20.2
nodejs_version="18.20.2"
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
@@ -15,7 +15,7 @@ nodejs_version="18.20.2"
#=================================================
readonly YNH_DEFAULT_MONGO_VERSION=6.0
# Declare the actual MongoDB version to use: 4.4 ; 5.0 ; 6.0
# Declare the actual MongoDB version to use: 4.4; 5.0; 6.0
# A packager willing to use another version of MongoDB can override the variable into its _common.sh.
YNH_MONGO_VERSION=${YNH_MONGO_VERSION:-$YNH_DEFAULT_MONGO_VERSION}
# Execute a mongo command
#
# example: ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("wekan")'
@@ -25,100 +25,100 @@ YNH_MONGO_VERSION=${YNH_MONGO_VERSION:-$YNH_DEFAULT_MONGO_VERSION}
# 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]
@ -103,7 +95,7 @@ ynh_mongo_exec() {
database=""
fi
mongo --quiet $user $password $authenticationdatabase $host $port <<EOF
mongosh --quiet --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port <<EOF
$database
${command}
quit()
@ -117,15 +109,12 @@ EOF
database=""
fi
mongo --quiet $database $user $password $authenticationdatabase $host $port --eval="$command"
mongosh --quiet $database --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port --eval="$command"
fi
}
# Drop a database
#
# [internal]
#
# If you intend to drop the database *and* the associated user,
@@ -129,220 +129,216 @@ EOF
# consider using ynh_mongo_remove_db instead.
#
# usage: ynh_mongo_drop_db --database=database
@ -326,8 +315,10 @@ ynh_install_mongo() {
ynh_handle_getopts_args "$@"
mongo_version="${mongo_version:-$YNH_MONGO_VERSION}"
debian=$(lsb_release --codename --short)
ynh_print_info --message="Installing MongoDB Community Edition..."
local mongo_debian_release=bullseye #$(ynh_get_debian_release)
local mongo_debian_release=$(ynh_get_debian_release)
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)."
@ -342,23 +333,7 @@ ynh_install_mongo() {
mongodb_servicename=mongod
# Make sure MongoDB is started and enabled
systemctl enable $mongodb_servicename --quiet
systemctl daemon-reload --quiet
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"
# Store mongo_version into the config of this app
ynh_app_setting_set --app=$app --key=mongo_version --value=$mongo_version
}
# Remove MongoDB
# Only remove the MongoDB service integration in YunoHost for now
# if MongoDB package as been removed
#
# usage: ynh_remove_mongo
@@ -366,19 +362,18 @@ ynh_install_mongo() {
#
#
ynh_remove_mongo() {
@ -374,6 +349,7 @@ ynh_remove_mongo() {
fi
}
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================