-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-service.sh
More file actions
executable file
·108 lines (91 loc) · 3.1 KB
/
Copy pathinstall-service.sh
File metadata and controls
executable file
·108 lines (91 loc) · 3.1 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
#!/bin/bash
# Install script for VAPI Phone Service
set -e
echo "🔧 Installing VAPI Phone Service"
echo "================================="
# Variables
SERVICE_NAME="vapi-phone"
SERVICE_FILE="${SERVICE_NAME}.service"
SCRIPT_PATH="/home/vapi/Projects/assistant.py/vapi-phone.py"
WRAPPER_SCRIPT="/home/vapi/Projects/assistant.py/start-vapi-phone.sh"
INSTALL_DIR="/etc/systemd/system"
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "❌ Please run as root (use sudo)"
exit 1
fi
# Check if script exists
if [ ! -f "$SCRIPT_PATH" ]; then
echo "❌ Script not found at: $SCRIPT_PATH"
echo " Please ensure the script is in the correct location"
exit 1
fi
# Check if virtual environment exists
VENV_PATH="/home/vapi/Projects/assistant.py/.venv"
if [ ! -d "$VENV_PATH" ]; then
echo "❌ Virtual environment not found at: $VENV_PATH"
echo " Please create virtual environment first:"
echo " cd /home/vapi/Projects/assistant.py"
echo " python3 -m venv .venv"
echo " source .venv/bin/activate"
echo " pip install -r requirements.txt"
exit 1
fi
# Check if Python executable exists in venv
VENV_PYTHON="$VENV_PATH/bin/python"
if [ ! -f "$VENV_PYTHON" ]; then
echo "❌ Python executable not found in virtual environment: $VENV_PYTHON"
exit 1
fi
# Check if wrapper script exists
if [ ! -f "$WRAPPER_SCRIPT" ]; then
echo "❌ Wrapper script not found at: $WRAPPER_SCRIPT"
echo " Please ensure start-vapi-phone.sh is in the project directory"
exit 1
fi
# Check if service file exists
if [ ! -f "$SERVICE_FILE" ]; then
echo "❌ Service file not found: $SERVICE_FILE"
echo " Please run this script from the directory containing $SERVICE_FILE"
exit 1
fi
echo "✅ Prerequisites check passed"
echo " Script: $SCRIPT_PATH"
echo " Wrapper: $WRAPPER_SCRIPT"
echo " Virtual environment: $VENV_PATH"
echo " Python executable: $VENV_PYTHON"
# Stop service if already running
if systemctl is-active --quiet "$SERVICE_NAME"; then
echo "🛑 Stopping existing service..."
systemctl stop "$SERVICE_NAME"
fi
# Copy service file
echo "📋 Installing service file..."
cp "$SERVICE_FILE" "$INSTALL_DIR/"
chmod 644 "$INSTALL_DIR/$SERVICE_FILE"
# Reload systemd
echo "🔄 Reloading systemd daemon..."
systemctl daemon-reload
# Enable service (start on boot)
echo "⚡ Enabling service to start on boot..."
systemctl enable "$SERVICE_NAME"
# Start service
echo "🚀 Starting service..."
systemctl start "$SERVICE_NAME"
# Check status
echo ""
echo "📊 Service Status:"
systemctl status "$SERVICE_NAME" --no-pager -l
echo ""
echo "✅ Installation complete!"
echo ""
echo "📖 Useful commands:"
echo " View status: sudo systemctl status $SERVICE_NAME"
echo " Start service: sudo systemctl start $SERVICE_NAME"
echo " Stop service: sudo systemctl stop $SERVICE_NAME"
echo " Restart: sudo systemctl restart $SERVICE_NAME"
echo " View logs: sudo journalctl -u $SERVICE_NAME -f"
echo " Disable: sudo systemctl disable $SERVICE_NAME"
echo ""
echo "🔍 To monitor logs in real-time:"
echo " sudo journalctl -u $SERVICE_NAME -f"