-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (46 loc) · 2 KB
/
Makefile
File metadata and controls
54 lines (46 loc) · 2 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
SHELL := /bin/bash
export PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
start:
@make stop
@make fancontrol
@/usr/local/bin/ngrok tcp 22 > /dev/null &
@sleep 20
@for ((i=1; i<=8; i++)); do \
if curl -s http://localhost:4040/api/tunnels >/dev/null; then \
echo "Ngrok successfully started."; \
echo "🔍 Retrieving ngrok remote URL"; \
NGROK_REMOTE_URL=$$(curl -s http://localhost:4040/api/tunnels | jq -r '.tunnels[] | select(.proto == "tcp") | .public_url'); \
if [ -z "$$NGROK_REMOTE_URL" ]; then \
echo "❌ ERROR: ngrok doesn't seem to return a valid URL ($$NGROK_REMOTE_URL)"; \
exit 1; \
fi; \
echo "✅ Ngrok remote URL: $$NGROK_REMOTE_URL"; \
sleep 2; \
HOST_IP=$$(hostname -I); \
/usr/bin/python ./callmebot/sendtext.py "$$NGROK_REMOTE_URL \n $$HOST_IP"; \
exit 0; \
else \
if [ $$i -eq 8 ]; then \
echo "Failed to start Ngrok after 8 attempts."; \
exit 1; \
else \
echo "Attempt $$i failed to start Ngrok."; \
fi; \
sleep 2; \
fi; \
done
stop:
@echo "Stopping background ngrok process"
@PID=$$(ps -ef | grep 'ngrok' | grep -v 'grep' | awk '{print $$2}'); \
if [ -n "$$PID" ]; then \
kill -9 $$PID; \
echo "ngrok stopped"; \
else \
echo "No ngrok process found"; \
fi
shutdown:
@echo "Shutting down the Raspberry Pi"
sudo shutdown -h now
.PHONY: fancontrol
fancontrol:
@sudo ./fancontrol/fancontrol.sh &