-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.sh
46 lines (36 loc) · 869 Bytes
/
start.sh
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
#!/bin/bash
set -e
function generate_random_string() {
length=32
random_string=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c ${length})
echo "${random_string}"
}
if [ -z "$API_SECRET" ]; then
API_SECRET="$(generate_random_string)"
echo "API_SECRET set to ${API_SECRET}"
export API_SECRET
fi
if [[ $PUBLIC_KEY ]]
then
mkdir -p ~/.ssh
chmod 700 ~/.ssh
cd ~/.ssh
echo "$PUBLIC_KEY" >> authorized_keys
chmod 700 -R ~/.ssh
cd /
service ssh start
else
echo "No public key provided, skipping ssh setup"
fi
echo "Starting ollama"
ollama serve &
while ! curl "$OLLAMA_URL"; do
sleep 1
done
echo "Pulling $OLLAMA_MODEL_NAME from ollama library"
ollama pull "$OLLAMA_MODEL_NAME"
cd /workspace
echo "Starting api"
uvicorn wikidatachat:app --reload --host 0.0.0.0 --port 8000 &
echo "Ready"
sleep infinity