-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·112 lines (99 loc) · 3.71 KB
/
install.sh
File metadata and controls
executable file
·112 lines (99 loc) · 3.71 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
#!/bin/bash
set -e
REPO_URL="https://github.com/HexmosTech/dPrompts"
BINARY_URL_LINUX="https://github.com/HexmosTech/dPrompts/releases/latest/download/dpr"
BINARY_URL_WIN="https://github.com/HexmosTech/dPrompts/releases/latest/download/dpr.exe"
BINARY_NAME_LINUX="dpr"
BINARY_NAME_WIN="dpr.exe"
OLLAMA_MODEL="gemma2:2b"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
CONFIG_SRC="$SCRIPT_DIR/.dprompts.toml"
# Detect OS
OS_TYPE="$(uname -s)"
IS_WINDOWS=0
if [[ "$OS_TYPE" == "MINGW"* || "$OS_TYPE" == "MSYS"* || "$OS_TYPE" == "CYGWIN"* ]]; then
IS_WINDOWS=1
fi
if [ $IS_WINDOWS -eq 1 ]; then
CONFIG_DEST="$USERPROFILE\\.dprompts.toml"
else
REAL_HOME=$(getent passwd ${SUDO_USER:-$USER} | cut -d: -f6)
CONFIG_DEST="$REAL_HOME/.dprompts.toml"
fi
echo "== dPrompts Installer =="
if [ $IS_WINDOWS -eq 1 ]; then
echo "Detected Windows environment."
echo "Downloading latest dPrompts binary for Windows..."
curl -L -o "$BINARY_NAME_WIN" "$BINARY_URL_WIN"
echo "Moving binary to current directory."
mv "$BINARY_NAME_WIN" .
echo "Binary saved as $BINARY_NAME_WIN in current directory."
else
echo "Detected Linux/Unix environment."
echo "Downloading latest dPrompts binary..."
curl -L "$BINARY_URL_LINUX" -o "$BINARY_NAME_LINUX"
chmod +x "$BINARY_NAME_LINUX"
echo "Moving binary to /usr/local/bin/ (this may require your password)..."
sudo mv "$BINARY_NAME_LINUX" /usr/local/bin/
fi
# Only copy config if it doesn't already exist
if [ -f "$CONFIG_DEST" ]; then
echo "Config file $CONFIG_DEST already exists. Skipping copy."
elif [ -f "$CONFIG_SRC" ]; then
cp "$CONFIG_SRC" "$CONFIG_DEST"
if [ $IS_WINDOWS -eq 0 ]; then
sudo chown $SUDO_USER:$SUDO_USER "$CONFIG_DEST" 2>/dev/null || true
fi
echo "Copied $CONFIG_SRC to $CONFIG_DEST"
else
echo "WARNING: $CONFIG_SRC not found. Please create your config and place it at $CONFIG_DEST"
fi
if [ $IS_WINDOWS -eq 1 ]; then
echo "Ollama installation and server management must be done manually on Windows."
echo "Please download and install Ollama from https://ollama.com/download"
echo "After installation, ensure the Ollama server is running and the '$OLLAMA_MODEL' model is pulled:"
echo " ollama serve"
echo " ollama pull $OLLAMA_MODEL"
echo "== Installation complete! =="
echo "You can now use the '$BINARY_NAME_WIN worker' command to start the dPrompts worker."
exit 0
fi
if ! command -v ollama &> /dev/null; then
echo "Ollama is not installed."
read -p "Do you want to install Ollama? (y/n): " yn
if [[ "$yn" =~ ^[Yy]$ ]]; then
curl -fsSL https://ollama.com/install.sh | sh
else
echo "Please install Ollama manually and re-run this script."
exit 1
fi
else
echo "Ollama is already installed."
fi
if ! pgrep -x "ollama" > /dev/null; then
echo "Ollama server is not running. Starting Ollama server in the background..."
nohup ollama serve > /dev/null 2>&1 &
sleep 2
if pgrep -x "ollama" > /dev/null; then
echo "Ollama server started."
else
echo "Failed to start Ollama server. Please start it manually."
exit 1
fi
else
echo "Ollama server is already running."
fi
if ! ollama list | grep -q "$OLLAMA_MODEL"; then
echo "Ollama model '$OLLAMA_MODEL' is not present."
read -p "Do you want to pull the model '$OLLAMA_MODEL'? (y/n): " yn
if [[ "$yn" =~ ^[Yy]$ ]]; then
ollama pull "$OLLAMA_MODEL"
else
echo "Please pull the model manually and re-run this script."
exit 1
fi
else
echo "Ollama model '$OLLAMA_MODEL' is already present."
fi
echo "== Installation complete! =="
echo "You can now use the 'dpr worker' command to start the dPrompts worker."