-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
43 lines (36 loc) · 1.27 KB
/
deploy.sh
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
#!/bin/bash
# Variables
REPO_URL="https://github.com/NerdBase-by-Stark/Stark-HA-Energy-Monitor.git"
HA_CONFIG_DIR="${1:-/config}"
CUSTOM_COMPONENTS_DIR="$HA_CONFIG_DIR/custom_components"
WWW_DIR="$HA_CONFIG_DIR/www/stark_energy_monitor"
# Clone the repository
if git clone "$REPO_URL" temp_stark_energy_monitor; then
echo "Repository cloned successfully."
else
echo "Error: Failed to clone repository."
exit 1
fi
# Copy the custom component files to Home Assistant
if cp -r temp_stark_energy_monitor/custom_components/stark_energy_monitor "$CUSTOM_COMPONENTS_DIR/"; then
echo "Custom component files copied successfully."
else
echo "Error: Failed to copy custom component files."
rm -rf temp_stark_energy_monitor
exit 1
fi
# Ensure www directory exists and copy resources
if [ ! -d "$WWW_DIR" ]; then
mkdir -p "$WWW_DIR"
fi
# Copy the HTML and other web resources to the www folder
if cp -r temp_stark_energy_monitor/www/stark_energy_monitor/* "$WWW_DIR/"; then
echo "Web resources copied successfully."
else
echo "Error: Failed to copy web resources."
rm -rf temp_stark_energy_monitor
exit 1
fi
# Clean up
rm -rf temp_stark_energy_monitor
echo "Deployment complete. Please restart Home Assistant to activate the Stark Energy Monitor integration."