blob: b47fa713530f6b54764334981a561af2dd1a3bf7 (
plain)
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
|
#!/bin/sh
PREFIX=@PREFIX@
PROGRAM=`basename $0`
echon () {
if [ X"$ECHON" = X ]; then
# Determine how to "echo" without newline: "echo -n"
# or "echo ...\c"
if [ X`echo -n` = X-n ]; then
ECHON=echo
NNL="\c"
# "
else
ECHON="echo -n"
NNL=""
fi
fi
$ECHON "$*$NNL"
}
# echo if in verbose mode
vecho() {
[ -n "$VERBOSE" ] && echo "$@"
}
# echo unless quiet mode
qecho() {
[ -z "$QUIET" ] && echo "$@"
}
# echo to stderr
eecho() {
echo "$@" >&2
}
# echo to stderr and exit with error
die() {
eecho "$@"
exit 1
}
init_tmpdir() {
local omask=`umask`
local __tmpd="/tmp/$PROGRAM-${$}-`date +%s`-$RANDOM"
umask 077 || die "umask"
mkdir -p "$__tmpd" || exit 1
trap "rm -fr \"$__tmpd\"; exit" 0
umask $omask
eval "$1=\"$__tmpd\""
}
pkg_inst() {
[ -z "$NOCOMMIT" ] && apk add -q $*
}
pkg_deinst() {
[ -z "$NOCOMMIT" ] && apk del -q $*
}
default_read() {
local n
read n
[ -z "$n" ] && n="$2"
eval "$1=\"$n\""
}
invalid_ip() {
[ "$1" ] || return 0
! ipcalc -s $1
}
cfg_add() {
[ -z "$NOCOMMIT" ] && lbu_add "$@"
}
|