mirror of
https://github.com/YunoHost-Apps/wekan_ynh.git
synced 2024-09-03 20:36:09 +02:00
Fixing ynh_mongo_test_if_first_run
This commit is contained in:
parent
dbb39079a9
commit
db5044786b
8 changed files with 11 additions and 8 deletions
|
@ -10,7 +10,7 @@ __YNH_NODE_LOAD_PATH__
|
|||
#DEBUG=true
|
||||
#---------------------------------------------
|
||||
# URL of the mongodb
|
||||
MONGO_URL=mongodb://127.0.0.1:27017/__DB_NAME__
|
||||
MONGO_URL=mongodb://__DB_USER__:__DB_PWD__@127.0.0.1:27017/__DB_NAME__
|
||||
#---------------------------------------------
|
||||
# ROOT_URL EXAMPLES FOR WEBSERVERS: https://github.com/wekan/wekan/wiki/Settings
|
||||
# Production: https://example.com/wekan
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Trello-like kanban",
|
||||
"fr": "Un kanban similaire à Trello"
|
||||
},
|
||||
"version": "4.09~ynh1",
|
||||
"version": "4.09~ynh2",
|
||||
"url": "https://wekan.io",
|
||||
"license": "MIT",
|
||||
"maintainer": [
|
||||
|
|
|
@ -62,6 +62,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
|
|||
#=================================================
|
||||
ynh_print_info --message="Backing up the MongoDB database..."
|
||||
|
||||
ynh_mongo_test_if_first_run
|
||||
ynh_mongo_dump_db --database="$db_name" > ./dump.bson
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -80,6 +80,7 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
ynh_install_nodejs --nodejs_version=$nodejsversion
|
||||
ynh_use_nodejs
|
||||
ynh_install_mongo
|
||||
ynh_mongo_test_if_first_run
|
||||
|
||||
#=================================================
|
||||
# CREATE A MONGODB DATABASE
|
||||
|
|
|
@ -49,6 +49,8 @@ ynh_remove_systemd_config
|
|||
#=================================================
|
||||
ynh_script_progression --message="Removing the MongoDB database..."
|
||||
|
||||
ynh_mongo_test_if_first_run
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
ynh_install_nodejs --nodejs_version=$nodejsversion
|
||||
ynh_use_nodejs
|
||||
ynh_install_mongo
|
||||
ynh_mongo_test_if_first_run
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MONGODB DATABASE
|
||||
|
|
|
@ -182,6 +182,7 @@ ynh_remove_nodejs
|
|||
ynh_install_nodejs --nodejs_version=$nodejsversion
|
||||
ynh_use_nodejs
|
||||
ynh_install_mongo
|
||||
ynh_mongo_test_if_first_run
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
|
|
|
@ -346,6 +346,7 @@ ynh_mongo_remove_db() {
|
|||
#
|
||||
#
|
||||
ynh_mongo_test_if_first_run() {
|
||||
ynh_print_info --message="MongoDB first run..."
|
||||
|
||||
# Make sure Mongodb is indeed installed
|
||||
dpkg --list | grep -q "ii mongodb.*server" || ynh_die --message="MongoDB is not installed !?"
|
||||
|
@ -358,17 +359,13 @@ ynh_mongo_test_if_first_run() {
|
|||
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
|
||||
|
||||
# If this is the very first time, we define the root password
|
||||
# and configure a few things
|
||||
if [ ! -f "$MONGO_ROOT_PWD_FILE" ]
|
||||
then
|
||||
local mongo_root_password="$(ynh_string_random)"
|
||||
echo "$mongo_root_password" >$MONGO_ROOT_PWD_FILE
|
||||
sleep 10
|
||||
|
||||
ynh_mongo_exec --database=admin --command='db.createUser( { user: "'${MONGO_ROOT_USER}'", pwd: "'${mongo_root_password}'", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } );'
|
||||
|
||||
ynh_systemd_action --service_name=$MONGODB_SERVICENAME --action=stop
|
||||
|
@ -378,7 +375,7 @@ ynh_mongo_test_if_first_run() {
|
|||
else
|
||||
ynh_replace_string --match_string="#auth = true" --replace_string="auth = true" --target_file="$MONGO_CONFIG_STRETCH"
|
||||
fi
|
||||
ynh_systemd_action --service_name=$MONGODB_SERVICENAME --action=start
|
||||
ynh_systemd_action --service_name=$MONGODB_SERVICENAME --action=start --line_match="aiting for connections" --log_path="/var/log/mongodb/$MONGODB_SERVICENAME.log"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue