forked from jagheterfredrik/wallbox-mqtt-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
55 lines (44 loc) · 1.41 KB
/
install.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
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Remove any previous installation, except any configuration
systemctl stop mqtt-bridge 2> /dev/null
systemctl disable mqtt-bridge 2> /dev/null
rm -f /lib/systemd/system/mqtt-bridge.service
find ~/mqtt-bridge/ -type f ! -name bridge.ini -delete
# Download the bridge
echo "Downloading the bridge"
arch=$(uname -m)
if [ "$arch" == "armv7l" ]; then
curl -sSfL --create-dirs -o ~/mqtt-bridge/bridge https://github.com/sweber/wallbox-mqtt-bridge/releases/download/v20241029_1/bridge-armhf
elif [ "$arch" == "aarch64" ]; then
curl -sSfL --create-dirs -o ~/mqtt-bridge/bridge https://github.com/sweber/wallbox-mqtt-bridge/releases/download/v20241029_1/bridge-arm64
else
echo "Unknown architecture $arch"
exit 1
fi
chmod +x ~/mqtt-bridge/bridge
# Create config if it doesn't exist
if [ ! -e ~/mqtt-bridge/bridge.ini ]; then
echo "No configuration found, please provide it now"
cd ~/mqtt-bridge/
./bridge --config
fi
# Install the service
echo "Setting up auto-start"
content="[Unit]
Description=MQTT Bridge
After=network.target
Requires=mysqld.service
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=root
ExecStart=/home/root/mqtt-bridge/bridge /home/root/mqtt-bridge/bridge.ini
[Install]
WantedBy=multi-user.target"
echo "$content" > /lib/systemd/system/mqtt-bridge.service
systemctl daemon-reload
systemctl enable mqtt-bridge
systemctl restart mqtt-bridge
echo "Done!"