aboutsummaryrefslogtreecommitdiffstats
path: root/rc.d/init.d/functions
diff options
context:
space:
mode:
Diffstat (limited to 'rc.d/init.d/functions')
-rw-r--r--rc.d/init.d/functions16
1 files changed, 16 insertions, 0 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index 3acd1707..d54361c3 100644
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -625,6 +625,22 @@ is_ignored_file() {
return 1
}
+# Convert the value ${1} of time unit ${2}-seconds into seconds:
+convert2sec() {
+ local retval=""
+
+ case "${2}" in
+ deci) retval=$(awk "BEGIN {printf \"%.1f\", ${1} / 10}") ;;
+ centi) retval=$(awk "BEGIN {printf \"%.2f\", ${1} / 100}") ;;
+ mili) retval=$(awk "BEGIN {printf \"%.3f\", ${1} / 1000}") ;;
+ micro) retval=$(awk "BEGIN {printf \"%.6f\", ${1} / 1000000}") ;;
+ nano) retval=$(awk "BEGIN {printf \"%.9f\", ${1} / 1000000000}") ;;
+ piko) retval=$(awk "BEGIN {printf \"%.12f\", ${1} / 1000000000000}") ;;
+ esac
+
+ echo "${retval}"
+}
+
# Evaluate shvar-style booleans
is_true() {
case "$1" in