Changes notes of work done prior initial commit to git removed (see below)

-##################################
-# Change Notes
-#
-# 2013-02-05: (miGi)
-# - First version of the script
-# 2013-02-06: (miGi)
-# - CPU temperature check changed to core 0
-# - A few changes to the logging
-# 2013-02-07: (fritz)
-# - correction of "Bad number" error in case of portable memory stick
-# - verification of the input parameters added
-# - check temperature of all CPUs / CPU cores
-# - log device model correctly even if it contains spaces (which is the
case for me)
-# - log device serial number correctly even if it contains spaces
-# - temperature of disks moved to the end of the line (readability)
-##################################
Changes notes of work done prior initial commit to git removed (see below)

-####################################################################
-# Change Notes:
-#
-# 2012-08-21:
-# - First issue of the script
-# 2012-08-22:
-# - New function: get_list_of_running_scripts()
-# 2012-09-10:
-# - Slight robustness improvement in rge create_lock_folder()
-# 2012-12-14:
-# - New functtion "reset_locks"
-# - Function "allow_scripts_to_start" modified (now it only resets
-#   the "CFG_FORBID_ANY_SCRIPT_START_FILE", instead of deleting all
locks
-# 2012-12-15:
-# - Minor changes in documentation in order to make clear, that
-#   the lock file should not necessary use the script name as
-#   name of the lock
-# 2012-12-17:
-# - constants defining path to utilities (like date, rm...) moved to
config.sh
-# - bugfix: before: Function "get_list_of_running_scripts" returned the
list
-#   of running script separated by a new line. Now: the items are
separated
-#   by a semicolon (to void issues during data logging)
-# - In fct "script_start": now different return codes for "script with
same
-#   id already running" and "no script allowed to be executed"
-# 2013-01-08:
-#       - minor changes in declaration of local variables
-#       - new function "run_main"
-# 2013-01-12:
-#       - mail not sent within the fct "run_main" anymore
-# 2013-01-13:
-#       - bug fix in "run_main". In case error occured in main, the
lock was not
-#   deleted at the end of the fct
-##################################
Changes notes of work done prior initial commit to git removed (see below)

-####################################################################
-# Change Notes:
-#
-# 2010-12-29:
-# First issue of the script
-# 2011-01-02:
-# Bug fix (Method to detect if data were provided by through the pipe
-# or with an dedicated argument)
-# 2011-01-03:
-# - Bug fix in timestamp generation (wrong year was provided in some
cases)
-# - New functions "ts_format" and "get_log_entries"
-# - Bug fix in function "get_log_entries": one more line returned
-# 2011-10-21:
-# - New function "get_log_entries_ts"
-# 2011-11-04:
-# - Bug fix in function "get_log_entries"
-# 2012-08-21:
-# - Minor typo corrected
-# 2012-09-10:
-# - Bug fix, the lines to be returned were not computed accurately
-#   (up to 2 lines more than expected were returned)
-# 2012-12-14:
-# - New function (get_log_oldest_ts) returning the oldest timestamp in
a log
-# 2012-12-17:
-# - constants defining path to utilities (like date, rm...) moved to
config.sh
-# 2013-01-08:
-#       - minor changes in declaration of local variables
-# 2013-01-13:
-#       - improvement of robusteness of fct "get_log_oldest_ts"
-#   (handle case where the log does not have the right format)
-#       - few variables declared readonly
-####################################################################
Changes notes of work done prior initial commit to git removed (see below)

-####################################################################
-# Change notes:
-#
-# 2010-12-30:
-#  - First issue of the script
-# 2010-12-31:
-#  - Minor bug fix
-# 2011-09-12:
-#  - Recipient e-mail address changed
-# 2011-12-17:
-# - constants that may be changed by the user moved to config.sh
-# 2013-01-08:
-#       - minor changes in declaration of local variables
-####################################################################
Changes notes of work done prior initial commit to git removed (see below)

