mirror of
https://github.com/YunoHost-Apps/rocketchat_ynh.git
synced 2024-09-03 20:16:25 +02:00
Update _common.sh
This commit is contained in:
parent
1764ad385e
commit
b79caa457e
1 changed files with 14 additions and 30 deletions
|
@ -17,11 +17,10 @@ pkg_dependencies="apt-transport-https build-essential gzip curl fontconfig graph
|
|||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
MONGO_DEBIAN_SERVICENAME="mongodb"
|
||||
#!/bin/bash
|
||||
|
||||
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_DEPENDENCIES="mongodb-org mongodb-org-server mongodb-org-tools mongodb-mongosh"
|
||||
MONGO_CE_CONFIG="/etc/mongod.conf"
|
||||
MONGO_CE_REPO="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main"
|
||||
MONGO_CE_KEY="https://www.mongodb.org/static/pgp/server-5.0.asc"
|
||||
|
@ -110,7 +109,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()
|
||||
|
@ -124,7 +123,7 @@ 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
|
||||
}
|
||||
|
||||
|
@ -324,26 +323,16 @@ ynh_mongo_remove_db() {
|
|||
#
|
||||
#
|
||||
ynh_install_mongo() {
|
||||
ynh_script_progression --message="Installing MongoDB..." --weight=5
|
||||
|
||||
# Define Mongo Service Name
|
||||
if $(dpkg --compare-versions $(cat /etc/debian_version) gt "10.0")
|
||||
then
|
||||
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
|
||||
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
|
||||
|
||||
# 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"
|
||||
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"
|
||||
yunohost service add $mongodb_servicename --description="MongoDB daemon" --log="/var/log/mongodb/$mongodb_servicename.log"
|
||||
}
|
||||
|
||||
# Remove MongoDB
|
||||
|
@ -357,15 +346,10 @@ ynh_remove_mongo() {
|
|||
# Only remove the mongodb service if it is not installed.
|
||||
if ! ynh_package_is_installed --package="mongodb*"
|
||||
then
|
||||
ynh_script_progression --message="Removing MongoDB service..." --weight=2
|
||||
# Define Mongo Service Name
|
||||
if [ "$(lsb_release --codename --short)" = "buster" ]; then
|
||||
MONGODB_SERVICENAME=$MONGO_CE_SERVICENAME
|
||||
else
|
||||
MONGODB_SERVICENAME=$MONGO_DEBIAN_SERVICENAME
|
||||
fi
|
||||
ynh_print_info --message="Removing MongoDB service..."
|
||||
mongodb_servicename=$MONGO_CE_SERVICENAME
|
||||
# Remove the mongodb service
|
||||
yunohost service remove $MONGODB_SERVICENAME
|
||||
yunohost service remove $mongodb_servicename
|
||||
# ynh_secure_remove --file=$MONGO_ROOT_PWD_FILE
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue