-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathinstall-systemd.sh
More file actions
executable file
·98 lines (80 loc) · 2.57 KB
/
Copy pathinstall-systemd.sh
File metadata and controls
executable file
·98 lines (80 loc) · 2.57 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
#!/bin/bash
set -euo pipefail
# Flint Systemd Installation Script
# This script installs Flint as a systemd service
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if running as root
if [[ $EUID -ne 0 ]]; then
log_error "This script must be run as root"
exit 1
fi
# Check if Flint is installed
if ! command -v flint &> /dev/null; then
log_error "Flint is not installed. Please install it first:"
echo "curl -fsSL https://raw.githubusercontent.com/volantvm/flint/main/install.sh | sh"
exit 1
fi
# Check if libvirtd is running
if ! systemctl is-active --quiet libvirtd; then
log_error "libvirtd is not running. Please start it first:"
echo "systemctl start libvirtd"
exit 1
fi
log_info "Installing Flint as a systemd service..."
# Create flint user and group
if ! id -u flint &>/dev/null; then
log_info "Creating flint user..."
useradd -r -s /bin/false -d /var/lib/flint -m flint
fi
# Create necessary directories
log_info "Creating directories..."
mkdir -p /var/lib/flint
mkdir -p /var/lib/flint/images
mkdir -p /var/log/flint
# Set ownership
chown -R flint:flint /var/lib/flint
chown -R flint:flint /var/log/flint
# Add flint user to libvirt group for access to libvirt socket
usermod -a -G libvirt flint
# Copy systemd service file
log_info "Installing systemd service..."
cp flint.service /etc/systemd/system/
chmod 644 /etc/systemd/system/flint.service
# Reload systemd
systemctl daemon-reload
# Enable and start service
log_info "Enabling and starting Flint service..."
systemctl enable flint
systemctl start flint
# Check status
if systemctl is-active --quiet flint; then
log_info "Flint service started successfully!"
log_info "Service status: $(systemctl is-active flint)"
log_info "Flint is now running at: http://localhost:5550"
log_info "API Key: $(su - flint -c 'flint api-key' 2>/dev/null | grep 'Flint API Key' | cut -d: -f2 | xargs)"
else
log_error "Failed to start Flint service"
log_info "Check service status: systemctl status flint"
log_info "Check logs: journalctl -u flint -f"
exit 1
fi
log_info "Installation complete!"
log_info ""
log_info "Useful commands:"
log_info " Start service: systemctl start flint"
log_info " Stop service: systemctl stop flint"
log_info " Restart service: systemctl restart flint"
log_info " View logs: journalctl -u flint -f"
log_info " Check status: systemctl status flint"