-####################################################################
-# Change Notes:
-#
-# 2010-08-21:
-# - Creation of the change notes
-# - Functions available: "convertTimestamp", "sortSnapshots",
-#   "getSnapTimestamp" and "getSnapTimestamp1970"
-# 2010-12-30:
-# - Script adapted for FreeNAS 0.7.2 (was for open solaris before)
-# 2011-01-01:
-# - Bug fix in function "getSnapTimestamp1970"
-# 2011-01-03:
-# - Bug fix in function "getTimestampFormat" (format changed
-#   from "%G%m%d_%H%M" to "%Y%m%d_%H%M")
-# 2012-12-17:
-# - constants defining path to utilities (like date, rm...) moved to
config.sh
-# 2012-12-25:
-# - performance of function sortSnapshots improved
-# 2013-01-03:
-#       - new snapshot naming rules to be compatible with NAS4Free
-#         CIFS shadow copies function:
-#   new function "generateSnapshotName"
-#   function "sortSnapshots" modified
-# 2013-01-06:
-#       - code of function sortSnapshots simplified
-# - fcts "convertTimestamp", "getSnapTimestamp" and
""getTimestampFormat"" deleted
-# 2013-01-08:
-#       - minor changes in declaration of local variables
-# 2013-01-13:
-#       - few variables declared readonly
-####################################################################
Changes notes of work done prior initial commit to git removed (see below)

-####################################################################
-# Change Notes:
-#
-# 2012-12-17:
-#       - First issue of the script
-# 2013-01-12:
-#       - double quotes added around certain variables
-# 2013-02-07:
-#       - smartctl added
-####################################################################
Changes notes of work done prior initial commit to git removed (see below)

-##################################
-# Change Notes
-#
-# 2012-08-21:
-# - Initial version of the script
-# 2012-08-22:
-# - Various bug fixes
-# 2012-08-29:
-# - Mail notification removed
-# 2012-12-05:
-#    Major rework and enhancement of the script:
-# - Script renamed into manageSleep.sh (before: safeShutdown.sh)
-# - The script should not be scheduled by cron anymore
-#   but called once at NAS startup
-# - Script set the NAS to sleep if no other devices are online
-#   during more than a certain duration, or if a configurable
-#   time is reached
-# 2012-12-08:
-# - Logging of system state added (this replaces the scripts run after
startup / before shutdown)
-# - "always-on" timeslot added
-# - Comments improved
-# 2012-12-09:
-# - Bug fix in function "isInTimeSlot"
-# - Bug fix in check if any other device is online (bad computation of
duration
-#   since the last device went offline)
-# 2012-12-10:
-# - It is now possible to pass the necessary params as argument of the
script
-#  - Log the selected configuration when the script starts
-#  - Send mail in case an error occurs
-# 2012-12-10:
-# - Support for ACPI state 3 (Suspend to RAM) added
-# - Bug fix: Lock not created anymore at script startup
-# 2012-12-11:
-# - New option -v: verbose
-# - New option -m: send mail on acpi state change
-# - Bug fix: script locks deleted at startup
-# 2012-12-11:
-# - Path to ACPI conf corrected
-# - support of ACPI state 3 added
-# - minor bugfix in parsing of arguments
-# - minor bugfixes in logging
-# 2012-12-14:
-# - Bug fix: Scripts are now allowed to start if the NAS shall not
sleep anymore
-#   (e.g. nas request sleep, but cannot because a script is running,
and
-#   before and of script execution, another device starts, so that the
nas
-#   should not sleep anymore)
-# - Monitor if other devices are online, even during the initial phase
-#   during which the NAS shall stay awake
-# 2012-12-17:
-#       - Variable TMPFILE renamed in LOGFILE
-# - constants defining path to utilities (like date, rm...) moved to
config.sh
-# 2013-01-06:
-#       - More compact coding for verbose logging
-# 2013-01-08:
-#       - minor changes in declaration of local variables
-# 2013-01-13:
-#       - few variables declared read only
-##################################
Changes notes of work done prior initial commit to git removed (see below)

