-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
214 lines (177 loc) · 5.52 KB
/
install.sh
File metadata and controls
214 lines (177 loc) · 5.52 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/bin/sh
set -e
# Shofar Install Script
# Usage: curl -fsSL https://raw.githubusercontent.com/RooTooZ/shofar/master/install.sh | sh
REPO="RooTooZ/shofar"
INSTALL_DIR="$HOME/.local/bin"
DATA_DIR="$HOME/.local/share/shofar"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
info() {
printf "${GREEN}[INFO]${NC} %s\n" "$1"
}
warn() {
printf "${YELLOW}[WARN]${NC} %s\n" "$1"
}
error() {
printf "${RED}[ERROR]${NC} %s\n" "$1"
exit 1
}
# Detect OS
detect_os() {
case "$(uname -s)" in
Linux*) echo "linux" ;;
Darwin*) error "macOS: Pre-built binaries not available. Please build from source: make all" ;;
MINGW*|MSYS*|CYGWIN*) error "Windows: Pre-built binaries not available. Please build from source." ;;
*) error "Unsupported OS: $(uname -s)" ;;
esac
}
# Detect architecture
detect_arch() {
case "$(uname -m)" in
x86_64|amd64) echo "amd64" ;;
arm64|aarch64) echo "arm64" ;;
*) error "Unsupported architecture: $(uname -m)" ;;
esac
}
# Get latest version from GitHub
get_latest_version() {
curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | \
grep '"tag_name":' | sed -E 's/.*"v?([^"]+)".*/\1/'
}
# Download and install
install_shofar() {
OS=$(detect_os)
ARCH=$(detect_arch)
info "Detected: ${OS}/${ARCH}"
# Get version
if [ -n "$VERSION" ]; then
info "Installing version: $VERSION"
else
VERSION=$(get_latest_version)
if [ -z "$VERSION" ]; then
error "Failed to get latest version. Set VERSION env var manually."
fi
info "Latest version: $VERSION"
fi
# Construct download URL (filename includes 'v' prefix)
FILENAME="shofar-v${VERSION}-${OS}-${ARCH}"
if [ "$OS" = "windows" ]; then
FILENAME="${FILENAME}.zip"
else
FILENAME="${FILENAME}.tar.gz"
fi
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/v${VERSION}/${FILENAME}"
info "Downloading from: $DOWNLOAD_URL"
# Create temp directory
TMP_DIR=$(mktemp -d)
trap "rm -rf $TMP_DIR" EXIT
# Download
if command -v curl > /dev/null; then
curl -fsSL "$DOWNLOAD_URL" -o "$TMP_DIR/$FILENAME"
elif command -v wget > /dev/null; then
wget -q "$DOWNLOAD_URL" -O "$TMP_DIR/$FILENAME"
else
error "curl or wget required"
fi
# Extract
cd "$TMP_DIR"
if [ "$OS" = "windows" ]; then
unzip -q "$FILENAME"
BINARY="shofar.exe"
else
tar -xzf "$FILENAME"
fi
# Install
mkdir -p "$INSTALL_DIR"
mkdir -p "$DATA_DIR/models/whisper"
mkdir -p "$DATA_DIR/models/vosk"
mkdir -p "$DATA_DIR/models/llm"
mkdir -p "$DATA_DIR/lib"
if [ "$OS" = "windows" ]; then
mv "$BINARY" "$INSTALL_DIR/shofar.exe"
info "Installed to: $INSTALL_DIR/shofar.exe"
else
# Install binary and libraries
mv shofar "$INSTALL_DIR/shofar"
chmod +x "$INSTALL_DIR/shofar"
# Install Vosk library
if [ -d "lib" ]; then
cp -r lib/* "$DATA_DIR/lib/"
fi
# Create launcher script
cat > "$INSTALL_DIR/shofar-run" << LAUNCHER
#!/bin/sh
export LD_LIBRARY_PATH="$DATA_DIR/lib:\$LD_LIBRARY_PATH"
exec "$INSTALL_DIR/shofar" "\$@"
LAUNCHER
chmod +x "$INSTALL_DIR/shofar-run"
# Install desktop entry and icon
DESKTOP_DIR="$HOME/.local/share/applications"
ICON_DIR="$HOME/.local/share/icons"
mkdir -p "$DESKTOP_DIR" "$ICON_DIR"
if [ -f "shofar.png" ]; then
cp shofar.png "$ICON_DIR/shofar.png"
fi
if [ -f "shofar.desktop" ]; then
# Update Exec path in desktop file
sed "s|Exec=shofar-run|Exec=$INSTALL_DIR/shofar-run|g" shofar.desktop > "$DESKTOP_DIR/shofar.desktop"
sed -i "s|Icon=shofar|Icon=$ICON_DIR/shofar.png|g" "$DESKTOP_DIR/shofar.desktop"
chmod +x "$DESKTOP_DIR/shofar.desktop"
info "Desktop entry installed"
fi
info "Installed to: $INSTALL_DIR/shofar"
fi
# Check if in PATH
if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then
warn "$INSTALL_DIR is not in PATH"
echo ""
echo "Add to your shell config:"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
echo ""
fi
info "Installation complete!"
echo ""
echo "Run 'shofar' to start the application."
echo "Models will be downloaded on first use via Settings."
}
# Check dependencies
check_deps() {
OS=$(detect_os)
if [ "$OS" = "linux" ]; then
MISSING=""
# Check for portaudio
if ! ldconfig -p 2>/dev/null | grep -q libportaudio; then
MISSING="$MISSING portaudio"
fi
# Check for gtk3
if ! ldconfig -p 2>/dev/null | grep -q libgtk-3; then
MISSING="$MISSING gtk3"
fi
# Check for appindicator
if ! ldconfig -p 2>/dev/null | grep -q libayatana-appindicator; then
MISSING="$MISSING libayatana-appindicator"
fi
if [ -n "$MISSING" ]; then
warn "Missing dependencies:$MISSING"
echo ""
echo "Install with:"
echo " Arch: sudo pacman -S portaudio libayatana-appindicator gtk3 xdotool"
echo " Ubuntu: sudo apt install libportaudio2 libayatana-appindicator3-1 libgtk-3-0 xdotool"
echo ""
fi
fi
}
# Main
main() {
echo ""
echo " Shofar Installer"
echo " Voice-to-Text for Desktop"
echo ""
check_deps
install_shofar
}
main "$@"