karnel-termux 4.17.38 → 4.17.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/karnel/RELEASE_COMMIT +1 -1
- package/karnel/cli/commands/plugin.sh +131 -0
- package/karnel/modules/deploy.sh +14 -42
- package/karnel/modules/games.sh +10 -48
- package/karnel/modules/network.sh +10 -48
- package/karnel/modules/utils.sh +10 -48
- package/karnel/tools/plugins/install.sh +76 -3
- package/karnel/tools/security/aircrack-ng/install.sh +14 -36
- package/karnel/tools/security/binwalk/install.sh +11 -33
- package/karnel/tools/security/dirb/install.sh +11 -33
- package/karnel/tools/security/exiftool/install.sh +11 -33
- package/karnel/tools/security/foremost/install.sh +11 -33
- package/karnel/tools/security/hashcat/install.sh +11 -33
- package/karnel/tools/security/hydra/install.sh +11 -33
- package/karnel/tools/security/john/install.sh +11 -33
- package/karnel/tools/security/netcat/install.sh +14 -36
- package/karnel/tools/security/nmap/install.sh +11 -33
- package/karnel/tools/security/smbclient/install.sh +11 -33
- package/karnel/tools/security/steghide/install.sh +11 -33
- package/karnel/tools/security/tcpdump/install.sh +11 -33
- package/karnel/tools/security/whois/install.sh +11 -33
- package/package.json +1 -1
package/karnel/RELEASE_COMMIT
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
dd742786e4b42ebc678470be889eb813a6a47c71
|
|
@@ -25,6 +25,23 @@ plugin_main() {
|
|
|
25
25
|
update)
|
|
26
26
|
_plugin_update_main "$@"
|
|
27
27
|
;;
|
|
28
|
+
enable)
|
|
29
|
+
if [[ $# -ne 1 ]]; then
|
|
30
|
+
log_error "Usage: karnel plugin enable <name>"
|
|
31
|
+
return 1
|
|
32
|
+
fi
|
|
33
|
+
_plugin_enable "$1"
|
|
34
|
+
;;
|
|
35
|
+
disable)
|
|
36
|
+
if [[ $# -ne 1 ]]; then
|
|
37
|
+
log_error "Usage: karnel plugin disable <name>"
|
|
38
|
+
return 1
|
|
39
|
+
fi
|
|
40
|
+
_plugin_disable "$1"
|
|
41
|
+
;;
|
|
42
|
+
config)
|
|
43
|
+
_plugin_config_main "$@"
|
|
44
|
+
;;
|
|
28
45
|
list|ls)
|
|
29
46
|
if [[ $# -ne 0 ]]; then
|
|
30
47
|
log_error "Usage: karnel plugin list"
|
|
@@ -85,6 +102,114 @@ _plugin_install_main() {
|
|
|
85
102
|
install_plugin "$target" "$unsafe_flag"
|
|
86
103
|
}
|
|
87
104
|
|
|
105
|
+
_plugin_enable() {
|
|
106
|
+
local name="$1"
|
|
107
|
+
local plugin_dir plugin_root
|
|
108
|
+
|
|
109
|
+
_plugin_validate_name "$name" || return 1
|
|
110
|
+
_plugin_require_jq || return 1
|
|
111
|
+
_plugin_prepare_plugins_dir || return 1
|
|
112
|
+
plugin_dir="$PLUGINS_DIR/$name"
|
|
113
|
+
if [[ ! -d "$plugin_dir" ]]; then
|
|
114
|
+
log_error "Plugin '$name' is not installed."
|
|
115
|
+
return 1
|
|
116
|
+
fi
|
|
117
|
+
plugin_root="$(_plugin_validate_installed_plugin "$plugin_dir" "$name")" || return 1
|
|
118
|
+
if _plugin_is_enabled "$plugin_root"; then
|
|
119
|
+
log_info "Plugin '$name' is already enabled."
|
|
120
|
+
return 0
|
|
121
|
+
fi
|
|
122
|
+
_plugin_set_enabled "$plugin_root" "true" || return 1
|
|
123
|
+
log_success "Plugin '$name' enabled."
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_plugin_disable() {
|
|
127
|
+
local name="$1"
|
|
128
|
+
local plugin_dir plugin_root
|
|
129
|
+
|
|
130
|
+
_plugin_validate_name "$name" || return 1
|
|
131
|
+
_plugin_require_jq || return 1
|
|
132
|
+
_plugin_prepare_plugins_dir || return 1
|
|
133
|
+
plugin_dir="$PLUGINS_DIR/$name"
|
|
134
|
+
if [[ ! -d "$plugin_dir" ]]; then
|
|
135
|
+
log_error "Plugin '$name' is not installed."
|
|
136
|
+
return 1
|
|
137
|
+
fi
|
|
138
|
+
plugin_root="$(_plugin_validate_installed_plugin "$plugin_dir" "$name")" || return 1
|
|
139
|
+
if ! _plugin_is_enabled "$plugin_root"; then
|
|
140
|
+
log_info "Plugin '$name' is already disabled."
|
|
141
|
+
return 0
|
|
142
|
+
fi
|
|
143
|
+
_plugin_set_enabled "$plugin_root" "false" || return 1
|
|
144
|
+
log_success "Plugin '$name' disabled."
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
_plugin_config_main() {
|
|
148
|
+
if [[ $# -eq 0 ]]; then
|
|
149
|
+
log_error "Usage: karnel plugin config <name> [key] [value]"
|
|
150
|
+
log_info " karnel plugin config <name> Show all config"
|
|
151
|
+
log_info " karnel plugin config <name> <key> Get a config value"
|
|
152
|
+
log_info " karnel plugin config <name> <key> <value> Set a config value"
|
|
153
|
+
log_info " karnel plugin config <name> --delete <key> Delete a config key"
|
|
154
|
+
return 1
|
|
155
|
+
fi
|
|
156
|
+
|
|
157
|
+
local name="$1"
|
|
158
|
+
shift
|
|
159
|
+
local plugin_dir plugin_root
|
|
160
|
+
|
|
161
|
+
_plugin_validate_name "$name" || return 1
|
|
162
|
+
_plugin_require_jq || return 1
|
|
163
|
+
_plugin_prepare_plugins_dir || return 1
|
|
164
|
+
plugin_dir="$PLUGINS_DIR/$name"
|
|
165
|
+
if [[ ! -d "$plugin_dir" ]]; then
|
|
166
|
+
log_error "Plugin '$name' is not installed."
|
|
167
|
+
return 1
|
|
168
|
+
fi
|
|
169
|
+
plugin_root="$(_plugin_validate_installed_plugin "$plugin_dir" "$name")" || return 1
|
|
170
|
+
|
|
171
|
+
if [[ $# -eq 0 ]]; then
|
|
172
|
+
local config
|
|
173
|
+
config="$(_plugin_get_config "$plugin_root")"
|
|
174
|
+
if [[ "$config" == "{}" ]]; then
|
|
175
|
+
log_info "Plugin '$name' has no configuration."
|
|
176
|
+
else
|
|
177
|
+
echo "$config" | jq -r 'to_entries[] | " \(.key) = \(.value)"'
|
|
178
|
+
fi
|
|
179
|
+
return 0
|
|
180
|
+
fi
|
|
181
|
+
|
|
182
|
+
if [[ "$1" == "--delete" ]]; then
|
|
183
|
+
if [[ $# -ne 2 ]]; then
|
|
184
|
+
log_error "Usage: karnel plugin config <name> --delete <key>"
|
|
185
|
+
return 1
|
|
186
|
+
fi
|
|
187
|
+
_plugin_delete_config "$plugin_root" "$2" || return 1
|
|
188
|
+
log_success "Config '$2' deleted from plugin '$name'."
|
|
189
|
+
return 0
|
|
190
|
+
fi
|
|
191
|
+
|
|
192
|
+
if [[ $# -eq 1 ]]; then
|
|
193
|
+
local val
|
|
194
|
+
val="$(_plugin_get_config "$plugin_root" "$1")"
|
|
195
|
+
if [[ -z "$val" ]]; then
|
|
196
|
+
log_info "Config '$1' is not set for plugin '$name'."
|
|
197
|
+
else
|
|
198
|
+
echo "$val"
|
|
199
|
+
fi
|
|
200
|
+
return 0
|
|
201
|
+
fi
|
|
202
|
+
|
|
203
|
+
if [[ $# -eq 2 ]]; then
|
|
204
|
+
_plugin_set_config "$plugin_root" "$1" "$2" || return 1
|
|
205
|
+
log_success "Config '$1' set for plugin '$name'."
|
|
206
|
+
return 0
|
|
207
|
+
fi
|
|
208
|
+
|
|
209
|
+
log_error "Usage: karnel plugin config <name> [key] [value]"
|
|
210
|
+
return 1
|
|
211
|
+
}
|
|
212
|
+
|
|
88
213
|
_plugin_update_main() {
|
|
89
214
|
local name=""
|
|
90
215
|
local unsafe_flag=""
|
|
@@ -132,6 +257,9 @@ plugin_help() {
|
|
|
132
257
|
printf " ${D_CYAN}%-30s${NC} %s\n" "install <owner/repo> --unsafe" "Install an unreviewed plugin after confirmation"
|
|
133
258
|
printf " ${D_CYAN}%-30s${NC} %s\n" "remove <name>" "Remove a plugin safely"
|
|
134
259
|
printf " ${D_CYAN}%-30s${NC} %s\n" "update <name>" "Atomically update an approved plugin"
|
|
260
|
+
printf " ${D_CYAN}%-30s${NC} %s\n" "enable <name>" "Enable a disabled plugin"
|
|
261
|
+
printf " ${D_CYAN}%-30s${NC} %s\n" "disable <name>" "Disable a plugin without removing it"
|
|
262
|
+
printf " ${D_CYAN}%-30s${NC} %s\n" "config <name> [key] [value]" "View or set per-plugin configuration"
|
|
135
263
|
printf " ${D_CYAN}%-30s${NC} %s\n" "list" "List installed plugins and trust source"
|
|
136
264
|
printf " ${D_CYAN}%-30s${NC} %s\n" "search [query] [filters]" "Search the approved registry"
|
|
137
265
|
printf " ${D_CYAN}%-30s${NC} %s\n" "create <name>" "Create a validated local plugin"
|
|
@@ -151,6 +279,9 @@ plugin_help() {
|
|
|
151
279
|
echo " karnel plugin install karnel-hello"
|
|
152
280
|
echo " karnel plugin install username/repo --unsafe"
|
|
153
281
|
echo " karnel plugin update karnel-hello"
|
|
282
|
+
echo " karnel plugin enable karnel-hello"
|
|
283
|
+
echo " karnel plugin disable karnel-hello"
|
|
284
|
+
echo " karnel plugin config karnel-hello greeting 'Hello World'"
|
|
154
285
|
echo " karnel plugin remove karnel-hello"
|
|
155
286
|
}
|
|
156
287
|
|
package/karnel/modules/deploy.sh
CHANGED
|
@@ -6,73 +6,45 @@ import "@/utils/colors"
|
|
|
6
6
|
LOG_FILE="$KARNEL_CACHE/install_deploy.log"
|
|
7
7
|
|
|
8
8
|
install_deploy() {
|
|
9
|
-
separator
|
|
10
|
-
|
|
11
|
-
separator
|
|
12
|
-
|
|
13
|
-
log_info "Installing deploy tools (Vercel, Railway, Netlify)..."
|
|
14
|
-
mkdir -p "$(dirname "$LOG_FILE")"
|
|
9
|
+
separator; box "Installing Deploy CLIs"; separator; echo
|
|
10
|
+
log_info "Installing deploy tools..."
|
|
15
11
|
local rc=0
|
|
16
|
-
|
|
12
|
+
import "@/tools/deploy/all"
|
|
13
|
+
install_all_deploy_tools || rc=$?
|
|
17
14
|
separator
|
|
18
|
-
|
|
19
|
-
log_success "Deploy tools installed"
|
|
20
|
-
else
|
|
21
|
-
log_warn "$rc deploy tool(s) failed to install"
|
|
22
|
-
fi
|
|
15
|
+
[[ "$rc" -eq 0 ]] && log_success "Deploy tools installed" || log_warn "$rc deploy tool(s) failed to install"
|
|
23
16
|
return "$rc"
|
|
24
17
|
}
|
|
25
18
|
|
|
26
|
-
_install_deploy_wrapper() {
|
|
27
|
-
import "@/tools/deploy/all"
|
|
28
|
-
install_all_deploy_tools
|
|
29
|
-
return $?
|
|
30
|
-
}
|
|
31
|
-
|
|
32
19
|
uninstall_deploy() {
|
|
33
|
-
separator
|
|
34
|
-
|
|
35
|
-
separator
|
|
20
|
+
separator; box "Uninstalling Deploy CLIs"; separator; echo
|
|
21
|
+
log_info "Uninstalling deploy tools..."
|
|
36
22
|
local rc=0
|
|
37
23
|
import "@/tools/deploy/all"
|
|
38
24
|
uninstall_all_deploy_tools || rc=$?
|
|
39
25
|
separator
|
|
40
|
-
|
|
41
|
-
log_success "Deploy tools uninstalled"
|
|
42
|
-
else
|
|
43
|
-
log_warn "$rc deploy tool(s) failed to uninstall"
|
|
44
|
-
fi
|
|
26
|
+
[[ "$rc" -eq 0 ]] && log_success "Deploy tools uninstalled" || log_warn "$rc deploy tool(s) failed to uninstall"
|
|
45
27
|
return "$rc"
|
|
46
28
|
}
|
|
47
29
|
|
|
48
30
|
update_deploy() {
|
|
49
|
-
separator
|
|
50
|
-
|
|
51
|
-
separator
|
|
31
|
+
separator; box "Updating Deploy CLIs"; separator; echo
|
|
32
|
+
log_info "Updating deploy tools..."
|
|
52
33
|
local rc=0
|
|
53
34
|
import "@/tools/deploy/all"
|
|
54
35
|
update_all_deploy_tools || rc=$?
|
|
55
36
|
separator
|
|
56
|
-
|
|
57
|
-
log_success "Deploy tools updated"
|
|
58
|
-
else
|
|
59
|
-
log_warn "$rc deploy tool(s) failed to update"
|
|
60
|
-
fi
|
|
37
|
+
[[ "$rc" -eq 0 ]] && log_success "Deploy tools updated" || log_warn "$rc deploy tool(s) failed to update"
|
|
61
38
|
return "$rc"
|
|
62
39
|
}
|
|
63
40
|
|
|
64
41
|
reinstall_deploy() {
|
|
65
|
-
separator
|
|
66
|
-
|
|
67
|
-
separator
|
|
42
|
+
separator; box "Reinstalling Deploy CLIs"; separator; echo
|
|
43
|
+
log_info "Reinstalling deploy tools..."
|
|
68
44
|
local rc=0
|
|
69
45
|
import "@/tools/deploy/all"
|
|
70
46
|
reinstall_all_deploy_tools || rc=$?
|
|
71
47
|
separator
|
|
72
|
-
|
|
73
|
-
log_success "Deploy tools reinstalled"
|
|
74
|
-
else
|
|
75
|
-
log_warn "$rc deploy tool(s) failed to reinstall"
|
|
76
|
-
fi
|
|
48
|
+
[[ "$rc" -eq 0 ]] && log_success "Deploy tools reinstalled" || log_warn "$rc deploy tool(s) failed to reinstall"
|
|
77
49
|
return "$rc"
|
|
78
50
|
}
|
package/karnel/modules/games.sh
CHANGED
|
@@ -6,83 +6,45 @@ import "@/utils/colors"
|
|
|
6
6
|
LOG_FILE="$KARNEL_CACHE/install_games.log"
|
|
7
7
|
|
|
8
8
|
install_games() {
|
|
9
|
-
separator
|
|
10
|
-
box "Installing Games"
|
|
11
|
-
separator
|
|
12
|
-
echo
|
|
13
|
-
|
|
9
|
+
separator; box "Installing Games"; separator; echo
|
|
14
10
|
log_info "Installing games..."
|
|
15
|
-
|
|
16
|
-
mkdir -p "$(dirname "$LOG_FILE")"
|
|
17
|
-
|
|
18
11
|
local rc=0
|
|
19
12
|
import "@/tools/games/all"
|
|
20
13
|
install_all_games || rc=$?
|
|
21
|
-
if [ "$rc" -eq 0 ]; then
|
|
22
|
-
log_success "Games installed"
|
|
23
|
-
else
|
|
24
|
-
log_warn "$rc game(s) failed to install"
|
|
25
|
-
fi
|
|
26
14
|
separator
|
|
27
|
-
|
|
15
|
+
[[ "$rc" -eq 0 ]] && log_success "Games installed" || log_warn "$rc game(s) failed to install"
|
|
28
16
|
return "$rc"
|
|
29
17
|
}
|
|
30
18
|
|
|
31
19
|
uninstall_games() {
|
|
32
|
-
separator
|
|
33
|
-
box "Uninstalling Games"
|
|
34
|
-
separator
|
|
35
|
-
echo
|
|
36
|
-
|
|
20
|
+
separator; box "Uninstalling Games"; separator; echo
|
|
37
21
|
log_info "Uninstalling games..."
|
|
38
|
-
|
|
39
22
|
local rc=0
|
|
40
23
|
import "@/tools/games/all"
|
|
41
24
|
uninstall_all_games || rc=$?
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
else
|
|
45
|
-
log_warn "$rc game(s) failed to uninstall"
|
|
46
|
-
fi
|
|
25
|
+
separator
|
|
26
|
+
[[ "$rc" -eq 0 ]] && log_success "Games uninstalled" || log_warn "$rc game(s) failed to uninstall"
|
|
47
27
|
return "$rc"
|
|
48
28
|
}
|
|
49
29
|
|
|
50
30
|
update_games() {
|
|
51
|
-
separator
|
|
52
|
-
box "Updating Games"
|
|
53
|
-
separator
|
|
54
|
-
echo
|
|
55
|
-
|
|
31
|
+
separator; box "Updating Games"; separator; echo
|
|
56
32
|
log_info "Updating games..."
|
|
57
|
-
|
|
58
33
|
local rc=0
|
|
59
34
|
import "@/tools/games/all"
|
|
60
35
|
update_all_games || rc=$?
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
else
|
|
64
|
-
log_warn "$rc game(s) failed to update"
|
|
65
|
-
fi
|
|
36
|
+
separator
|
|
37
|
+
[[ "$rc" -eq 0 ]] && log_success "Games updated" || log_warn "$rc game(s) failed to update"
|
|
66
38
|
return "$rc"
|
|
67
39
|
}
|
|
68
40
|
|
|
69
41
|
reinstall_games() {
|
|
70
|
-
separator
|
|
71
|
-
box "Reinstalling Games"
|
|
72
|
-
separator
|
|
73
|
-
echo
|
|
74
|
-
|
|
42
|
+
separator; box "Reinstalling Games"; separator; echo
|
|
75
43
|
log_info "Reinstalling games..."
|
|
76
|
-
|
|
77
44
|
local rc=0
|
|
78
45
|
import "@/tools/games/all"
|
|
79
46
|
reinstall_all_games || rc=$?
|
|
80
|
-
if [ "$rc" -eq 0 ]; then
|
|
81
|
-
log_success "Games reinstalled"
|
|
82
|
-
else
|
|
83
|
-
log_warn "$rc game(s) failed to reinstall"
|
|
84
|
-
fi
|
|
85
47
|
separator
|
|
86
|
-
|
|
48
|
+
[[ "$rc" -eq 0 ]] && log_success "Games reinstalled" || log_warn "$rc game(s) failed to reinstall"
|
|
87
49
|
return "$rc"
|
|
88
50
|
}
|
|
@@ -6,83 +6,45 @@ import "@/utils/colors"
|
|
|
6
6
|
LOG_FILE="$KARNEL_CACHE/install_network.log"
|
|
7
7
|
|
|
8
8
|
install_network() {
|
|
9
|
-
separator
|
|
10
|
-
box "Installing Network Tools"
|
|
11
|
-
separator
|
|
12
|
-
echo
|
|
13
|
-
|
|
9
|
+
separator; box "Installing Network Tools"; separator; echo
|
|
14
10
|
log_info "Installing network tools..."
|
|
15
|
-
|
|
16
|
-
mkdir -p "$(dirname "$LOG_FILE")"
|
|
17
|
-
|
|
18
11
|
local rc=0
|
|
19
12
|
import "@/tools/network/all"
|
|
20
13
|
install_all_network || rc=$?
|
|
21
|
-
if [ "$rc" -eq 0 ]; then
|
|
22
|
-
log_success "Network tools installed"
|
|
23
|
-
else
|
|
24
|
-
log_warn "$rc network tool(s) failed to install"
|
|
25
|
-
fi
|
|
26
14
|
separator
|
|
27
|
-
|
|
15
|
+
[[ "$rc" -eq 0 ]] && log_success "Network tools installed" || log_warn "$rc network tool(s) failed to install"
|
|
28
16
|
return "$rc"
|
|
29
17
|
}
|
|
30
18
|
|
|
31
19
|
uninstall_network() {
|
|
32
|
-
separator
|
|
33
|
-
box "Uninstalling Network Tools"
|
|
34
|
-
separator
|
|
35
|
-
echo
|
|
36
|
-
|
|
20
|
+
separator; box "Uninstalling Network Tools"; separator; echo
|
|
37
21
|
log_info "Uninstalling network tools..."
|
|
38
|
-
|
|
39
22
|
local rc=0
|
|
40
23
|
import "@/tools/network/all"
|
|
41
24
|
uninstall_all_network || rc=$?
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
else
|
|
45
|
-
log_warn "$rc network tool(s) failed to uninstall"
|
|
46
|
-
fi
|
|
25
|
+
separator
|
|
26
|
+
[[ "$rc" -eq 0 ]] && log_success "Network tools uninstalled" || log_warn "$rc network tool(s) failed to uninstall"
|
|
47
27
|
return "$rc"
|
|
48
28
|
}
|
|
49
29
|
|
|
50
30
|
update_network() {
|
|
51
|
-
separator
|
|
52
|
-
box "Updating Network Tools"
|
|
53
|
-
separator
|
|
54
|
-
echo
|
|
55
|
-
|
|
31
|
+
separator; box "Updating Network Tools"; separator; echo
|
|
56
32
|
log_info "Updating network tools..."
|
|
57
|
-
|
|
58
33
|
local rc=0
|
|
59
34
|
import "@/tools/network/all"
|
|
60
35
|
update_all_network || rc=$?
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
else
|
|
64
|
-
log_warn "$rc network tool(s) failed to update"
|
|
65
|
-
fi
|
|
36
|
+
separator
|
|
37
|
+
[[ "$rc" -eq 0 ]] && log_success "Network tools updated" || log_warn "$rc network tool(s) failed to update"
|
|
66
38
|
return "$rc"
|
|
67
39
|
}
|
|
68
40
|
|
|
69
41
|
reinstall_network() {
|
|
70
|
-
separator
|
|
71
|
-
box "Reinstalling Network Tools"
|
|
72
|
-
separator
|
|
73
|
-
echo
|
|
74
|
-
|
|
42
|
+
separator; box "Reinstalling Network Tools"; separator; echo
|
|
75
43
|
log_info "Reinstalling network tools..."
|
|
76
|
-
|
|
77
44
|
local rc=0
|
|
78
45
|
import "@/tools/network/all"
|
|
79
46
|
reinstall_all_network || rc=$?
|
|
80
|
-
if [ "$rc" -eq 0 ]; then
|
|
81
|
-
log_success "Network tools reinstalled"
|
|
82
|
-
else
|
|
83
|
-
log_warn "$rc network tool(s) failed to reinstall"
|
|
84
|
-
fi
|
|
85
47
|
separator
|
|
86
|
-
|
|
48
|
+
[[ "$rc" -eq 0 ]] && log_success "Network tools reinstalled" || log_warn "$rc network tool(s) failed to reinstall"
|
|
87
49
|
return "$rc"
|
|
88
50
|
}
|
package/karnel/modules/utils.sh
CHANGED
|
@@ -6,83 +6,45 @@ import "@/utils/colors"
|
|
|
6
6
|
LOG_FILE="$KARNEL_CACHE/install_utils.log"
|
|
7
7
|
|
|
8
8
|
install_utils() {
|
|
9
|
-
separator
|
|
10
|
-
box "Installing Utility Tools"
|
|
11
|
-
separator
|
|
12
|
-
echo
|
|
13
|
-
|
|
9
|
+
separator; box "Installing Utility Tools"; separator; echo
|
|
14
10
|
log_info "Installing utility tools..."
|
|
15
|
-
|
|
16
|
-
mkdir -p "$(dirname "$LOG_FILE")"
|
|
17
|
-
|
|
18
11
|
local rc=0
|
|
19
12
|
import "@/tools/utils/all"
|
|
20
13
|
install_all_utils || rc=$?
|
|
21
|
-
if [ "$rc" -eq 0 ]; then
|
|
22
|
-
log_success "Utility tools installed"
|
|
23
|
-
else
|
|
24
|
-
log_warn "$rc utility tool(s) failed to install"
|
|
25
|
-
fi
|
|
26
14
|
separator
|
|
27
|
-
|
|
15
|
+
[[ "$rc" -eq 0 ]] && log_success "Utility tools installed" || log_warn "$rc utility tool(s) failed to install"
|
|
28
16
|
return "$rc"
|
|
29
17
|
}
|
|
30
18
|
|
|
31
19
|
uninstall_utils() {
|
|
32
|
-
separator
|
|
33
|
-
box "Uninstalling Utility Tools"
|
|
34
|
-
separator
|
|
35
|
-
echo
|
|
36
|
-
|
|
20
|
+
separator; box "Uninstalling Utility Tools"; separator; echo
|
|
37
21
|
log_info "Uninstalling utility tools..."
|
|
38
|
-
|
|
39
22
|
local rc=0
|
|
40
23
|
import "@/tools/utils/all"
|
|
41
24
|
uninstall_all_utils || rc=$?
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
else
|
|
45
|
-
log_warn "$rc utility tool(s) failed to uninstall"
|
|
46
|
-
fi
|
|
25
|
+
separator
|
|
26
|
+
[[ "$rc" -eq 0 ]] && log_success "Utility tools uninstalled" || log_warn "$rc utility tool(s) failed to uninstall"
|
|
47
27
|
return "$rc"
|
|
48
28
|
}
|
|
49
29
|
|
|
50
30
|
update_utils() {
|
|
51
|
-
separator
|
|
52
|
-
box "Updating Utility Tools"
|
|
53
|
-
separator
|
|
54
|
-
echo
|
|
55
|
-
|
|
31
|
+
separator; box "Updating Utility Tools"; separator; echo
|
|
56
32
|
log_info "Updating utility tools..."
|
|
57
|
-
|
|
58
33
|
local rc=0
|
|
59
34
|
import "@/tools/utils/all"
|
|
60
35
|
update_all_utils || rc=$?
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
else
|
|
64
|
-
log_warn "$rc utility tool(s) failed to update"
|
|
65
|
-
fi
|
|
36
|
+
separator
|
|
37
|
+
[[ "$rc" -eq 0 ]] && log_success "Utility tools updated" || log_warn "$rc utility tool(s) failed to update"
|
|
66
38
|
return "$rc"
|
|
67
39
|
}
|
|
68
40
|
|
|
69
41
|
reinstall_utils() {
|
|
70
|
-
separator
|
|
71
|
-
box "Reinstalling Utility Tools"
|
|
72
|
-
separator
|
|
73
|
-
echo
|
|
74
|
-
|
|
42
|
+
separator; box "Reinstalling Utility Tools"; separator; echo
|
|
75
43
|
log_info "Reinstalling utility tools..."
|
|
76
|
-
|
|
77
44
|
local rc=0
|
|
78
45
|
import "@/tools/utils/all"
|
|
79
46
|
reinstall_all_utils || rc=$?
|
|
80
|
-
if [ "$rc" -eq 0 ]; then
|
|
81
|
-
log_success "Utility tools reinstalled"
|
|
82
|
-
else
|
|
83
|
-
log_warn "$rc utility tool(s) failed to reinstall"
|
|
84
|
-
fi
|
|
85
47
|
separator
|
|
86
|
-
|
|
48
|
+
[[ "$rc" -eq 0 ]] && log_success "Utility tools reinstalled" || log_warn "$rc utility tool(s) failed to reinstall"
|
|
87
49
|
return "$rc"
|
|
88
50
|
}
|
|
@@ -582,7 +582,7 @@ _plugin_install_metadata_errors() {
|
|
|
582
582
|
else
|
|
583
583
|
. as $metadata |
|
|
584
584
|
[
|
|
585
|
-
if (($metadata | keys | sort) != ["checksum", "commit", "name", "ref", "registryName", "repo", "schemaVersion", "source", "version"]) then "metadata has unknown or missing fields" else empty end,
|
|
585
|
+
if (($metadata | keys | sort) != ["checksum", "commit", "config", "enabled", "name", "ref", "registryName", "repo", "schemaVersion", "source", "version"]) then "metadata has unknown or missing fields" else empty end,
|
|
586
586
|
if $metadata.schemaVersion != 1 then "metadata schemaVersion must be 1" else empty end,
|
|
587
587
|
if (["registry", "unsafe", "local"] | index($metadata.source)) == null then "metadata source is invalid" else empty end,
|
|
588
588
|
if ($metadata.name | safe_name | not) then "metadata name is invalid" else empty end,
|
|
@@ -933,7 +933,7 @@ _plugin_write_install_metadata() {
|
|
|
933
933
|
--argjson ref "$ref_json" \
|
|
934
934
|
--argjson commit "$commit_json" \
|
|
935
935
|
--argjson registry_name "$registry_json" \
|
|
936
|
-
'{schemaVersion: 1, source: $source, name: $name, repo: $repo, ref: $ref, commit: $commit, version: $version, checksum: (if $checksum == "" then null else $checksum end), registryName: $registry_name}' >"$metadata"; then
|
|
936
|
+
'{schemaVersion: 1, source: $source, name: $name, repo: $repo, ref: $ref, commit: $commit, version: $version, checksum: (if $checksum == "" then null else $checksum end), registryName: $registry_name, enabled: true, config: {}}' >"$metadata"; then
|
|
937
937
|
log_error "Failed to write installation metadata for '$name'."
|
|
938
938
|
return 1
|
|
939
939
|
fi
|
|
@@ -1327,6 +1327,72 @@ _plugin_read_metadata_field() {
|
|
|
1327
1327
|
jq -r ".$field // empty" "$plugin_root/.karnel-install.json"
|
|
1328
1328
|
}
|
|
1329
1329
|
|
|
1330
|
+
_plugin_is_enabled() {
|
|
1331
|
+
local plugin_root="$1"
|
|
1332
|
+
local enabled
|
|
1333
|
+
|
|
1334
|
+
enabled="$(_plugin_read_metadata_field "$plugin_root" enabled)"
|
|
1335
|
+
[[ "$enabled" != "false" ]]
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
_plugin_set_enabled() {
|
|
1339
|
+
local plugin_root="$1"
|
|
1340
|
+
local enabled="$2"
|
|
1341
|
+
local metadata="$plugin_root/.karnel-install.json"
|
|
1342
|
+
|
|
1343
|
+
if ! jq --arg val "$enabled" '.enabled = $val' "$metadata" >"$metadata.tmp"; then
|
|
1344
|
+
log_error "Failed to update enabled state."
|
|
1345
|
+
return 1
|
|
1346
|
+
fi
|
|
1347
|
+
if ! mv -- "$metadata.tmp" "$metadata"; then
|
|
1348
|
+
log_error "Failed to persist enabled state."
|
|
1349
|
+
return 1
|
|
1350
|
+
fi
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
_plugin_get_config() {
|
|
1354
|
+
local plugin_root="$1"
|
|
1355
|
+
local key="${2:-}"
|
|
1356
|
+
local metadata="$plugin_root/.karnel-install.json"
|
|
1357
|
+
|
|
1358
|
+
if [[ -z "$key" ]]; then
|
|
1359
|
+
jq -r '.config // {}' "$metadata"
|
|
1360
|
+
else
|
|
1361
|
+
jq -r --arg k "$key" '.config[$k] // empty' "$metadata"
|
|
1362
|
+
fi
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
_plugin_set_config() {
|
|
1366
|
+
local plugin_root="$1"
|
|
1367
|
+
local key="$2"
|
|
1368
|
+
local value="$3"
|
|
1369
|
+
local metadata="$plugin_root/.karnel-install.json"
|
|
1370
|
+
|
|
1371
|
+
if ! jq --arg k "$key" --arg v "$value" '.config[$k] = $v' "$metadata" >"$metadata.tmp"; then
|
|
1372
|
+
log_error "Failed to set config '$key'."
|
|
1373
|
+
return 1
|
|
1374
|
+
fi
|
|
1375
|
+
if ! mv -- "$metadata.tmp" "$metadata"; then
|
|
1376
|
+
log_error "Failed to persist config."
|
|
1377
|
+
return 1
|
|
1378
|
+
fi
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
_plugin_delete_config() {
|
|
1382
|
+
local plugin_root="$1"
|
|
1383
|
+
local key="$2"
|
|
1384
|
+
local metadata="$plugin_root/.karnel-install.json"
|
|
1385
|
+
|
|
1386
|
+
if ! jq --arg k "$key" 'del(.config[$k])' "$metadata" >"$metadata.tmp"; then
|
|
1387
|
+
log_error "Failed to delete config '$key'."
|
|
1388
|
+
return 1
|
|
1389
|
+
fi
|
|
1390
|
+
if ! mv -- "$metadata.tmp" "$metadata"; then
|
|
1391
|
+
log_error "Failed to persist config."
|
|
1392
|
+
return 1
|
|
1393
|
+
fi
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1330
1396
|
update_plugin() {
|
|
1331
1397
|
local name="$1"
|
|
1332
1398
|
local unsafe_flag="${2:-}"
|
|
@@ -1536,7 +1602,11 @@ _list_plugins() {
|
|
|
1536
1602
|
description="$(jq -r '.description' "$manifest")" || return 1
|
|
1537
1603
|
version="$(jq -r '.version' "$manifest")" || return 1
|
|
1538
1604
|
source="$(_plugin_read_metadata_field "$plugin_root" source)" || return 1
|
|
1539
|
-
|
|
1605
|
+
if _plugin_is_enabled "$plugin_root"; then
|
|
1606
|
+
printf " ${D_GREEN}%-20s${NC} v%-10s [%s] %s\n" "$name" "$version" "$source" "$description"
|
|
1607
|
+
else
|
|
1608
|
+
printf " ${D_YELLOW}%-20s${NC} v%-10s [%s] [disabled] %s\n" "$name" "$version" "$source" "$description"
|
|
1609
|
+
fi
|
|
1540
1610
|
found=1
|
|
1541
1611
|
done
|
|
1542
1612
|
|
|
@@ -1559,6 +1629,9 @@ _plugin_collect_commands() {
|
|
|
1559
1629
|
return 1
|
|
1560
1630
|
fi
|
|
1561
1631
|
plugin_root="$(_plugin_validate_installed_plugin "$plugin_dir" "$name")" || return 1
|
|
1632
|
+
if ! _plugin_is_enabled "$plugin_root"; then
|
|
1633
|
+
continue
|
|
1634
|
+
fi
|
|
1562
1635
|
while IFS= read -r command_name; do
|
|
1563
1636
|
printf '%s\t%s\t%s\n' "$name" "$plugin_root/commands/$command_name.sh" "$command_name"
|
|
1564
1637
|
done < <(jq -r '.commands[]' "$plugin_root/karnel-plugin.json")
|