-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·103 lines (84 loc) · 3.8 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·103 lines (84 loc) · 3.8 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
#!/bin/bash
# GERTIE Install Script
# Generates systemd service files from templates using values in gertie.toml
#
# Usage:
# 1. cp gertie.toml.example gertie.toml
# 2. Edit gertie.toml with your username and install path
# 3. ./install.sh
#
# What this does:
# - Reads GERTIE_USER and GERTIE_DIR from gertie.toml
# - Generates .service files in generated-services/
# - Optionally installs them to /etc/systemd/system/ (requires sudo)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_FILE="$SCRIPT_DIR/gertie.toml"
OUTPUT_DIR="$SCRIPT_DIR/generated-services"
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; CYAN='\033[0;36m'; NC='\033[0m'
# ── Read gertie.toml ──────────────────────────────────────────────────────────
if [ ! -f "$CONFIG_FILE" ]; then
echo -e "${RED}ERROR: gertie.toml not found.${NC}"
echo -e " Run: ${CYAN}cp gertie.toml.example gertie.toml${NC} and fill in your values."
exit 1
fi
# Parse TOML with grep (no toml parser needed)
GERTIE_USER=$(grep -E '^user\s*=' "$CONFIG_FILE" | head -1 | sed 's/.*=\s*"\(.*\)"/\1/')
GERTIE_DIR=$(grep -E '^install_dir\s*=' "$CONFIG_FILE" | head -1 | sed 's/.*=\s*"\(.*\)"/\1/')
if [ -z "$GERTIE_USER" ] || [ -z "$GERTIE_DIR" ]; then
echo -e "${RED}ERROR: Could not read 'user' or 'install_dir' from gertie.toml${NC}"
exit 1
fi
echo -e "${CYAN}GERTIE Install${NC}"
echo -e " User: ${GREEN}$GERTIE_USER${NC}"
echo -e " Install dir: ${GREEN}$GERTIE_DIR${NC}"
echo ""
# ── Generate service files ────────────────────────────────────────────────────
mkdir -p "$OUTPUT_DIR"
SERVICE_TEMPLATES=(
"gertie-video.service"
"gertie-capture.service"
"local_camera_node.service"
"lisiparoi/lisiparoi.service"
)
DESKTOP_TEMPLATES=(
"assets/GERTIE_Qt.desktop"
"lisiparoi/desktop/Lights_OFF.desktop"
"lisiparoi/desktop/Lights_25.desktop"
"lisiparoi/desktop/Lights_50.desktop"
"lisiparoi/desktop/Lights_75.desktop"
"lisiparoi/desktop/Lights_100.desktop"
)
for template in "${SERVICE_TEMPLATES[@]}"; do
src="$SCRIPT_DIR/$template"
dst="$OUTPUT_DIR/$(basename $template)"
if [ ! -f "$src" ]; then
echo -e " ${YELLOW}Skipping $template (not found)${NC}"
continue
fi
sed "s|{GERTIE_USER}|$GERTIE_USER|g; s|{GERTIE_DIR}|$GERTIE_DIR|g" "$src" > "$dst"
echo -e " ${GREEN}Generated: generated-services/$(basename $template)${NC}"
done
for template in "${DESKTOP_TEMPLATES[@]}"; do
src="$SCRIPT_DIR/$template"
dst="$OUTPUT_DIR/$(basename $template)"
if [ ! -f "$src" ]; then continue; fi
sed "s|{GERTIE_USER}|$GERTIE_USER|g; s|{GERTIE_DIR}|$GERTIE_DIR|g" "$src" > "$dst"
echo -e " ${GREEN}Generated: generated-services/$(basename $template)${NC}"
done
echo ""
# ── Optionally install ────────────────────────────────────────────────────────
if [ "${1:-}" = "--install" ]; then
echo -e "${CYAN}Installing service files to /etc/systemd/system/ ...${NC}"
for svc in "$OUTPUT_DIR"/*.service; do
sudo cp "$svc" /etc/systemd/system/
echo -e " ${GREEN}Installed $(basename $svc)${NC}"
done
sudo systemctl daemon-reload
echo -e "${GREEN}✓ Services installed. Enable with:${NC}"
echo -e " sudo systemctl enable gertie-video.service gertie-capture.service"
echo -e " sudo systemctl enable local_camera_node.service"
else
echo -e "Service files generated in ${CYAN}generated-services/${NC}"
echo -e "To install: ${CYAN}./install.sh --install${NC} (requires sudo)"
fi