-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·58 lines (45 loc) · 1.44 KB
/
deploy.sh
File metadata and controls
executable file
·58 lines (45 loc) · 1.44 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
#!/bin/bash
# Deployment script for IANUA CalDAV Server
# This script stops the current service, pulls updates, installs dependencies, and starts the service
SERVICE_NAME=ianuacaldav
REPO_DIR=$(pwd)
VENV_DIR="$REPO_DIR/venv"
echo "Stopping current $SERVICE_NAME service..."
sudo systemctl stop $SERVICE_NAME 2>/dev/null || echo "Service not running or failed to stop"
echo "Pulling latest updates from git..."
git pull
echo "Setting up virtual environment..."
if [ ! -d "$VENV_DIR" ]; then
echo "Creating virtual environment..."
python3 -m venv "$VENV_DIR"
fi
echo "Activating virtual environment and installing dependencies..."
source "$VENV_DIR/bin/activate"
pip install -r requirements.txt
echo "Setting up systemd service..."
if [ ! -f /etc/systemd/system/$SERVICE_NAME.service ]; then
echo "Creating systemd service file..."
sudo tee /etc/systemd/system/$SERVICE_NAME.service > /dev/null << EOF
[Unit]
Description=IANUA CalDAV Server
After=network.target
[Service]
Type=simple
User=$USER
WorkingDirectory=$REPO_DIR
ExecStart=$VENV_DIR/bin/python main.py
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable $SERVICE_NAME
else
echo "Systemd service file already exists"
fi
echo "Starting $SERVICE_NAME service..."
sudo systemctl start $SERVICE_NAME
echo "Checking service status..."
sudo systemctl status $SERVICE_NAME --no-pager -l
echo "Deployment complete!"