Commit 7547be46 authored by Nicolas Wavrant's avatar Nicolas Wavrant

slaprunner: importer script should fail also when running the custom import scripts

parent 95c0c413
...@@ -68,7 +68,7 @@ recipe = hexagonit.recipe.download ...@@ -68,7 +68,7 @@ recipe = hexagonit.recipe.download
ignore-existing = true ignore-existing = true
url = ${:_profile_base_location_}/template/runner-import.sh.jinja2 url = ${:_profile_base_location_}/template/runner-import.sh.jinja2
download-only = true download-only = true
md5sum = 275ae222cd9a560c08748d7502824885 md5sum = 5db39d7f56fd1f96ce6466e9055841a1
filename = runner-import.sh.jinja2 filename = runner-import.sh.jinja2
mode = 0644 mode = 0644
......
...@@ -15,6 +15,7 @@ ERROR_MESSAGE="" ...@@ -15,6 +15,7 @@ ERROR_MESSAGE=""
fail_with_exit_code () { fail_with_exit_code () {
echo 1 > $RESTORE_EXIT_CODE_FILE echo 1 > $RESTORE_EXIT_CODE_FILE
echo -e "Failure during step : $ERROR_MESSAGE" > $RESTORE_ERROR_MESSAGE_FILE echo -e "Failure during step : $ERROR_MESSAGE" > $RESTORE_ERROR_MESSAGE_FILE
exit 1
} }
trap fail_with_exit_code ERR trap fail_with_exit_code ERR
...@@ -55,18 +56,18 @@ cp -r {{ directory['backup'] }}/etc/.??* {{ directory['etc'] }}; ...@@ -55,18 +56,18 @@ cp -r {{ directory['backup'] }}/etc/.??* {{ directory['etc'] }};
# Invoke arbitrary script to perform specific restoration # Invoke arbitrary script to perform specific restoration
# procedure. # procedure.
RESTORE_EXIT_CODE=0
runner_import_restore=$srv_directory/runner-import-restore runner_import_restore=$srv_directory/runner-import-restore
if [ ! -e "$runner_import_restore" ]; then if [ ! -e "$runner_import_restore" ]; then
touch $runner_import_restore touch $runner_import_restore
chmod +x $runner_import_restore chmod +x $runner_import_restore
fi fi
log_message "Running $runner_import_restore..." log_message "Running $runner_import_restore..."
$srv_directory/runner-import-restore || RESTORE_EXIT_CODE=$? $srv_directory/runner-import-restore
# If no "etc/.project" neither "srv/runner/proxy.db", we can safely assume # If no "etc/.project" neither "srv/runner/proxy.db", we can safely assume
# that there is no instnace deployed on runner0 # that there is no instnace deployed on runner0
if [ ! -f "directory['etc']/.project" ] && [ ! -f "$srv_directory/runner/proxy.db" ]; then if [ ! -f "directory['etc']/.project" ] && [ ! -f "$srv_directory/runner/proxy.db" ]; then
log_message "No Software Requested... Writing status file... End"
echo 0 > $RESTORE_EXIT_CODE_FILE echo 0 > $RESTORE_EXIT_CODE_FILE
exit 0 exit 0
fi fi
...@@ -121,8 +122,8 @@ for partition in $srv_directory/runner/instance/slappart*/ ...@@ -121,8 +122,8 @@ for partition in $srv_directory/runner/instance/slappart*/
do do
script=$partition/srv/runner-import-restore script=$partition/srv/runner-import-restore
if [ -e "$script" ]; then if [ -e "$script" ]; then
log_message "Running $script..." log_message "Running custom instance script : $script..."
$script || RESTORE_EXIT_CODE=$? $script
fi fi
done done
...@@ -132,5 +133,5 @@ $SQLITE3 $DATABASE "update partition11 set requested_state='started';" ...@@ -132,5 +133,5 @@ $SQLITE3 $DATABASE "update partition11 set requested_state='started';"
# Write exit code to an arbitrary file that will be checked by promise/monitor # Write exit code to an arbitrary file that will be checked by promise/monitor
log_message "Writing status file... End" log_message "Writing status file... End"
echo $RESTORE_EXIT_CODE > $RESTORE_EXIT_CODE_FILE echo 0 > $RESTORE_EXIT_CODE_FILE
exit $RESTORE_EXIT_CODE exit 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment