-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
77 lines (68 loc) · 2.43 KB
/
Taskfile.yaml
File metadata and controls
77 lines (68 loc) · 2.43 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
version: "3"
vars:
PI_HOST: "pizero.local"
PI_USER: "pi"
PI_PATH: "/home/{{.PI_USER}}"
tasks:
build:
desc: Build the project
env:
GOOS: linux
GOARCH: arm
GOARM: 6
cmds:
- echo "Building for Raspberry Pi Zero W..."
- go build -o dist/brother-cube-telegram-pi .
silent: true
upload:
desc: Upload the binary to Raspberry Pi
cmds:
- echo "Uploading to Raspberry Pi..."
- scp ./dist/brother-cube-telegram-pi config.yaml .env brother-cube-telegram.service {{.PI_USER}}@{{.PI_HOST}}:{{.PI_PATH}}
- ssh {{.PI_USER}}@{{.PI_HOST}} "sudo cp {{.PI_PATH}}/brother-cube-telegram.service /lib/systemd/system/" # Copy service file with root
- ssh {{.PI_USER}}@{{.PI_HOST}} "sudo systemctl daemon-reload"
silent: true
release:
desc: Build and upload the project to Raspberry Pi
deps:
- build
cmds:
- task: stop-service
- task: upload
- task: start-service
run:
desc: Run the project
cmds:
- go run main.go
silent: true
activate-service:
desc: Activate service to run on boot
cmds:
- ssh {{.PI_USER}}@{{.PI_HOST}} "sudo systemctl enable brother-cube-telegram.service" && echo "Service activated to run on boot."
start-service:
desc: Start the service
cmds:
- ssh {{.PI_USER}}@{{.PI_HOST}} "sudo systemctl start brother-cube-telegram.service" && echo "Service started."
silent: true
stop-service:
desc: Stop the service
cmds:
- ssh {{.PI_USER}}@{{.PI_HOST}} "sudo systemctl stop brother-cube-telegram.service" && echo "Service stopped."
silent: true
configure-gpio:
desc: Configure GPIO 17 as output high for relay control
cmds:
- echo "Checking GPIO configuration..."
- |
ssh {{.PI_USER}}@{{.PI_HOST}} "
if grep -q 'gpio=17=op,dh' /boot/firmware/config.txt; then
echo 'GPIO 17 output high is already configured in /boot/firmware/config.txt'
else
echo 'Adding GPIO 17 output high configuration to /boot/firmware/config.txt...'
echo '' | sudo tee -a /boot/firmware/config.txt
echo '# GPIO Configuration for Brother Cube Telegram Bot Relay' | sudo tee -a /boot/firmware/config.txt
echo 'gpio=17=op,dh' | sudo tee -a /boot/firmware/config.txt
echo 'GPIO 17 configured as output high (relay off). Reboot required to take effect.'
fi
"
silent: true