blob: e206a477a5843feb0f4ffdb04d028df477ee2fb5 (
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
|
# Copyright (C) 2024-2026 Maria Lisina
# Copyright (C) 2024-2026 Danil Lisin
# SPDX-License-Identifier: Apache-2.0
if [[ -z "${ib_login}" ]]
then
if [[ -f "${login_file}" ]]
then
ib_login="$(< "${login_file}")"
else
output_text="You must specify ${ib_login_word} and ${ib_key_word}"
return
fi
fi
if [[ -z "${ib_key}" ]]
then
if [[ -f "${key_file}" ]]
then
ib_key="$(< "${key_file}")"
else
output_text="You must specify ${ib_key_word}"
return
fi
fi
if ! mkdir -p "${auth_dir}"
then
output_text="Failed to create user config"
log_text="ib_auth (${update_id}): ${output_text}"
source "${units}/log.zsh"
return
fi
case "${ib_board}" in
(a|d)
source "${auth}/donmai.zsh"
;;
(g)
source "${auth}/gelbooru.zsh"
;;
(i|s)
source "${auth}/sankakucomplex.zsh"
;;
(k|y)
source "${auth}/moebooru.zsh"
;;
esac
if [[ -z "${output_text}" ]]
then
printf "%s\n" "${ib_login}" > "${login_file}"
printf "%s\n" "${ib_key}" > "${key_file}"
else
for user_data_dir in "${auth_dir}" "${user_config}"
do
user_data=($(ls -1 "${user_data_dir}"))
if [[ ${#user_data} -eq 0 ]]
then
rmdir "${user_data_dir}"
fi
done
fi
|