-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_chatbot.sh.bak.1763194937
More file actions
executable file
·71 lines (61 loc) · 2.05 KB
/
run_chatbot.sh.bak.1763194937
File metadata and controls
executable file
·71 lines (61 loc) · 2.05 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
#!/bin/bash
# Set working directory
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
# Bluetooth/Pulse audio routing env
. "/home/dash/whisplay-ai-chatbot/.bluetooth_audio_env.sh"
# Find the sound card index for wm8960soundcard
card_index=$(awk '/wm8960soundcard/ {print $1}' /proc/asound/cards | head -n1)
# Default to 1 if not found
if [ -z "$card_index" ]; then
card_index=1
fi
echo "Using sound card index: $card_index"
# Output current environment information (for debugging)
echo "===== Start time: $(date) ====="
echo "Current user: $(whoami)"
echo "Working directory: $(pwd)"
working_dir=$(pwd)
echo "PATH: $PATH"
echo "Python version: $(python3 --version)"
echo "Node version: $(node --version)"
sleep 5
# Adjust volume
amixer -c $card_index set Speaker 114
# Start the service
echo "Starting Node.js application..."
cd $working_dir
# load .env variables, exclude comments and empty lines
# check if .env file exists
serve_ollama=false
if [ -f ".env" ]; then
# Load only SERVE_OLLAMA from .env (ignore comments/other vars)
if grep -Eq '^[[:space:]]*SERVE_OLLAMA[[:space:]]*=' .env; then
val=$(grep -E '^[[:space:]]*SERVE_OLLAMA[[:space:]]*=' .env | tail -n1 | cut -d'=' -f2-)
# trim whitespace and surrounding quotes
SERVE_OLLAMA=$(echo "$val" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/^"//' -e 's/"$//' -e "s/^'//" -e "s/'$//")
export SERVE_OLLAMA
fi
echo ".env variables loaded."
# check if SERVE_OLLAMA is set to true
if [ "$SERVE_OLLAMA" = "true" ]; then
serve_ollama=true
fi
else
echo ".env file not found, please create one based on .env.template."
exit 1
fi
if [ "$serve_ollama" = true ]; then
echo "Starting Ollama server..."
ollama serve &
fi
SOUND_CARD_INDEX=$card_index yarn start
# After the service ends, perform cleanup
echo "Cleaning up after service..."
if [ "$serve_ollama" = true ]; then
echo "Stopping Ollama server..."
pkill ollama
fi
# Record end status
echo "===== Service ended: $(date) ====="