karnel-termux 0.0.3 → 4.7.5
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/README.md +9 -11
- package/install.sh +9 -0
- package/karnel/bin/karnel +1 -1
- package/karnel/cli/commands/backup.sh +100 -0
- package/karnel/cli/commands/doctor/fixes.sh +310 -0
- package/karnel/cli/commands/doctor/system.sh +87 -0
- package/karnel/cli/commands/doctor.sh +7 -308
- package/karnel/cli/commands/install.sh +21 -2
- package/karnel/cli/commands/list.sh +2 -0
- package/karnel/cli/commands/reinstall.sh +5 -1
- package/karnel/cli/commands/restore.sh +83 -0
- package/karnel/cli/commands/search.sh +62 -0
- package/karnel/cli/commands/show.sh +102 -38
- package/karnel/cli/commands/uninstall.sh +3 -551
- package/karnel/cli/commands/update.sh +3 -551
- package/karnel/cli/karnel.sh +5 -0
- package/karnel/modules/db.sh +2 -0
- package/karnel/modules/dev.sh +9 -3
- package/karnel/tools/ai/antigravity-cli/bin/agy +1 -1
- package/karnel/tools/ai/claude-code/bin/claude +1 -1
- package/karnel/tools/ai/codegraph/bin/codegraph +1 -1
- package/karnel/tools/ai/freebuff/bin/freebuff +1 -1
- package/karnel/tools/ai/kilocode-cli/bin/kilocode +1 -1
- package/karnel/tools/ai/kilocode-cli/install.sh +1 -1
- package/karnel/tools/ai/kimchi-code/bin/kimchi +1 -1
- package/karnel/tools/ai/mimocode/bin/mimo +1 -1
- package/karnel/tools/ai/omni-route/README.md +17 -15
- package/karnel/tools/ai/opencode/bin/opencode +1 -1
- package/karnel/tools/db/redis/install.sh +1 -1
- package/karnel/tools/dev/all.sh +3 -0
- package/karnel/tools/dev/httptmux/install.sh +75 -0
- package/karnel/tools/dev/openssh/install.sh +1 -1
- package/karnel/tools/dev/snyk/install.sh +75 -0
- package/karnel/tools/dev/tmux/install.sh +1 -1
- package/karnel/tools/dev/zork/install.sh +122 -0
- package/karnel/tools/editor/neovim/install.sh +1 -1
- package/karnel/tools/editor/nvchad/install.sh +1 -1
- package/karnel/tools/npm/turbopack/bin/next-turbopack +1 -1
- package/karnel/tools/npm/turbopack/bin/node-glibc.sh +1 -1
- package/karnel/utils/log.sh +70 -0
- package/karnel/utils/tools.sh +34 -0
- package/karnel/utils/version.sh +1 -1
- package/package.json +1 -1
- package/scripts/completion.bash +28 -0
- package/scripts/completion.zsh +90 -0
|
@@ -5,8 +5,10 @@ import "@/utils/colors"
|
|
|
5
5
|
|
|
6
6
|
doctor_main() {
|
|
7
7
|
local QUICK_MODE=false
|
|
8
|
+
local FIX_MODE=false
|
|
8
9
|
for arg in "$@"; do
|
|
9
10
|
[[ "$arg" == "--quick" || "$arg" == "-q" ]] && QUICK_MODE=true
|
|
11
|
+
[[ "$arg" == "--fix" || "$arg" == "-f" ]] && FIX_MODE=true
|
|
10
12
|
done
|
|
11
13
|
|
|
12
14
|
echo
|
|
@@ -1186,8 +1188,10 @@ EOF
|
|
|
1186
1188
|
done
|
|
1187
1189
|
echo
|
|
1188
1190
|
|
|
1189
|
-
local confirm
|
|
1190
|
-
|
|
1191
|
+
local confirm="y"
|
|
1192
|
+
if ! $FIX_MODE; then
|
|
1193
|
+
read_confirm "Apply all auto-corrections?" confirm
|
|
1194
|
+
fi
|
|
1191
1195
|
if [[ "$confirm" == "y" ]]; then
|
|
1192
1196
|
echo
|
|
1193
1197
|
for ((i=0; i<${#fix_commands[@]}; i++)); do
|
|
@@ -1219,310 +1223,5 @@ EOF
|
|
|
1219
1223
|
echo
|
|
1220
1224
|
}
|
|
1221
1225
|
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
_fix_storage() {
|
|
1225
|
-
termux-setup-storage 2>/dev/null
|
|
1226
|
-
return $?
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
_fix_mkdir() {
|
|
1230
|
-
for dir in "$KARNEL_CONFIG" "$KARNEL_CACHE" "$KARNEL_DATA"; do
|
|
1231
|
-
mkdir -p "$dir" 2>/dev/null
|
|
1232
|
-
chmod 755 "$dir" 2>/dev/null
|
|
1233
|
-
done
|
|
1234
|
-
return 0
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
_fix_pkg_install() {
|
|
1238
|
-
local pkg_to_install=""
|
|
1239
|
-
case "$1" in
|
|
1240
|
-
pkg) pkg_to_install="$2" ;;
|
|
1241
|
-
*) pkg_to_install="${fix_commands[$i]:-}" ;;
|
|
1242
|
-
esac
|
|
1243
|
-
local pkg_name=""
|
|
1244
|
-
if [[ "$pkg_to_install" =~ pkg\ install\ -y\ (.+) ]]; then
|
|
1245
|
-
pkg_name="${BASH_REMATCH[1]}"
|
|
1246
|
-
fi
|
|
1247
|
-
if [[ -n "$pkg_name" ]]; then
|
|
1248
|
-
pkg install -y "$pkg_name" 2>/dev/null
|
|
1249
|
-
return $?
|
|
1250
|
-
fi
|
|
1251
|
-
return 1
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
_fix_dpkg() {
|
|
1255
|
-
dpkg --configure -a 2>/dev/null
|
|
1256
|
-
apt-get -f install -y 2>/dev/null
|
|
1257
|
-
return $?
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
_fix_apt_update() {
|
|
1261
|
-
pkg update -y 2>/dev/null
|
|
1262
|
-
return $?
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
_fix_npm_prefix() {
|
|
1266
|
-
mkdir -p "$HOME/.npm-global"
|
|
1267
|
-
npm config set prefix "$HOME/.npm-global" 2>/dev/null
|
|
1268
|
-
return $?
|
|
1269
|
-
}
|
|
1226
|
+
import "@/cli/commands/doctor/fixes"
|
|
1270
1227
|
|
|
1271
|
-
_fix_pip() {
|
|
1272
|
-
local py_cmd=""
|
|
1273
|
-
for py in python3.12 python3.11 python3.10 python3.9 python3 python; do
|
|
1274
|
-
if command -v "$py" &>/dev/null; then py_cmd="$py"; break; fi
|
|
1275
|
-
done
|
|
1276
|
-
if [[ -n "$py_cmd" ]]; then
|
|
1277
|
-
"$py_cmd" -m ensurepip 2>/dev/null
|
|
1278
|
-
"$py_cmd" -m pip install --upgrade pip 2>/dev/null
|
|
1279
|
-
return $?
|
|
1280
|
-
fi
|
|
1281
|
-
return 1
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1284
|
-
_fix_pg_init() {
|
|
1285
|
-
source "$KARNEL_PATH/utils/env.sh" 2>/dev/null
|
|
1286
|
-
import "@/modules/db" 2>/dev/null
|
|
1287
|
-
if type pg_init &>/dev/null; then
|
|
1288
|
-
pg_init 2>/dev/null
|
|
1289
|
-
pg_start 2>/dev/null
|
|
1290
|
-
return $?
|
|
1291
|
-
fi
|
|
1292
|
-
local pg_data="$HOME/.local/share/postgresql/data"
|
|
1293
|
-
mkdir -p "$pg_data" 2>/dev/null
|
|
1294
|
-
if command -v initdb &>/dev/null; then
|
|
1295
|
-
initdb -D "$pg_data" 2>/dev/null
|
|
1296
|
-
pg_ctl -D "$pg_data" -l "$HOME/.cache/karnel/postgresql.log" start 2>/dev/null
|
|
1297
|
-
return $?
|
|
1298
|
-
fi
|
|
1299
|
-
return 1
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1302
|
-
_fix_pg_start() {
|
|
1303
|
-
local pg_data=""
|
|
1304
|
-
for dir in "$PREFIX/var/lib/postgresql/data" "$PREFIX/var/lib/postgresql" "$HOME/.termux/postgresql/data" "$HOME/.termux/postgresql" "$HOME/.local/share/postgresql/data"; do
|
|
1305
|
-
if [[ -d "$dir" ]] && [[ -f "$dir/PG_VERSION" ]]; then
|
|
1306
|
-
pg_data="$dir"
|
|
1307
|
-
break
|
|
1308
|
-
fi
|
|
1309
|
-
done
|
|
1310
|
-
if [[ -n "$pg_data" ]] && command -v pg_ctl &>/dev/null; then
|
|
1311
|
-
pg_ctl -D "$pg_data" -l "$HOME/.cache/karnel/postgresql.log" start 2>/dev/null
|
|
1312
|
-
return $?
|
|
1313
|
-
fi
|
|
1314
|
-
return 1
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
_fix_pg_install() {
|
|
1318
|
-
source "$KARNEL_PATH/utils/env.sh" 2>/dev/null
|
|
1319
|
-
import "@/modules/db" 2>/dev/null
|
|
1320
|
-
if type install_db &>/dev/null; then
|
|
1321
|
-
install_db 2>/dev/null
|
|
1322
|
-
return $?
|
|
1323
|
-
fi
|
|
1324
|
-
pkg install -y postgresql 2>/dev/null
|
|
1325
|
-
return $?
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
_fix_symlinks() {
|
|
1329
|
-
ln -sf "$KARNEL_PATH/bin/karnel" "$PREFIX/bin/karnel" 2>/dev/null
|
|
1330
|
-
[[ -L "$PREFIX/bin/karnel" ]]
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
_fix_banner() {
|
|
1334
|
-
local shell_config=""
|
|
1335
|
-
if [[ -f "$HOME/.zshrc" ]]; then
|
|
1336
|
-
shell_config="$HOME/.zshrc"
|
|
1337
|
-
elif [[ -f "$HOME/.bashrc" ]]; then
|
|
1338
|
-
shell_config="$HOME/.bashrc"
|
|
1339
|
-
fi
|
|
1340
|
-
if [[ -z "$shell_config" ]]; then
|
|
1341
|
-
shell_config="$HOME/.zshrc"
|
|
1342
|
-
touch "$shell_config"
|
|
1343
|
-
fi
|
|
1344
|
-
local marker="# ===== Karnel Banner ====="
|
|
1345
|
-
if ! grep -qF "$marker" "$shell_config" 2>/dev/null; then
|
|
1346
|
-
cat >>"$shell_config" <<EOF
|
|
1347
|
-
|
|
1348
|
-
$marker
|
|
1349
|
-
source "$KARNEL_UTILS/banner.sh"
|
|
1350
|
-
EOF
|
|
1351
|
-
return 0
|
|
1352
|
-
fi
|
|
1353
|
-
return 0
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
_fix_ai_install() {
|
|
1357
|
-
log_info "Installing AI tools (this may take a while)..."
|
|
1358
|
-
source "$KARNEL_PATH/utils/env.sh" 2>/dev/null
|
|
1359
|
-
import "@/modules/ai" 2>/dev/null
|
|
1360
|
-
if type install_ai &>/dev/null; then
|
|
1361
|
-
install_ai 2>/dev/null
|
|
1362
|
-
return $?
|
|
1363
|
-
fi
|
|
1364
|
-
return 1
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
_fix_shell_syntax() {
|
|
1368
|
-
local config=""
|
|
1369
|
-
if [[ -f "$HOME/.zshrc" ]]; then
|
|
1370
|
-
config="$HOME/.zshrc"
|
|
1371
|
-
elif [[ -f "$HOME/.bashrc" ]]; then
|
|
1372
|
-
config="$HOME/.bashrc"
|
|
1373
|
-
fi
|
|
1374
|
-
if [[ -n "$config" ]]; then
|
|
1375
|
-
cp "$config" "${config}.bak" 2>/dev/null
|
|
1376
|
-
local marker="# ===== Karnel Banner ====="
|
|
1377
|
-
local banner_block=""
|
|
1378
|
-
if grep -qF "$marker" "$config" 2>/dev/null; then
|
|
1379
|
-
local marker_line
|
|
1380
|
-
marker_line=$(grep -nF "$marker" "$config" | head -1 | cut -d: -f1)
|
|
1381
|
-
if [[ -n "$marker_line" ]]; then
|
|
1382
|
-
banner_block=$(sed -n "$((marker_line - 1)),\$p" "$config" 2>/dev/null)
|
|
1383
|
-
fi
|
|
1384
|
-
fi
|
|
1385
|
-
local tmpconfig
|
|
1386
|
-
tmpconfig=$(mktemp)
|
|
1387
|
-
sed '/^source.*\/dev\/null$/d; /^#.*syntax error/d' "$config" > "$tmpconfig" 2>/dev/null
|
|
1388
|
-
if [[ -n "$banner_block" ]]; then
|
|
1389
|
-
echo "" >> "$tmpconfig"
|
|
1390
|
-
echo "$banner_block" >> "$tmpconfig"
|
|
1391
|
-
fi
|
|
1392
|
-
cp "$tmpconfig" "$config" 2>/dev/null
|
|
1393
|
-
rm -f "$tmpconfig"
|
|
1394
|
-
return 0
|
|
1395
|
-
fi
|
|
1396
|
-
return 1
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
_fix_ssh_key() {
|
|
1400
|
-
mkdir -p "$HOME/.ssh"
|
|
1401
|
-
chmod 700 "$HOME/.ssh"
|
|
1402
|
-
ssh-keygen -t ed25519 -f "$HOME/.ssh/id_ed25519" -N '' 2>/dev/null
|
|
1403
|
-
return $?
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
_fix_disk_cleanup() {
|
|
1407
|
-
rm -rf ~/.cache/karnel/install_*.log 2>/dev/null
|
|
1408
|
-
if command -v pkg &>/dev/null; then
|
|
1409
|
-
pkg clean -y 2>/dev/null
|
|
1410
|
-
fi
|
|
1411
|
-
return $?
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
_fix_mkdir_single() {
|
|
1415
|
-
for dir in "$KARNEL_CONFIG" "$KARNEL_CACHE" "$KARNEL_DATA" "$HOME/.local/share/karnel-data"; do
|
|
1416
|
-
[[ -d "$dir" ]] || mkdir -p "$dir" 2>/dev/null
|
|
1417
|
-
done
|
|
1418
|
-
return 0
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
# ===== NEW FIX CALLBACKS =====
|
|
1422
|
-
|
|
1423
|
-
_fix_psutil() {
|
|
1424
|
-
local tmp="$PREFIX/tmp/psutil_patch"
|
|
1425
|
-
mkdir -p "$tmp"
|
|
1426
|
-
pip download psutil==7.2.2 --no-binary :all: --no-deps -d "$tmp" 2>/dev/null || return 1
|
|
1427
|
-
tar xzf "$tmp/psutil-7.2.2.tar.gz" -C "$tmp"
|
|
1428
|
-
sed -i 's/LINUX = sys.platform.startswith("linux")/LINUX = sys.platform.startswith(("linux", "android"))/' "$tmp/psutil-7.2.2/psutil/_common.py"
|
|
1429
|
-
pip install "$tmp/psutil-7.2.2" 2>/dev/null
|
|
1430
|
-
local rc=$?
|
|
1431
|
-
rm -rf "$tmp"
|
|
1432
|
-
return $rc
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
_fix_pip_check() {
|
|
1436
|
-
local broken
|
|
1437
|
-
broken=$(pip check 2>&1 | grep -oP '^\S+' | head -3)
|
|
1438
|
-
if [[ -n "$broken" ]]; then
|
|
1439
|
-
pip install --upgrade --force-reinstall $broken 2>/dev/null
|
|
1440
|
-
fi
|
|
1441
|
-
return 0
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
_fix_npm_shebangs() {
|
|
1445
|
-
local fixed=0
|
|
1446
|
-
for f in "$PREFIX/bin/"*; do
|
|
1447
|
-
[[ -f "$f" ]] || continue
|
|
1448
|
-
local shebang
|
|
1449
|
-
shebang=$(head -1 "$f" 2>/dev/null | tr -d '\0')
|
|
1450
|
-
if [[ "$shebang" == "#!/usr/bin/env node" ]]; then
|
|
1451
|
-
sed -i "1s|^.*$|#!$PREFIX/bin/node|" "$f"
|
|
1452
|
-
((fixed++))
|
|
1453
|
-
elif [[ "$shebang" == "#!/usr/bin/env bash" ]] || [[ "$shebang" == "#!/usr/bin/env sh" ]]; then
|
|
1454
|
-
sed -i "1s|^.*$|#!$PREFIX/bin/bash|" "$f"
|
|
1455
|
-
((fixed++))
|
|
1456
|
-
fi
|
|
1457
|
-
done
|
|
1458
|
-
return 0
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
_fix_broken_symlinks() {
|
|
1462
|
-
find "$PREFIX/bin" -type l ! -exec test -e {} \; -delete 2>/dev/null
|
|
1463
|
-
return 0
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
_fix_npm_cache() {
|
|
1467
|
-
npm cache clean --force 2>/dev/null
|
|
1468
|
-
return $?
|
|
1469
|
-
}
|
|
1470
|
-
|
|
1471
|
-
_fix_pip_cache() {
|
|
1472
|
-
pip cache purge 2>/dev/null
|
|
1473
|
-
return $?
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1476
|
-
_fix_pycache() {
|
|
1477
|
-
find "$PREFIX/lib/python3.*" -name "__pycache__" -exec rm -rf {} + 2>/dev/null
|
|
1478
|
-
return 0
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
_fix_proot_ubuntu() {
|
|
1482
|
-
if command -v proot-distro &>/dev/null; then
|
|
1483
|
-
proot-distro install ubuntu 2>/dev/null
|
|
1484
|
-
return $?
|
|
1485
|
-
fi
|
|
1486
|
-
return 1
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
_fix_dns() {
|
|
1490
|
-
echo 'nameserver 8.8.8.8' > "$PREFIX/etc/resolv.conf" 2>/dev/null
|
|
1491
|
-
return $?
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
_fix_mirror() {
|
|
1495
|
-
if command -v termux-change-repo &>/dev/null; then
|
|
1496
|
-
termux-change-repo 2>/dev/null
|
|
1497
|
-
return $?
|
|
1498
|
-
fi
|
|
1499
|
-
return 1
|
|
1500
|
-
}
|
|
1501
|
-
|
|
1502
|
-
_fix_locale() {
|
|
1503
|
-
local config="$HOME/.zshrc"
|
|
1504
|
-
if [[ ! -f "$config" ]] && [[ -f "$HOME/.bashrc" ]]; then
|
|
1505
|
-
config="$HOME/.bashrc"
|
|
1506
|
-
fi
|
|
1507
|
-
echo 'export LANG=en_US.UTF-8' >> "$config" 2>/dev/null
|
|
1508
|
-
return $?
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
_fix_zombies() {
|
|
1513
|
-
ps aux 2>/dev/null | awk '$8 ~ /^Z/ {print $2}' | xargs kill -9 2>/dev/null
|
|
1514
|
-
return 0
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
_fix_url_quote_magic() {
|
|
1518
|
-
local uqm_file="$PREFIX/share/zsh/functions/Zle/url-quote-magic"
|
|
1519
|
-
if [[ ! -f "$uqm_file" ]]; then
|
|
1520
|
-
return 1
|
|
1521
|
-
fi
|
|
1522
|
-
# Fix double-paren case patterns: (( -> ( for localschema and otherschema
|
|
1523
|
-
sed -i \
|
|
1524
|
-
-e 's/((${~localschema})/(${~localschema})/g' \
|
|
1525
|
-
-e 's/((${~otherschema})/(${~otherschema})/g' \
|
|
1526
|
-
"$uqm_file" 2>/dev/null
|
|
1527
|
-
return $?
|
|
1528
|
-
}
|
|
@@ -71,7 +71,7 @@ install_main() {
|
|
|
71
71
|
list_item "lang - Language packages (Node.js, Python, Perl, PHP, Rust, C, C++, Go)"
|
|
72
72
|
list_item "db - Databases (PostgreSQL, MariaDB, SQLite, MongoDB, Redis)"
|
|
73
73
|
list_item "ai - AI tools (OpenCode, Gentle AI, Claude Code, etc.)"
|
|
74
|
-
list_item "editor - Code editor (code-server)"
|
|
74
|
+
list_item "editor - Code editor (code-server, neovim, nvchad)"
|
|
75
75
|
list_item "dev - Development tools"
|
|
76
76
|
list_item "npm - Node.js global modules (npm packages)"
|
|
77
77
|
list_item "shell - ZSH + Oh My Zsh + plugins"
|
|
@@ -396,6 +396,18 @@ _install_specific_tools() {
|
|
|
396
396
|
install_udocker
|
|
397
397
|
case $? in 0|2) ((installed_count++));; 1) ((failed_count++));; esac
|
|
398
398
|
;;
|
|
399
|
+
snyk)
|
|
400
|
+
install_snyk
|
|
401
|
+
case $? in 0|2) ((installed_count++));; 1) ((failed_count++));; esac
|
|
402
|
+
;;
|
|
403
|
+
httptmux)
|
|
404
|
+
install_httptmux
|
|
405
|
+
case $? in 0|2) ((installed_count++));; 1) ((failed_count++));; esac
|
|
406
|
+
;;
|
|
407
|
+
zork)
|
|
408
|
+
install_zork
|
|
409
|
+
case $? in 0|2) ((installed_count++));; 1) ((failed_count++));; esac
|
|
410
|
+
;;
|
|
399
411
|
*)
|
|
400
412
|
log_warn "Unknown tool: --$tool"
|
|
401
413
|
;;
|
|
@@ -597,10 +609,17 @@ _install_specific_tools() {
|
|
|
597
609
|
for tool in "${tools[@]}"; do
|
|
598
610
|
case "$tool" in
|
|
599
611
|
code-server)
|
|
600
|
-
import "@/tools/editor/code-server"
|
|
601
612
|
install_code_server
|
|
602
613
|
case $? in 0|2) ((installed_count++));; 1) ((failed_count++));; esac
|
|
603
614
|
;;
|
|
615
|
+
neovim)
|
|
616
|
+
install_neovim
|
|
617
|
+
case $? in 0|2) ((installed_count++));; 1) ((failed_count++));; esac
|
|
618
|
+
;;
|
|
619
|
+
nvchad)
|
|
620
|
+
install_nvchad
|
|
621
|
+
case $? in 0|2) ((installed_count++));; 1) ((failed_count++));; esac
|
|
622
|
+
;;
|
|
604
623
|
*)
|
|
605
624
|
log_warn "Unknown editor component: --$tool"
|
|
606
625
|
;;
|
|
@@ -185,6 +185,8 @@ _list_editor() {
|
|
|
185
185
|
|
|
186
186
|
table_start "Component" "Install Flag" "Status"
|
|
187
187
|
table_row "code-server" "--code-server" "$(_check_cmd "code-server")"
|
|
188
|
+
table_row "neovim" "--neovim" "$(_check_cmd "nvim")"
|
|
189
|
+
table_row "nvchad" "--nvchad" "$(_check_cmd "nvim")"
|
|
188
190
|
table_end
|
|
189
191
|
|
|
190
192
|
echo
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
2
|
|
|
3
3
|
import "@/utils/log"
|
|
4
4
|
import "@/utils/colors"
|
|
@@ -568,6 +568,10 @@ _reinstall_specific_tools() {
|
|
|
568
568
|
|
|
569
569
|
for tool in "${tools[@]}"; do
|
|
570
570
|
case "$tool" in
|
|
571
|
+
code-server)
|
|
572
|
+
reinstall_code_server
|
|
573
|
+
case $? in 0) ((reinstalled_count++));; 1) ((failed_count++));; esac
|
|
574
|
+
;;
|
|
571
575
|
neovim)
|
|
572
576
|
reinstall_neovim
|
|
573
577
|
case $? in 0) ((reinstalled_count++));; 1) ((failed_count++));; esac
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
import "@/utils/log"
|
|
4
|
+
import "@/utils/colors"
|
|
5
|
+
|
|
6
|
+
restore_main() {
|
|
7
|
+
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
|
|
8
|
+
echo
|
|
9
|
+
box "◈ KARNEL RESTORE ◈"
|
|
10
|
+
echo
|
|
11
|
+
list_item "karnel restore Restore latest backup"
|
|
12
|
+
list_item "karnel restore <arquivo> Restore specific file"
|
|
13
|
+
list_item "karnel restore --cloud Restore from Google Drive"
|
|
14
|
+
echo
|
|
15
|
+
return
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
local dir="${KARNEL_DATA}/backups"
|
|
19
|
+
local file=""
|
|
20
|
+
local cloud=false
|
|
21
|
+
|
|
22
|
+
for arg in "$@"; do
|
|
23
|
+
[[ "$arg" == "--cloud" ]] && cloud=true && continue
|
|
24
|
+
[[ -f "$arg" ]] && file="$arg"
|
|
25
|
+
done
|
|
26
|
+
|
|
27
|
+
# Download from cloud
|
|
28
|
+
if $cloud; then
|
|
29
|
+
command -v rclone &>/dev/null || { log_error "Install rclone: pkg install rclone"; return 1; }
|
|
30
|
+
rclone listremotes 2>/dev/null | grep -q "^karnel:" || { log_error "Run 'rclone config' and name remote 'karnel'"; return 1; }
|
|
31
|
+
|
|
32
|
+
log_info "Downloading from Google Drive..."
|
|
33
|
+
rclone copy "karnel:backups/" "$dir/" --include "termux-*.tar.gz" 2>/dev/null
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# Find file
|
|
37
|
+
[[ -z "$file" ]] && file=$(ls -t "$dir"/termux-*.tar.gz 2>/dev/null | head -1)
|
|
38
|
+
[[ -z "$file" || ! -f "$file" ]] && { log_error "No backup found. Run 'karnel backup' first"; return 1; }
|
|
39
|
+
|
|
40
|
+
local ts
|
|
41
|
+
ts=$(basename "$file" .tar.gz | sed 's/termux-//')
|
|
42
|
+
local pkgs="$dir/packages-$ts.list"
|
|
43
|
+
local manifest="$dir/manifest-$ts.list"
|
|
44
|
+
|
|
45
|
+
echo
|
|
46
|
+
box "◈ KARNEL RESTORE ◈"
|
|
47
|
+
echo
|
|
48
|
+
log_info "Restoring: $(basename "$file")"
|
|
49
|
+
[[ -f "$manifest" ]] && log_info "$(wc -l < "$manifest") tools to reinstall"
|
|
50
|
+
echo
|
|
51
|
+
|
|
52
|
+
read_confirm "Proceed with restore?" confirm
|
|
53
|
+
[[ "$confirm" != "y" ]] && { log_info "Cancelled"; return 0; }
|
|
54
|
+
|
|
55
|
+
# Configs
|
|
56
|
+
log_info "Restoring configs..."
|
|
57
|
+
tar -xzf "$file" -C / 2>/dev/null
|
|
58
|
+
log_success "Configs restored"
|
|
59
|
+
|
|
60
|
+
# Packages
|
|
61
|
+
if [[ -f "$pkgs" ]]; then
|
|
62
|
+
log_info "Restoring packages..."
|
|
63
|
+
dpkg --set-selections < "$pkgs" 2>/dev/null
|
|
64
|
+
apt-get dselect-upgrade -y &>/dev/null &
|
|
65
|
+
log_success "Package list restored"
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
# Tools
|
|
69
|
+
if [[ -f "$manifest" ]]; then
|
|
70
|
+
log_info "Reinstalling tools..."
|
|
71
|
+
local ok=0 total=0
|
|
72
|
+
while IFS= read -r line; do
|
|
73
|
+
((total++))
|
|
74
|
+
local mod="${line%%:*}" tool="${line#*:}"
|
|
75
|
+
karnel install "$mod" "--$tool" &>/dev/null && ((ok++))
|
|
76
|
+
done < "$manifest"
|
|
77
|
+
log_success "$ok/$total tools reinstalled"
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
echo
|
|
81
|
+
log_success "All done! Restart Termux or run: source ~/.zshrc"
|
|
82
|
+
echo
|
|
83
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
import "@/utils/log"
|
|
4
|
+
import "@/utils/colors"
|
|
5
|
+
|
|
6
|
+
search_main() {
|
|
7
|
+
local query="$*"
|
|
8
|
+
if [[ -z "$query" ]]; then
|
|
9
|
+
echo
|
|
10
|
+
box "◈ KARNEL SEARCH ◈"
|
|
11
|
+
echo
|
|
12
|
+
log_info "Search across all tools and brain memories"
|
|
13
|
+
echo
|
|
14
|
+
log_info "Usage: karnel search <query>"
|
|
15
|
+
echo
|
|
16
|
+
return
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
echo
|
|
20
|
+
box "◈ Search: $query ◈"
|
|
21
|
+
echo
|
|
22
|
+
|
|
23
|
+
local any_found=false
|
|
24
|
+
|
|
25
|
+
separator_section "Tool Names"
|
|
26
|
+
echo
|
|
27
|
+
for reg_file in "$KARNEL_PATH/tools/"*/all.sh; do
|
|
28
|
+
local mod
|
|
29
|
+
mod=$(basename "$(dirname "$reg_file")")
|
|
30
|
+
while IFS= read -r line; do
|
|
31
|
+
local id name
|
|
32
|
+
id=$(echo "$line" | cut -d: -f1 | tr -d '"' | xargs)
|
|
33
|
+
name=$(echo "$line" | cut -d: -f2 | tr -d '"' | xargs)
|
|
34
|
+
if echo "$id $name" | grep -qi "$query"; then
|
|
35
|
+
list_item "${D_CYAN}$mod${NC}: $name ($id)"
|
|
36
|
+
any_found=true
|
|
37
|
+
fi
|
|
38
|
+
done < <(grep -E '"[a-z].*:.*:.*"' "$reg_file" 2>/dev/null)
|
|
39
|
+
done
|
|
40
|
+
if ! $any_found; then
|
|
41
|
+
log_info "No tools found matching '$query'"
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
echo
|
|
45
|
+
separator_section "Brain Memories"
|
|
46
|
+
echo
|
|
47
|
+
if [[ -d "$KARNEL_DATA/brain" ]]; then
|
|
48
|
+
grep -ril "$query" "$KARNEL_DATA/brain" 2>/dev/null | while IFS= read -r file; do
|
|
49
|
+
local title
|
|
50
|
+
title=$(head -1 "$file" 2>/dev/null | sed 's/^# //')
|
|
51
|
+
list_item "${D_CYAN}$(basename "$file")${NC}: ${title:-$file}"
|
|
52
|
+
any_found=true
|
|
53
|
+
done
|
|
54
|
+
if ! $any_found; then
|
|
55
|
+
log_info "No memories found matching '$query'"
|
|
56
|
+
fi
|
|
57
|
+
else
|
|
58
|
+
log_info "Brain not initialized (run 'karnel brain init')"
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
echo
|
|
62
|
+
}
|