-####################################################################
-# Change Notes:
-#
-# 2010-03-07:
-# Script completely rewritten in order to be more robust
-# in case the computer is not always switched on.
-# Instead of having to be called daily, weekly and monthly
-# by cron, it is now only necessary to call the script daily.
-# 2010-03-08:
-# Now using an external script for sorting the snapshots
-# according to their creation date
-# 2010-03-15:
-# - Common functions put into another shell script, used in this script
-# 2010-08-15:
-# location of the log file changed to "/export/home/xxxxx/scripts/logs"
-# instead of "/export/home/xxxxx/scripts/logs"
-# 2010-12-30:
-# - Script adapted to FreeNAS 0.7.2
-# - Logging modified to harmonize the format of the log file
-# 2010-12-31:
-# - Send a mail in case an issue is detected
-# - Function aimed at deleting old snapshots added to the script
-#   (This fucntion was in a separate file before)
-# 2011-01-01:
-# - Hourly tag added
-# 2011-01-02:
-# - Bug fix in "main" function
-# 2011-10-09:
-# - Function deleteOldSnapshots modified so that it does not delete
-#   any snapshot if the number of snapshots to be kept is lower than 0
-# - Function renameSnapshots modified so that it renames a snapshot if
-#   the age difference between the high frequency snapshot and low
-#   frequency snapshot is greater or equal (and not strictly greater)
-#   than the period given as paramter
-# - Additional parameters supported by the script:
-#   [-n] [-h num] [-d num] [-w num] [-m num]
-# 2011-10-21:
-# - Pool import added at the beginning of the script
-# - Pool export added at the beginning of the script
-#       - Script modified in order to mail only the lines
-#         that have been written in the logfile during the current
execution
-# 2011-10-22:
-# - Name of the log file modified in order to contain the name of the
-#   filesystem for which snapshots shall be created
-#       - Minor changes to improve code quality
-# 2012-08-21:
-# - Minor fix in logged data (the number of snapshot kept was erroneous
in the log)
-# - Create lock file at when starting the execution
-# - Delete lock file at the end of the execution
-# - Prevent several instances of the script to run at the same time
-# 2012-09-25:
-#       - Pool not imported / exported anymore
-# 2012-12-11:
-#       - New option -k
-# 2012-12-17:
-#       - Variable TMPFILE renamed in LOGFILE
-# - constants defining path to utilities (like date, rm...) moved to
config.sh
-#       - log why the script could not be started (differentiate the
return codes)
-#       - allow 2 instances for difference FS to run concurrently
-# 2012-12-18:
-#       - Bugfix: the wrong lock id was passed to script_end()
-# 2012-12-24:
-#       - corrected text in log error
-# 2013-01-01:
-#       - snapshot never renamed anymore (because it could lead to
issues
-#   with the backup function)
-# - performance improved
-# 2013-01-02:
-#       - reference to obsolete script commonPoolFct.sh removed
-# - bug fix in snapshot creation function. Never create a snapshot if
the max
-#   number of snapshots to be created is 0
-# 2013-01-03:
-#       - new snapshot naming rules to be compatible with NAS4Free
-#   CIFS shadow copies function
-# 2013-01-04:
-#       - improvements in code quality (no functionnal impact)
-#       - do not send a error mail in case the NAS is about to shut
down
-# 2013-01-06:
-#       - minor changes induced by changes in "commonSnapFcts.sh"
-# 2013-01-08:
-#       - minor changes in declaration of local variables
-# 2013-01-12:
-#       - lock management moved to fct "run_main"
-# 2013-01-14:
-#       - few variables declared readonly
-####################################################################
Changes notes of work done prior initial commit to git removed (see below)

-##################################
-# Change Notes
-#
-# 2010-01-03:
-# First issue of the script
-# 2012-12-17:
-# - constants defining path to utilities (like date) moved to config.sh
-# 2012-12-22:
-# - minor bugfix
-# 2013-01-13:
-# - few variables declared readonly
-##################################
Changes notes of work done prior initial commit to git removed (see below)

-##################################
-# Change Notes
-#
-# 2010-08-15:
-# - Initial version written for opensolaris 2009.06
-# 2010-12-29:
-# - Script modified for FreeNAS 0.7.2
-# - Successive calls of the script saved in the same log file (instead
of creating
-#   a log file for each call
-# 2010-12-30:
-# - Mail sent in case an issue was detected
-# 2011-10-21:
-#       - Script modified in order to mail only the lines
-#         that have been written in the logfile during the current
execution
-# 2011-10-22:
-#       - Minor changes to improve code quality
-# 2012-08-21:
-#       - Create lock file at when starting the execution
-#       - Delete lock file at the end of the execution
-#       - Prevent several instances of the script to run at the same
time
-# 2012-12-17:
-#       - Variable TMPFILE renamed in LOGFILE
-# - constants defining path to utilities (like zpool, date...) moved to
config.sh
-#       - log why the script could not be started (differentiate the
return codes)
-# 2012-12-24:
-#       - corrected text in log error
-# 2012-12-29:
-#       - scrubbing all pools at concurrently instead of one after the
other
-#   in order to save time
-# 2013-01-04:
-#       - do not send a error mail in case the NAS is about to shut
down
-# 2013-01-12:
-#       - lock management moved to fct "run_main"
-# 2013-01-13:
-#       - few variables declared readonly
-##################################