-
Notifications
You must be signed in to change notification settings - Fork 247
/
rear
executable file
·544 lines (495 loc) · 22.1 KB
/
rear
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
#!/bin/bash
# $Id$
#
# Relax-and-Recover
#
# Relax-and-Recover 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
# (at your option) any later version.
# Relax-and-Recover 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 Relax-and-Recover; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Authors:
# Schlomo Schapiro <rear at schlomo.schapiro dot org> [GSS]
# Gratien D'haese <gdha at sourceforge dot net> [GD]
# Jeroen Hoekx <jeroen.hoekx at hamok dot be> [JH]
# Dag Wieers <dag at wieers dot com> [DAG]
# Johannes Meixner <jsmeix at suse dot de> [jsmeix]
# Usually functions belong to the library scripts (i.e. $SHARE_DIR/lib/*.sh),
# but these 2 are exceptions on the rule because the complementary global functions
# to get and apply bash flags and options commands are needed from the very beginning
# (the usual functions are sourced at "Include functions" below):
function get_bash_flags_and_options_commands () {
# Output bash commands that set the currently set flags
# in reverse ordering to have "set ... xtrace" (i.e. "set +/- x") first
# so that this flag is set first via apply_bash_flags_and_options_commands
# which results better matching logging output in debugscripts mode:
set +o | tac | tr '\n' ';'
# Output bash commands that set the currently set options:
shopt -p | tr '\n' ';'
}
# This function exists only to provide a syntactically matching counterpart of get_bash_flags_and_options_commands:
function apply_bash_flags_and_options_commands () {
# Must be called with $1 that is the output of a previous get_bash_flags_and_options_commands:
eval "$1"
}
# At the very beginning save initial bash flags and options in a global readonly variable
# so that exactly the initial bash flags and options can be restored if needed via
# apply_bash_flags_and_options_commands "$INITIAL_BASH_FLAGS_AND_OPTIONS_COMMANDS"
readonly INITIAL_BASH_FLAGS_AND_OPTIONS_COMMANDS="$( get_bash_flags_and_options_commands )"
# Enable as needed for development of fail-safe code:
# set -ue -o pipefail
# set -xue -o pipefail
# set -xvue -o pipefail
# Cf. the Relax-and-Recover Coding Style
# https://github.com/rear/rear/wiki/Coding-Style
# that reads (excerpt - dated 18. Nov. 2015):
# "TODO Use set -eu to die from unset variables and unhandled errors"
# Versioning
readonly PRODUCT="Relax-and-Recover"
readonly PROGRAM=${0##*/}
readonly VERSION=1.19
readonly RELEASE_DATE=Git
# Used in framework-functions.sh to calculate the time spent executing rear:
readonly STARTTIME=$SECONDS
# Provide the command line options in an array so that other scripts may read them:
readonly CMD_OPTS=( "$@" )
# Allow workflows to set the exit code to a different value (not "readonly"):
EXIT_CODE=0
# Find out if we're running from checkout
REAR_DIR_PREFIX=""
readonly SCRIPT_FILE="$( readlink -f $( type -p "$0" || echo "$0" ) )"
if test "$SCRIPT_FILE" != "$( readlink -f /usr/sbin/$PROGRAM )" ; then
REAR_DIR_PREFIX=${SCRIPT_FILE%/usr/sbin/$PROGRAM}
fi
readonly REAR_DIR_PREFIX
# Program directories - they must be set here. Everything else is then dynamic.
# Not yet readonly here because they are set via the /etc/rear/rescue.conf file
# in the recovery system that is sourced by the rear command in recover mode
# and CONFIG_DIR can also be changed via '-c' command line option:
SHARE_DIR="$REAR_DIR_PREFIX/usr/share/rear"
CONFIG_DIR="$REAR_DIR_PREFIX/etc/rear"
VAR_DIR="$REAR_DIR_PREFIX/var/lib/rear"
LOG_DIR="$REAR_DIR_PREFIX/var/log/rear"
# Generic global variables that are not meant to be configured by the user
# (i.e. that do not belong into usr/share/rear/conf/default.conf),
# see https://github.com/rear/rear/issues/678
# and https://github.com/rear/rear/issues/708
# Location of the disklayout.conf file created by savelayout
# (no readonly DISKLAYOUT_FILE because it is also set in checklayout-workflow.sh and mkbackuponly-workflow.sh):
DISKLAYOUT_FILE="$VAR_DIR/layout/disklayout.conf"
# Location of the root of the filesystem tree of the target system
# in particular the root of the filesystem tree of the to-be-recovered-system in the recovery system
# i.e. the mountpoint in the recovery system where the filesystem tree of the to-be-recovered-system is mounted:
readonly TARGET_FS_ROOT="/mnt/local"
# Initialize defaults: empty value means "false"/"no":
DEBUG=""
DEBUGSCRIPTS=""
DEBUGSCRIPTS_ARGUMENT="x"
KEEP_BUILD_DIR=""
KERNEL_VERSION=""
RECOVERY_MODE=""
STEPBYSTEP=""
SIMULATE=""
VERBOSE=""
WORKFLOW=""
# Parse options
help_note_text="Use '$PROGRAM --help' or 'man $PROGRAM' for more information."
readonly OPTS="$( getopt -n $PROGRAM -o "c:C:dDhsSvVr:" -l "help,version,debugscripts:" -- "$@" )"
if test $? -ne 0 ; then
echo "$help_note_text"
exit 1
fi
eval set -- "$OPTS"
while true ; do
case "$1" in
(-h|--help)
WORKFLOW="help"
;;
(-V|--version)
echo -e "$PRODUCT $VERSION / $RELEASE_DATE"
exit 0
;;
(-v)
VERBOSE=1
;;
(-c)
if [[ "$2" == -* ]] ; then
# When the item that follows '-c' starts with a '-'
# it is considered to be the next option and not an argument for '-c':
echo "-c requires an argument."
echo "$help_note_text"
exit 1
fi
CONFIG_DIR="$2"
shift
;;
(-C)
if [[ "$2" == -* ]] ; then
# When the item that follows '-C' starts with a '-'
# it is considered to be the next option and not an argument for '-C':
echo "-C requires an argument."
echo "$help_note_text"
exit 1
fi
CONFIG_APPEND_FILES="$2"
shift
;;
(-d)
DEBUG=1
VERBOSE=1
;;
(-D)
DEBUGSCRIPTS=1
;;
(--debugscripts)
DEBUG=1
VERBOSE=1
DEBUGSCRIPTS=1
if [[ "$2" == -* ]] ; then
# When the item that follows '--debugscripts' starts with a '-'
# it is considered to be the next option and not an argument for '--debugscripts':
echo "--debugscripts requires an argument."
echo "$help_note_text"
exit 1
fi
DEBUGSCRIPTS_ARGUMENT="$2"
shift
;;
(-s)
SIMULATE=1
VERBOSE=1
;;
(-S)
STEPBYSTEP=1
;;
(-r)
if [[ "$2" == -* ]] ; then
# When the item that follows '-r' starts with a '-'
# it is considered to be the next option and not an argument for '-r':
echo "-r requires an argument."
echo "$help_note_text"
exit 1
fi
KERNEL_VERSION="$2"
shift
;;
(--)
shift
break
;;
(-*)
echo "$PROGNAME: unrecognized option '$option'"
echo "$help_note_text"
exit 1
;;
(*)
break
;;
esac
shift
done
# Set workflow to first command line argument or to "help" as fallback:
if test -z "$WORKFLOW" ; then
# Usually workflow is now in $1 (after the options and its arguments were shifted above)
# but when rear is called without a workflow there exists no $1 here so that
# an empty default value is used to avoid 'set -eu' error exit if $1 is unset:
if test "${1:-}" ; then
# Not "$1" to get rid of compound commands:
WORKFLOW=$1
shift
else
WORKFLOW=help
fi
fi
# Keep the remaining command line arguments to feed to the workflow:
ARGS=( "$@" )
# The following workflows are always verbose:
case "$WORKFLOW" in
(validate|dump|shell|recover)
VERBOSE=1
;;
esac
# Set the variables v and verbose to be used in called programs
# that support the '-v' or '--verbose' options like
# "cp $v ..." or "rm $verbose ..." and so on:
v=""
verbose=""
if test "$VERBOSE" ; then
v="-v"
verbose="--verbose"
fi
# Mark variables that are not meant to be changed later as constants (i.e. readonly).
# Exceptions here:
# CONFIG_DIR because "rear recover" sets it in /etc/rear/rescue.conf in the recovery system
# WORKFLOW because for the udev workflow WORKFLOW is set to the actual workflow
# KERNEL_VERSION because if empty it is set when sourcing config files below
# VERBOSE because there is a special "VERBOSE=1" setting below:
readonly ARGS
readonly CONFIG_APPEND_FILES
readonly DEBUG DEBUGSCRIPTS DEBUGSCRIPTS_ARGUMENT
readonly SIMULATE STEPBYSTEP
# The udev workflow is a special case because it is only a wrapper workflow
# that calls an actual workflow that is specified as $UDEV_WORKFLOW
# (e.g. the default UDEV_WORKFLOW is "mkrescue" in default.conf)
# and then WORKFLOW is set to the actual workflow in udev-workflow.sh
# so that WORKFLOW cannot be set readonly for the udev workflow:
test "$WORKFLOW" = "udev" || readonly WORKFLOW
# Make sure we have the necessary paths (eg. in cron), /sbin will be the first path to search.
# some needed binaries are in /lib/udev or /usr/lib/udev
for path in /usr/bin /bin /usr/sbin /sbin ; do
case ":$PATH:" in
(*:"$path":*)
;;
(*)
test -d "$path" && PATH=$path:$PATH
;;
esac
done
# No readonly PATH so that it can be later extended if needed
# (e.g. to have third-party backup/restore tools available via PATH):
PATH=$PATH:/lib/udev:/usr/lib/udev
# ReaR must run as 'root' (i.e. abort if effective user ID is not 0):
if test "$( id --user )" != "0" ; then
echo "ERROR: $PRODUCT needs 'root' privileges (effective user ID is not 0)" >&2
exit 1
fi
# Set some bash options:
# With nullglob set when e.g. for foo*bar no file matches are found, then foo*bar is removed
# (e.g. "ls foo*bar" becomes plain "ls" without "foo*bar: No such file or directory" error).
# The extglob shell option enables several extended pattern matching operators.
shopt -s nullglob extglob
# Save the current default bash flags and options in a global readonly variable
# so that exactly the default bash flags and options can be restored if needed via
# apply_bash_flags_and_options_commands "$DEFAULT_BASH_FLAGS_AND_OPTIONS_COMMANDS"
readonly DEFAULT_BASH_FLAGS_AND_OPTIONS_COMMANDS="$( get_bash_flags_and_options_commands )"
# Forget all remembered full pathnames of commands:
hash -r
# Make sure that we use only English:
export LC_CTYPE=C LC_ALL=C LANG=C
# Include default config before the RUNTIME_LOGFILE value is set because
# setting the right RUNTIME_LOGFILE value requires values from default.conf
# in particular the default LOGFILE value and the values of the
# LOCKLESS_WORKFLOWS and SIMULTANEOUS_RUNNABLE_WORKFLOWS arrays:
source $SHARE_DIR/conf/default.conf
# Use RUNTIME_LOGFILE for the logfile that is actually used during runtime
# so that the user can specify a different LOGFILE in his local.conf file.
# During runtime use only the actually used RUNTIME_LOGFILE value.
# By default RUNTIME_LOGFILE is the LOGFILE from default.conf:
RUNTIME_LOGFILE="$LOGFILE"
# Set the right RUNTIME_LOGFILE value depending on whether or not
# this currently running instance can run simultaneously with another instance:
can_run_simultaneously=""
# LOCKLESS_WORKFLOWS can run simultaneously with another instance by using LOGFILE.lockless.
# FIXME: Only one lockless workflow can run otherwise the same LOGFILE.lockless
# would be used by more than one simultaneously running lockless workflows:
for lockless_workflow in "${LOCKLESS_WORKFLOWS[@]}" ; do
if test "$WORKFLOW" = "$lockless_workflow" ; then
RUNTIME_LOGFILE="$LOGFILE.lockless"
can_run_simultaneously="yes"
break
fi
done
# SIMULTANEOUS_RUNNABLE_WORKFLOWS are allowed to run simultaneously
# but cannot use LOGFILE.lockless instead they get a LOGFILE with PID
# see https://github.com/rear/rear/issues/1102
# When a workflow is both in LOCKLESS_WORKFLOWS and in SIMULTANEOUS_RUNNABLE_WORKFLOWS
# its right LOGFILE value is the one for SIMULTANEOUS_RUNNABLE_WORKFLOWS:
for simultaneous_runnable_workflow in "${SIMULTANEOUS_RUNNABLE_WORKFLOWS[@]}" ; do
if test "$WORKFLOW" = "$simultaneous_runnable_workflow" ; then
# Simultaneously runnable workflows require unique logfile names
# so that the PID is interposed in the LOGFILE value from default.conf
# which is used as RUNTIME_LOGFILE while the workflow is running
# and at the end it gets copied to a possibly used-defined LOGFILE.
# The logfile_suffix also works for logfile names without '.*' suffix
# (in this case ${LOGFILE##*.} returns the whole $LOGFILE value):
logfile_suffix=$( test "${LOGFILE##*.}" = "$LOGFILE" && echo 'log' || echo "${LOGFILE##*.}" )
RUNTIME_LOGFILE="${LOGFILE%.*}.$$.$logfile_suffix"
can_run_simultaneously="yes"
break
fi
done
# The log file that is actually used during runtime must not be changed:
readonly RUNTIME_LOGFILE
# When this currently running instance cannot run simultaneously with another instance
# test that this currently running instance does not run simultaneously with another instance:
if ! test "$can_run_simultaneously" ; then
# In this case pidof is needed to test what running instances there are:
if ! type pidof 1>/dev/null ; then
echo "ERROR: Required program 'pidof' missing, please check your PATH" >&2
exit 1
fi
# For unknown reasons '-o %PPID' does not work for pidof at least in SLES11
# so that a manual test is done to find out if another pid != $$ is running:
for pid in $( pidof -x "$SCRIPT_FILE" ) ; do
if test "$pid" != $$ ; then
echo "ERROR: $PROGRAM is already running, not starting again" >&2
exit 1
fi
done
fi
# Keep old log file:
test -r "$RUNTIME_LOGFILE" && mv -f "$RUNTIME_LOGFILE" "$RUNTIME_LOGFILE".old 2>/dev/null
# Start logging:
mkdir -p $LOG_DIR
exec 2>"$RUNTIME_LOGFILE" || echo "ERROR: Could not create $RUNTIME_LOGFILE" >&2
# Include functions after RUNTIME_LOGFILE is set and readonly
# so that functions can use a fixed RUNTIME_LOGFILE value:
for script in $SHARE_DIR/lib/*.sh ; do
source $script
done
# Show initial startup messages:
if test "$WORKFLOW" != "help" ; then
LogPrint "$PRODUCT $VERSION / $RELEASE_DATE"
Log "Command line options: $0 ${CMD_OPTS[@]}"
LogPrint "Using log file: $RUNTIME_LOGFILE"
fi
# In DEBUG mode keep by default the build area but that can be overridden in user config files
# therefore no readonly KEEP_BUILD_DIR (it is also set to 1 in build/default/980_verify_rootfs.sh):
test "$DEBUG" && KEEP_BUILD_DIR=1 || true
# Check if we are in recovery mode:
test -e "/etc/rear-release" && RECOVERY_MODE="y" || true
readonly RECOVERY_MODE
test "$SIMULATE" && LogPrint "Simulation mode activated, Relax-and-Recover base directory: $SHARE_DIR" || true
if test "$DEBUGSCRIPTS_ARGUMENT" ; then
Debug "Current set of flags is '$-'"
Debug "The debugscripts flags are '$DEBUGSCRIPTS_ARGUMENT'"
fi
# All workflows need to read the configurations first.
# Combine configuration files:
Debug "Combining configuration files"
# Use this file to manually override the OS detection:
test -r "$CONFIG_DIR/os.conf" && Source "$CONFIG_DIR/os.conf" || true
test -r "$CONFIG_DIR/$WORKFLOW.conf" && Source "$CONFIG_DIR/$WORKFLOW.conf" || true
SetOSVendorAndVersion
# Distribution configuration files:
for config in "$ARCH" "$OS" \
"$OS_MASTER_VENDOR" "$OS_MASTER_VENDOR_ARCH" "$OS_MASTER_VENDOR_VERSION" "$OS_MASTER_VENDOR_VERSION_ARCH" \
"$OS_VENDOR" "$OS_VENDOR_ARCH" "$OS_VENDOR_VERSION" "$OS_VENDOR_VERSION_ARCH" ; do
test -r "$SHARE_DIR/conf/$config.conf" && Source "$SHARE_DIR/conf/$config.conf" || true
done
# User configuration files, last thing is to overwrite variables if we are in the rescue system:
for config in site local rescue ; do
test -r "$CONFIG_DIR/$config.conf" && Source "$CONFIG_DIR/$config.conf" || true
done
# Finally source additional configuration files if specified on the command line:
if test "$CONFIG_APPEND_FILES" ; then
for config_append_file in $CONFIG_APPEND_FILES ; do
# If what is specified on the command line starts with '/' an absolute path is meant
# otherwise what is specified on the command line means a file in CONFIG_DIR.
# Files in CONFIG_DIR get automatically copied into the recovery system but
# other files are added to COPY_AS_IS to get them copied into the recovery system:
case "$config_append_file" in
(/*)
config_append_file_path="$config_append_file"
# If "-C foo" was specified on the command line but 'foo' does not exist
# try if 'foo.conf' exists and if yes, use that:
if test -r "$config_append_file_path" ; then
COPY_AS_IS=( "${COPY_AS_IS[@]}" "$config_append_file_path" )
else if test -r "$config_append_file_path.conf" ; then
COPY_AS_IS=( "${COPY_AS_IS[@]}" "$config_append_file_path.conf" )
else
Error "There is '-C $config_append_file' but neither '$config_append_file_path' nor '$config_append_file_path.conf' can be read."
fi
fi
;;
(*)
config_append_file_path="$CONFIG_DIR/$config_append_file"
;;
esac
# If "-C foo" was specified on the command line but 'foo' does not exist
# try if 'foo.conf' exists and if yes, use that:
if test -r "$config_append_file_path" ; then
LogPrint "Sourcing additional configuration file '$config_append_file_path'"
Source "$config_append_file_path"
else if test -r "$config_append_file_path.conf" ; then
LogPrint "Sourcing additional configuration file '$config_append_file_path.conf'"
Source "$config_append_file_path.conf"
else
Error "There is '-C $config_append_file' but neither '$config_append_file_path' nor '$config_append_file_path.conf' can be read."
fi
fi
done
fi
# Now SHARE_DIR CONFIG_DIR VAR_DIR LOG_DIR and KERNEL_VERSION should be set to a fixed value:
readonly SHARE_DIR CONFIG_DIR VAR_DIR LOG_DIR KERNEL_VERSION
# Enable progress subsystem only in verbose mode, set some stuff that others can use:
if test "$VERBOSE" ; then
source $SHARE_DIR/lib/progresssubsystem.nosh
fi
SourceStage "init"
# Check for requirements, do we have all required binaries?
# Without the empty string as initial value MISSING_PROGS would be
# an unbound variable that would result an error exit if 'set -eu' is used:
MISSING_PROGS=("")
for f in "${REQUIRED_PROGS[@]}" ; do
if ! has_binary "$f" ; then
MISSING_PROGS=( "${MISSING_PROGS[@]}" "$f" )
fi
done
test "$MISSING_PROGS" && Error "Cannot find required programs: ${MISSING_PROGS[@]}"
readonly VERSION_INFO="
$PRODUCT $VERSION / $RELEASE_DATE
$PRODUCT comes with ABSOLUTELY NO WARRANTY; for details see
the GNU General Public License at: http://www.gnu.org/licenses/gpl.html
Host $( uname -n ) using Backup $BACKUP and Output $OUTPUT
Build date: $( date -R )
"
if test "$WORKFLOW" != "help" ; then
# Create temporary work area and register removal exit task:
BUILD_DIR="$( mktemp -d -t rear.XXXXXXXXXXXXXXX || Error "Could not create build area '$BUILD_DIR'" )"
QuietAddExitTask cleanup_build_area_and_end_program
Log "Using build area '$BUILD_DIR'"
ROOTFS_DIR=$BUILD_DIR/rootfs
TMP_DIR=$BUILD_DIR/tmp
mkdir -p $v $ROOTFS_DIR >&2 || Error "Could not create $ROOTFS_DIR"
mkdir -p $v $TMP_DIR >&2 || Error "Could not create $TMP_DIR"
fi
# Check for and run the requested workflow:
if has_binary WORKFLOW_$WORKFLOW ; then
Log "Running $WORKFLOW workflow"
# There could be no ARGS[@] which means it would be an unbound variable so that
# an empty default is used here to avoid an error exit if 'set -eu' is used:
WORKFLOW_$WORKFLOW "${ARGS[@]:-}"
Log "Finished running $WORKFLOW workflow"
else
VERBOSE=1
LogPrint "ERROR: The specified command '$WORKFLOW' does not exist!"
EXIT_CODE=1
fi
# Usually RUNTIME_LOGFILE=/var/log/rear/rear-$HOSTNAME.log
# The RUNTIME_LOGFILE name is set above from LOGFILE in default.conf
# but later user config files are sourced where LOGFILE can be set different
# so that the user config LOGFILE is used as final logfile name:
if test "$RUNTIME_LOGFILE" != "$LOGFILE" ; then
test "$WORKFLOW" != "help" && LogPrint "Saving $RUNTIME_LOGFILE as $LOGFILE"
cat "$RUNTIME_LOGFILE" > "$LOGFILE"
fi
# When this point is reached, the workflow is done without a real error because
# for real errors one of the Error functions should be called that kills rear
# and then the exit code is usually 143 (i.e. 128 + signal-number)
# and the Error function results an "ERROR: ..." syslog message.
# There should be no syslog message for the help workflow:
if test "$WORKFLOW" != "help" ; then
if test $EXIT_CODE -eq 0 ; then
LogToSyslog "$PROGRAM $WORKFLOW finished with zero exit code"
else
if test "checklayout" = "$WORKFLOW" -a $EXIT_CODE -eq 1 ; then
# The checklayout workflow is special because it sets EXIT_CODE=1
# when the disk layout has changed or when configuration files have changed
# but that exit code 1 is no error but meant as a signal that things have changed
# which require a new ISO image so that users can run "rear checklayout || rear mkrescue"
# see https://github.com/rear/rear/issues/564
LogToSyslog "$PROGRAM checklayout finished with exit code 1 (layout or config changed)"
else
LogToSyslog "$PROGRAM $WORKFLOW failed with exit code $EXIT_CODE"
fi
fi
fi
exit $EXIT_CODE