Skip to content

Commit

Permalink
Merge pull request #74 from NethServer/bug-6942
Browse files Browse the repository at this point in the history
Resume import-module action after NS8 reboot

Refs NethServer/dev#6942
  • Loading branch information
DavidePrincipi authored Jun 6, 2024
2 parents 2e6b735 + e0c56e0 commit 12e7dbc
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 3 deletions.
19 changes: 17 additions & 2 deletions api/migration/update
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ exit_apierror ()
error "ApiFailed" "${action} ${app_id} failed"
}

run_check_import ()
{
local app_id
app_id=${1:?}
if [[ -x "${app_idir}"/check-import ]]; then
# If the app overrides the check-import script, run it. Some
# modules like Mail requires it.
"${app_idir}"/check-import "${app_id}"
else
# If the app installation dir has no check-import script,
# run the automatic check:
/usr/sbin/ns8-check-import "${app_id}"
fi
}

trap exit_apierror ERR

source /etc/nethserver/agent.env
Expand All @@ -60,10 +75,10 @@ echo "----------- ${action} ${app_id}" $(date -R) >>/var/log/ns8-migration.log
if [ "$action" == "start" ]; then
"${app_idir}/bind" &>>/var/log/ns8-migration.log
elif [[ "$action" == "sync" ]]; then
/usr/sbin/ns8-check-import "${app_id}"
run_check_import "${app_id}"
MIGRATE_ACTION="${action}" flock ${app_sdir}/syncing.lock "${app_idir}/migrate" &>>/var/log/ns8-migration.log
elif [[ "$action" == "finish" ]]; then
/usr/sbin/ns8-check-import "${app_id}"
run_check_import "${app_id}"
MIGRATE_ACTION="${action}" flock ${app_sdir}/syncing.lock "${app_idir}/migrate" &>>/var/log/ns8-migration.log
touch ${app_sdir}/migrated
if [[ "${app_id}" == "account-provider" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion root/usr/sbin/ns8-check-import
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ source /etc/nethserver/agent.env
source "${AGENT_STATE_DIR}"/agent.env
source "${AGENT_STATE_DIR}"/environment

module=$1
module=${1:?missing module argument}
cd "${AGENT_STATE_DIR}/${module}"
source bind.env
export RSYNC_PASSWORD
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

#
# Copyright (C) 2024 Nethesis S.r.l.
# http://www.nethesis.it - [email protected]
#
# This script is part of NethServer.
#
# NethServer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# NethServer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NethServer. If not, see COPYING.
#

set -e

account_provider_type=$(/sbin/e-smith/config getprop sssd Provider)
ns8-check-import "account-provider/${account_provider_type}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

#
# Copyright (C) 2024 Nethesis S.r.l.
# http://www.nethesis.it - [email protected]
#
# This script is part of NethServer.
#
# NethServer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# NethServer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NethServer. If not, see COPYING.
#

set -e

ns8-check-import nethserver-mail &

if [[ -f /etc/e-smith/db/configuration/defaults/webtop/type ]]; then
ns8-check-import nethserver-webtop5 &
fi

if [[ -f /etc/e-smith/db/configuration/defaults/roundcubemail/type && -d '/var/lib/mysql/roundcubemail' ]]; then
ns8-check-import nethserver-roundcubemail &
fi

if [[ -f /etc/e-smith/db/configuration/defaults/sogod/type ]]; then
ns8-check-import nethserver-sogo &
fi

# Getmail is not a service
if [[ -f /etc/e-smith/events/actions/nethserver-getmail-conf ]]; then
ns8-check-import nethserver-mail-getmail &
fi

for pid in $(jobs -p); do
wait "${pid}"
done

0 comments on commit 12e7dbc

Please sign in to comment.