blob: b09479ae6199dbc2128ff01bbe7cc7ceced8da7b (
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
|
#!/hint/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
[[ -z ${DEVTOOLS_INCLUDE_CONFIG_SH:-} ]] || return 0
DEVTOOLS_INCLUDE_CONFIG_SH=1
set -e
readonly XDG_DEVTOOLS_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/devtools"
readonly XDG_DEVTOOLS_GITLAB_CONFIG="${XDG_DEVTOOLS_DIR}/gitlab.conf"
# default config variables
export GITLAB_TOKEN=""
load_devtools_config() {
# temporary permission fixup
if [[ -d "${XDG_DEVTOOLS_DIR}" ]]; then
chmod 700 "${XDG_DEVTOOLS_DIR}"
fi
if [[ -f "${XDG_DEVTOOLS_GITLAB_CONFIG}" ]]; then
chmod 600 "${XDG_DEVTOOLS_GITLAB_CONFIG}"
fi
if [[ -n "${DEVTOOLS_GITLAB_TOKEN}" ]]; then
GITLAB_TOKEN="${DEVTOOLS_GITLAB_TOKEN}"
return
fi
if [[ -f "${XDG_DEVTOOLS_GITLAB_CONFIG}" ]]; then
GITLAB_TOKEN=$(grep GITLAB_TOKEN "${XDG_DEVTOOLS_GITLAB_CONFIG}"|cut -d= -f2|cut -d\" -f2)
return
fi
GITLAB_TOKEN=""
}
save_devtools_config() {
# temporary permission fixup
if [[ -d "${XDG_DEVTOOLS_DIR}" ]]; then
chmod 700 "${XDG_DEVTOOLS_DIR}"
fi
if [[ -f "${XDG_DEVTOOLS_GITLAB_CONFIG}" ]]; then
chmod 600 "${XDG_DEVTOOLS_GITLAB_CONFIG}"
fi
(
umask 0077
mkdir -p "${XDG_DEVTOOLS_DIR}"
printf 'GITLAB_TOKEN="%s"\n' "${GITLAB_TOKEN}" > "${XDG_DEVTOOLS_GITLAB_CONFIG}"
)
}
|