diff --git a/conf/systemd.service b/conf/systemd.service index e5ed9ca..f626c23 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,7 +1,7 @@ [Unit] Description=Wekan, task board -Wants=mongodb.service -After=network.target +Wants=__MOGODB_SERVICENAME__.service +After=network.target __MOGODB_SERVICENAME__.service [Service] Type=simple diff --git a/scripts/_common.sh b/scripts/_common.sh index 2bdc4db..fe27352 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,6 +7,8 @@ # dependencies used by the app pkg_dependencies="mongodb mongodb-server mongo-tools" pkg_dependencies_buster="mongodb-org mongodb-org-server mongodb-org-tools" +mongodb_stretch="mongodb" +mongodb_buster="mongod" nodejsversion=12.15.0 #================================================= diff --git a/scripts/install b/scripts/install index 1ec5a31..e51b971 100755 --- a/scripts/install +++ b/scripts/install @@ -81,8 +81,10 @@ ynh_use_nodejs if [ "$(lsb_release --codename --short)" = "buster" ]; then ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies_buster" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" + mongodb_servicename=$mongodb_buster else ynh_install_app_dependencies $pkg_dependencies + mongodb_servicename=$mongodb_stretch fi #================================================= @@ -91,8 +93,8 @@ fi ynh_print_info --message="Creating a MongoDB database..." # Start mongodb -systemctl enable mongodb -systemctl start mongodb +systemctl enable $mongodb_servicename +systemctl start $mongodb_servicename # Registering db name db_name=$(ynh_sanitize_dbid --db_name=$app) @@ -132,6 +134,7 @@ ynh_print_info --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__MOGODB_SERVICENAME__" --replace_string="$mongodb_servicename" --target_file="../conf/systemd.service" ynh_add_systemd_config #================================================= diff --git a/scripts/restore b/scripts/restore index e795562..445e21f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -89,8 +89,10 @@ ynh_use_nodejs if [ "$(lsb_release --codename --short)" = "buster" ]; then ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies_buster" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" + mongodb_servicename=$mongodb_buster else ynh_install_app_dependencies $pkg_dependencies + mongodb_servicename=$mongodb_stretch fi #================================================= @@ -99,8 +101,8 @@ fi ynh_print_info --message="Restoring the MongoDB database..." # Start mongodb -systemctl enable mongodb -systemctl start mongodb +systemctl enable $mongodb_servicename +systemctl start $mongodb_servicename mongorestore --db $db_name ./dump/$db_name #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 94f2507..42045cd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -166,8 +166,10 @@ ynh_use_nodejs if [ "$(lsb_release --codename --short)" = "buster" ]; then ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies_buster" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" + mongodb_servicename=$mongodb_buster else ynh_install_app_dependencies $pkg_dependencies + mongodb_servicename=$mongodb_stretch fi #================================================= @@ -201,6 +203,7 @@ ynh_print_info --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__MOGODB_SERVICENAME__" --replace_string="$mongodb_servicename" --target_file="../conf/systemd.service" ynh_add_systemd_config #=================================================