-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·161 lines (134 loc) · 4.3 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·161 lines (134 loc) · 4.3 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
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
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env bash
set -euo pipefail
echo "Requesting superuser access for installing:"
sudo -v
# Mycelium installer — builds and installs myc (CLI) and/or MycUI (GUI)
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
INSTALL_CLI=false
INSTALL_GUI=false
# ---------- argument parsing ----------
if [ $# -eq 0 ]; then
INSTALL_CLI=true
INSTALL_GUI=true
fi
for arg in "$@"; do
case "$arg" in
--cli) INSTALL_CLI=true ;;
--gui) INSTALL_GUI=true ;;
--all) INSTALL_CLI=true; INSTALL_GUI=true ;;
--help|-h)
echo "Usage: ./install.sh [--cli] [--gui] [--all]"
echo ""
echo " --cli Build and install myc (CLI only)"
echo " --gui Build and install MycUI (Tauri GUI)"
echo " --all Install both (default when no flags given)"
echo ""
echo "Set INSTALL_DIR to change install path (default: /usr/local/bin)"
exit 0
;;
*)
echo "Unknown option: $arg (use --help for usage)"
exit 1
;;
esac
done
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OS="$(uname -s)"
# ---------- helpers ----------
info() { echo -e "\033[1;34m==>\033[0m $*"; }
ok() { echo -e "\033[1;32m==>\033[0m $*"; }
err() { echo -e "\033[1;31m==>\033[0m $*" >&2; }
check_cmd() {
if ! command -v "$1" &>/dev/null; then
err "Required: $1 — $2"
return 1
fi
}
need_sudo() {
local target_dir="${SUDO_TARGET_DIR:-$INSTALL_DIR}"
if [ -w "$target_dir" ]; then
"$@"
else
sudo "$@"
fi
}
# ---------- platform check ----------
case "$OS" in
Linux|Darwin) ;;
*)
err "Unsupported platform: $OS (only Linux and macOS are supported)"
exit 1
;;
esac
# ---------- dependency checks ----------
info "Checking dependencies ($OS)..."
MISSING=false
check_cmd cargo "Install from https://rustup.rs" || MISSING=true
if $INSTALL_GUI; then
check_cmd bun "Install from https://bun.sh" || MISSING=true
if [ "$OS" = "Linux" ]; then
for lib in libwebkit2gtk-4.1 libgtk-3 libayatana-appindicator3; do
if ! pkg-config --exists "${lib}-dev" 2>/dev/null && ! pkg-config --exists "$lib" 2>/dev/null; then
info "Note: $lib may be needed — install Tauri prerequisites if build fails"
info " See: https://v2.tauri.app/start/prerequisites/#linux"
fi
done
fi
fi
if $MISSING; then
err "Install missing dependencies and try again."
exit 1
fi
# ---------- build CLI ----------
if $INSTALL_CLI; then
info "Building myc (CLI)..."
cd "$SCRIPT_DIR"
cargo build --release
info "Installing myc to $INSTALL_DIR..."
need_sudo install -m 755 target/release/myc "$INSTALL_DIR/myc"
ok "myc installed to $INSTALL_DIR/myc"
fi
# ---------- build GUI ----------
if $INSTALL_GUI; then
info "Building MycUI (GUI)..."
cd "$SCRIPT_DIR/mycui"
bun install
bun run tauri:build
if [ "$OS" = "Darwin" ]; then
APP_BUNDLE="src-tauri/target/release/bundle/macos/MycUI.app"
if [ ! -d "$APP_BUNDLE" ]; then
err "MycUI.app not found at $APP_BUNDLE"
exit 1
fi
info "Installing MycUI.app to /Applications..."
if [ -d "/Applications/MycUI.app" ]; then
SUDO_TARGET_DIR=/Applications need_sudo rm -rf /Applications/MycUI.app
fi
SUDO_TARGET_DIR=/Applications need_sudo cp -R "$APP_BUNDLE" /Applications/
ok "MycUI installed to /Applications/MycUI.app"
else
GUI_BIN="src-tauri/target/release/mycui"
if [ ! -f "$GUI_BIN" ]; then
# Tauri may use productName casing
GUI_BIN="src-tauri/target/release/MycUI"
fi
if [ ! -f "$GUI_BIN" ]; then
err "MycUI binary not found in src-tauri/target/release/"
exit 1
fi
info "Installing mycui to $INSTALL_DIR..."
need_sudo install -m 755 "$GUI_BIN" "$INSTALL_DIR/mycui"
ok "mycui installed to $INSTALL_DIR/mycui"
fi
fi
# ---------- done ----------
echo ""
ok "Done! Installed:"
$INSTALL_CLI && echo " myc -> $INSTALL_DIR/myc"
if $INSTALL_GUI; then
if [ "$OS" = "Darwin" ]; then
echo " MycUI -> /Applications/MycUI.app"
else
echo " mycui -> $INSTALL_DIR/mycui"
fi
fi