-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
149 lines (145 loc) · 3 KB
/
install
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/sh
set -u
set_completion() {
module="_sigchk_module()
{
local cur prev OPTS
COMPREPLY=()
cur=\"\${COMP_WORDS[COMP_CWORD]}\"
prev=\"\${COMP_WORDS[COMP_CWORD-1]}\"
case \$prev in
'-h'|'--help'|'--version')
return 0
;;
esac
case \$cur in
-*)
OPTS=\"
--fingerprint
--timestamp
--strict
--ignore-missing
--no-exceptions
--no-cert-exceptions
--no-local
--colour
--help
--version
--quiet
\"
COMPREPLY=( \$(compgen -W \"\${OPTS[*]}\" -- \$cur) )
return 0
;;
esac
_filedir '@(7[zZ]|[aA][vV][iI]|[bB][iI][nN]|[eE][xX][eE]|[gG][zZ]|[jJ][pP][gG]|[jJ][pP][eE][gG]|[mM][kK][vV]|[mM][pP]4|[pP][dD][fF]|[pP][nN][gG]|[rR][aA][rR]|[zZ][iI][pP])'
return 0
}
complete -F _sigchk_module sigchk"
if [ -d "${bash_dir}" ]; then
echo "${module}" > "${1}"
if [ -s "${1}" ]; then
return 0
else
return 1
fi
else
return 1
fi
}
main() {
target="${0%"/"*}/"
if ! [ -d "${target:-""}" ]; then
target=""
fi
target="${target}sigchk"
if ! [ -e "${target}" ]; then
echo "${0##*"/"}: sigchk: Is not found" 1>&2
exit 1
fi
case "${UID:-"1000"}" in
0)
echo "${0##*"/"}: access level: root" 1>&2
app_dir="/usr/local/bin"
if [ -e "/etc/bash_completion" ]; then
bash_dir="/usr/share/bash-completion/completions"
fi
;;
*)
echo "${0##*"/"}: access level: user" 1>&2
app_dir="${HOME:-"/home/${USER}"}/.local/bin"
if ! [ -d "${app_dir}" ]; then
if ! mkdir -p -- "${app_dir}" 2>/dev/null; then
echo "${0##*"/"}: sigchk: FAILED" 1>&2
code=1
return 1
fi
fi
if [ -e "/etc/bash_completion" ]; then
bash_dir="${HOME:-"/home/${USER}"}/.local/share/bash-completion/completions"
if ! [ -d "${bash_dir}" ]; then
if ! mkdir -p -- "${bash_dir}" 2>/dev/null; then
echo "${0##*"/"}: bash-completion: FAILED" 1>&2
code=1
return 1
fi
fi
fi
;;
esac
if [ -n "${bash_dir:-""}" ]; then
if [ "${target}" -nt "${bash_dir}/sigchk" ]; then
if set_completion "${bash_dir}/sigchk"; then
echo "${0##*"/"}: bash-completion: OK" 1>&2
else
echo "${0##*"/"}: bash-completion: FAILED" 1>&2
code=1
return 1
fi
elif ! [ -e "${bash_dir}/sigchk" ]; then
if set_completion "${bash_dir}/sigchk"; then
echo "${0##*"/"}: bash-completion: OK" 1>&2
else
echo "${0##*"/"}: bash-completion: FAILED" 1>&2
code=1
return 1
fi
else
echo "${0##*"/"}: bash-completion: Is already installed" 1>&2
fi
fi
if [ -n "${app_dir:-""}" ]; then
if [ "${target}" -nt "${app_dir}/sigchk" ]; then
:
elif ! [ -e "${app_dir}/sigchk" ]; then
:
else
echo "${0##*"/"}: sigchk: Is already installed" 1>&2
return 0
fi
if [ -f "${target}" ]; then
if cp -- "${target}" "${app_dir}/sigchk" 2>/dev/null; then
if ! chmod +x -- "${app_dir}/sigchk" 2>/dev/null; then
code=1
return 1
fi
else
code=1
return 1
fi
else
echo "${0##*"/"}: sigchk: Is not found" 1>&2
code=1
return 1
fi
fi
case "${code:-"0"}" in
0)
echo "${0##*"/"}: sigchk: OK"
;;
*)
echo "${0##*"/"}: sigchk: FAILED"
;;
esac
}
main
exit "${code:-"0"}"