mirror of
https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git
synced 2025-12-16 03:42:44 +03:00
* switch from phase functions to variables containing list of actions * init actions prefixed with 'init__' * refine output during init * add syslog entries * add --setup for putting init scripts in the right runlevel
32 lines
774 B
Bash
32 lines
774 B
Bash
# Tiny Cloud - common script functions
|
|
# vim: ts=4 et ft=sh:
|
|
|
|
# set defaults
|
|
[ -f "$ROOT/etc/tiny-cloud.conf" ] && . "$ROOT/etc/tiny-cloud.conf"
|
|
: "${CLOUD:=unknown}"
|
|
: "${CLOUD_USER:=alpine}"
|
|
: "${TINY_CLOUD_LOGS:=$ROOT/var/log}"
|
|
: "${TINY_CLOUD_VAR:=$ROOT/var/lib/cloud}"
|
|
|
|
log() {
|
|
local facility="local7"
|
|
local stderr
|
|
local tag=$(basename "$0")
|
|
while [ "${1#-}" != "$1" ]; do
|
|
case "$1" in
|
|
-f) facility="$2"; shift ;;
|
|
-s) stderr=-s ;;
|
|
-t) tag="$tag/$2"; shift ;;
|
|
esac
|
|
shift
|
|
done
|
|
local level="$1"
|
|
[ -z "$DEBUG" ] && [ "$level" = debug ] && return
|
|
shift
|
|
|
|
logger $stderr -p "$facility.$level" -t "$tag[$$]" "$@"
|
|
case "$level" in
|
|
crit|alert|emerg) exit 1 ;;
|
|
esac
|
|
}
|