1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/wekan_ynh.git synced 2024-09-03 20:36:09 +02:00

Going back to ynh_mongo_db

This commit is contained in:
yalh76 2022-06-13 01:04:18 +02:00
parent 44ac4a255a
commit 4f9220d7be
6 changed files with 37 additions and 18 deletions

View file

@ -8,7 +8,7 @@
# 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__2 source ../settings/scripts/ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================

View file

@ -7,7 +7,7 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_mongo_db__2 source ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================

View file

@ -7,7 +7,7 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_mongo_db__2 source ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================

View file

@ -8,7 +8,7 @@
# 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__2 source ../settings/scripts/ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================

View file

@ -7,7 +7,7 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_mongo_db__2 source ynh_mongo_db
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================

View file

@ -1,10 +1,13 @@
#!/bin/bash #!/bin/bash
MONGO_DEBIAN_SERVICENAME="mongodb"
MONGO_CE_SERVICENAME="mongod" MONGO_CE_SERVICENAME="mongod"
MONGO_CE_DEPENDENCIES="mongodb-org mongodb-org-server mongodb-org-tools mongodb-mongosh" 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_CONFIG="/etc/mongod.conf"
MONGO_CE_REPO="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main" 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-5.0.asc" MONGO_CE_KEY="https://www.mongodb.org/static/pgp/server-4.4.asc"
# Execute a mongo command # Execute a mongo command
# #
@ -90,7 +93,7 @@ ynh_mongo_exec() {
database="" database=""
fi fi
mongosh --quiet --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port <<EOF mongo --quiet $user $password $authenticationdatabase $host $port <<EOF
$database $database
${command} ${command}
quit() quit()
@ -104,7 +107,7 @@ EOF
database="" database=""
fi fi
mongosh --quiet $database --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port --eval="$command" mongo --quiet $database $user $password $authenticationdatabase $host $port --eval="$command"
fi fi
} }
@ -304,16 +307,27 @@ ynh_mongo_remove_db() {
# #
# #
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_print_info --message="Installing MongoDB Community Edition..."
ynh_install_extra_app_dependencies --repo="$MONGO_CE_REPO" --package="$MONGO_CE_DEPENDENCIES" --key="$MONGO_CE_KEY" ynh_install_extra_app_dependencies --repo="$MONGO_CE_REPO" --package="$MONGO_CE_DEPENDENCIES" --key="$MONGO_CE_KEY"
mongodb_servicename=$MONGO_CE_SERVICENAME 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 # Make sure MongoDB is started and enabled
systemctl is-enabled $mongodb_servicename -q || systemctl enable $mongodb_servicename --quiet 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" 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 # Integrate MongoDB service in YunoHost
yunohost service add $mongodb_servicename --description="MongoDB daemon" --log="/var/log/mongodb/$mongodb_servicename.log" yunohost service add $MONGODB_SERVICENAME --description="MongoDB daemon" --log="/var/log/mongodb/$MONGODB_SERVICENAME.log"
} }
# Remove MongoDB # Remove MongoDB
@ -328,9 +342,14 @@ ynh_remove_mongo() {
if ! ynh_package_is_installed --package="mongodb*" if ! ynh_package_is_installed --package="mongodb*"
then then
ynh_print_info --message="Removing MongoDB service..." ynh_print_info --message="Removing MongoDB service..."
mongodb_servicename=$MONGO_CE_SERVICENAME # 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 # Remove the mongodb service
yunohost service remove $mongodb_servicename yunohost service remove $MONGODB_SERVICENAME
# ynh_secure_remove --file=$MONGO_ROOT_PWD_FILE # ynh_secure_remove --file=$MONGO_ROOT_PWD_FILE
fi fi
} }