File: variables.sh

package info (click to toggle)
json2file-go 1.15
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 184 kB
  • sloc: sh: 298; makefile: 10
file content (82 lines) | stat: -rw-r--r-- 2,225 bytes parent folder | download | duplicates (2)
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
# Set and export shell variables for json2file-go

# DEFAULT VALUES
CONFDIR="/etc/json2file-go"
DEFAULT_BASEDIR="/var/spool/json2file-go"
DEFAULT_SOCKDIR="/run/json2file-go"

# DAEMON Variables
cf="basedir"
if [ -f "${CONFDIR}/${cf}" ]; then
    export J2F_BASEDIR="$(head -1 "${CONFDIR}/${cf}")"
else
    export J2F_BASEDIR="${DEFAULT_BASEDIR}"
fi
cf="bind"
if [ -f "${CONFDIR}/${cf}" ]; then
    export J2F_BIND="$(head -1 "${CONFDIR}/${cf}")"
fi
cf="debug"
if [ -f "${CONFDIR}/${cf}" ]; then
    export J2F_DEBUG="$(head -1 "${CONFDIR}/${cf}")"
else
    export J2F_DEBUG=""
fi
cf="dirlist"
if [ -f "${CONFDIR}/${cf}" ]; then
    export J2F_DIRLIST="$(paste -s -d';' "${CONFDIR}/${cf}")"
fi
cf="signature_headers"
if [ -f "${CONFDIR}/${cf}" ]; then
    export J2F_SIGNATURE_HEADERS="$(paste -s -d',' "${CONFDIR}/${cf}")"
fi
cf="token_headers"
if [ -f "${CONFDIR}/${cf}" ]; then
    export J2F_TOKEN_HEADERS="$(paste -s -d',' "${CONFDIR}/${cf}")"
fi
cf="token_fields"
if [ -f "${CONFDIR}/${cf}" ]; then
    export J2F_TOKEN_FIELDS="$(paste -s -d',' "${CONFDIR}/${cf}")"
fi
cf="certfile"
if [ -f "${CONFDIR}/${cf}" ]; then
    export J2F_CERTFILE="$(head -1 "${CONFDIR}/${cf}")"
fi
cf="keyfile"
if [ -f "${CONFDIR}/${cf}" ]; then
    export J2F_KEYFILE="$(head -1 "${CONFDIR}/${cf}")"
fi
cf="host"
if [ -f "${CONFDIR}/${cf}" ]; then
    export J2F_HOST="$(head -1 "${CONFDIR}/${cf}")"
fi
cf="port"
if [ -f "${CONFDIR}/${cf}" ]; then
    export J2F_PORT="$(head -1 "${CONFDIR}/${cf}")"
fi
cf="url_prefix"
if [ -f "${CONFDIR}/${cf}" ]; then
    export J2F_URL_PREFIX="$(head -1 "${CONFDIR}/${cf}")"
fi
cf="socket"
if [ -f "${CONFDIR}/${cf}" ]; then
    export J2F_SOCKET="$(head -1 "${CONFDIR}/${cf}")"
elif [ -z "${J2F_HOST}" ] && [ -z "${J2F_PORT}" ]; then
    export J2F_SOCKET="${DEFAULT_SOCKDIR}/socket"
fi

# Supervisor variables

# Set umask
if [ -n "${J2F_UMASK}" ]; then
    umask "${J2F_UMASK}"
fi
# Create the directory for the socket if it does not exist
if [ -n "${J2F_SOCKET}" ]; then
    RUNDIR="$(dirname "${J2F_SOCKET}")"
    if [ ! -d "${RUNDIR}" ]; then
        if mkdir "${RUNDIR}" 2> /dev/null && [ -n "${J2F_CHUSER}" ]; then
            chown "${J2F_CHUSER}:" "${J2F_CHUSER}" || true
        fi
    fi
fi