-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-tui.sh
More file actions
executable file
·95 lines (78 loc) · 3.33 KB
/
Copy pathinstall-tui.sh
File metadata and controls
executable file
·95 lines (78 loc) · 3.33 KB
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
#!/bin/bash
# Copyright (C) 2025 pliski@q30.space
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# install-tui.sh — symlink spaceapi-tui into ~/.local/bin and check
# that the runtime dependencies (gum, secret-tool, curl) are present.
set -eu
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SOURCE="$SCRIPT_DIR/spaceapi-tui"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
TARGET="$INSTALL_DIR/spaceapi-tui"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
err() { printf "${RED}✗ %s${NC}\n" "$*" >&2; }
warn() { printf "${YELLOW}! %s${NC}\n" "$*" >&2; }
ok() { printf "${GREEN}✓ %s${NC}\n" "$*"; }
# ---- dependency check ------------------------------------------------------
install_hint() {
local pkg_arch="$1" pkg_debian="$2" pkg_fedora="$3"
if command -v pacman >/dev/null 2>&1; then echo " sudo pacman -S $pkg_arch"
elif command -v apt >/dev/null 2>&1; then echo " sudo apt install $pkg_debian"
elif command -v dnf >/dev/null 2>&1; then echo " sudo dnf install $pkg_fedora"
else echo " (install $pkg_arch via your package manager)"
fi
}
check_dep() {
local cmd="$1" pkg_arch="$2" pkg_debian="$3" pkg_fedora="$4"
if command -v "$cmd" >/dev/null 2>&1; then
ok "$cmd found ($(command -v "$cmd"))"
return 0
fi
err "$cmd not found"
echo " Install with:"
install_hint "$pkg_arch" "$pkg_debian" "$pkg_fedora"
return 1
}
missing=0
check_dep gum gum gum gum || missing=$((missing+1))
check_dep secret-tool libsecret libsecret-tools libsecret || missing=$((missing+1))
check_dep curl curl curl curl || missing=$((missing+1))
if [ "$missing" -ne 0 ]; then
err "$missing required dependency/dependencies missing — aborting."
exit 1
fi
# Warn (don't fail) if no keyring daemon is detectable. The TUI will surface
# a clear error at first run if libsecret can't reach a backend.
if [ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ]; then
warn "DBUS_SESSION_BUS_ADDRESS is unset — a keyring daemon (gnome-keyring, KWallet, kwalletmanager) needs to be running for libsecret to work."
fi
# ---- install ---------------------------------------------------------------
if [ ! -x "$SOURCE" ]; then
chmod +x "$SOURCE"
fi
mkdir -p "$INSTALL_DIR"
if [ -L "$TARGET" ] && [ "$(readlink -f "$TARGET")" = "$(readlink -f "$SOURCE")" ]; then
ok "Already installed: $TARGET → $SOURCE"
else
ln -sf "$SOURCE" "$TARGET"
ok "Installed symlink: $TARGET → $SOURCE"
fi
case ":$PATH:" in
*":$INSTALL_DIR:"*) ok "$INSTALL_DIR is on PATH" ;;
*) warn "$INSTALL_DIR is not on PATH — add it to your shell rc to run 'spaceapi-tui' from anywhere" ;;
esac
ok "Done. Run: spaceapi-tui"