-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
43 lines (32 loc) · 1.14 KB
/
Makefile
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
name="sonoff"
CHROOT=/etc/${name}
build:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 && go build -o dist/${name} -tags=release -ldflags "-s -w"
cp light.ico dist/light.ico
clean-build:
@rm --force --recursive dist/
install-folder:
sudo mkdir ${CHROOT}
sudo cp light.ico ${CHROOT}/light.ico
sudo cp sonoff.service /etc/systemd/user/${name}.service
sudo cp sonoff.sh ${CHROOT}/sonoff.sh
sudo cp config.toml ${CHROOT}/config.toml
sudo cp dist/${name} /usr/local/bin/${name}
sudo chmod 777 /usr/local/bin/${name}
sudo chmod 777 ${CHROOT}/sonoff.sh
systemctl --user daemon-reload
systemctl --user enable ${name}.service
systemctl --user start ${name}.service
install : build install-folder clean-build
@echo "\033[0;32m Install done \033[0m"
uninstall:
systemctl --user stop ${name}.service
systemctl --user disable ${name}.service
systemctl --user daemon-reload
sudo rm --force /usr/local/bin/${name}
sudo rm --force ${CHROOT}/sonoff.sh
sudo rm --force ${CHROOT}/config.toml
sudo rm --force ${CHROOT}/light.ico
sudo rm --force /etc/systemd/user/${name}.service
sudo rm --force --recursive ${CHROOT}
systemctl --user daemon-reload