-
Notifications
You must be signed in to change notification settings - Fork 5
284 lines (242 loc) · 10.2 KB
/
build.yml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
name: Build image, lint, and run tests
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install uv
python -m uv venv
python -m uv pip install .[test]
- name: Lint with ruff
run: |
source .venv/bin/activate
ruff check .
- name: Test with pytest
run: |
source .venv/bin/activate
pytest
- name: Build web app
run: |
cd gonotego/settings-server
npm install
npm run build
cd ../..
- name: Archive web app build
uses: actions/upload-artifact@v4
with:
name: web-app-dist
path: gonotego/settings-server/dist
build_image:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download web app build
uses: actions/download-artifact@v4
with:
name: web-app-dist
path: web-app-dist
- uses: pguyot/arm-runner-action@v2
id: build_image
with:
base_image: https://downloads.raspberrypi.com/raspios_armhf/images/raspios_armhf-2024-03-15/2024-03-15-raspios-bookworm-armhf.img.xz
bootpartition: 1
rootpartition: 2
image_additional_mb: 4000
bind: |
${{ github.workspace }}/web-app-dist:/mnt/web-app-dist
commands: |
echo "Updating!"
sudo apt update
echo "Installing dependencies!"
sudo apt install -y git firefox-esr xvfb portaudio19-dev libatlas-base-dev redis-server espeak \
rustc python3-dev libopenblas-dev iptables iptables-persistent nodejs npm
echo "Installing Go Note Go!"
mkdir -p /home/pi/code/github/dbieber
cd /home/pi/code/github/dbieber
git clone https://github.com/dbieber/GoNoteGo.git
cd GoNoteGo
# Checkout the specific commit
git checkout $GITHUB_SHA
echo "Including web app"
cp -r /mnt/web-app-dist /home/pi/code/github/dbieber/GoNoteGo/gonotego/settings-server/dist
echo "Setting up Python environment"
python3 -m venv env
./env/bin/pip install -e . # Install Python dependencies
echo "Start on boot"
sudo cat /etc/rc.local
sudo sed '/^exit 0/i \
sudo -u pi mkdir -p /home/pi/out \
bash /home/pi/code/github/dbieber/GoNoteGo/scripts/install_settings.sh \
/home/pi/code/github/dbieber/GoNoteGo/env/bin/supervisord -c /home/pi/code/github/dbieber/GoNoteGo/gonotego/supervisord.conf \
' /etc/rc.local > ./rc.local.modified && sudo mv ./rc.local.modified /etc/rc.local
sudo chmod +x /etc/rc.local
echo "Setting up Go Note Go:"
cp gonotego/settings/secure_settings_template.py gonotego/settings/secure_settings.py
echo "Manually edit secure_settings.py to configure your settings."
mkdir /home/pi/secrets
echo "Manually transfer secrets to /home/pi/secrets."
echo "Install geckodriver to known location"
cd
wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-arm7hf.tar.gz
tar -xvf geckodriver-v0.23.0-arm7hf.tar.gz
rm geckodriver-v0.23.0-arm7hf.tar.gz
sudo mv geckodriver /usr/local/bin
echo "Set up a wifi access point"
sudo apt install -y rng-tools hostapd dnsmasq
cat <<EOF > /etc/dhcpcd.conf
# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel
# Inform the DHCP server of our hostname for DDNS.
hostname
# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid
# Persist interface configuration when dhcpcd exits.
persistent
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu
# Most distributions have NTP support.
#option ntp_servers
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private
# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1
# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1
# fallback to static profile on eth0
#interface eth0
#fallback static_eth0
# Interface for Go Note Go Access Point
interface uap0
static ip_address=192.168.4.1/24
nohook wpa_supplicant
EOF
cat <<EOF >> /etc/dnsmasq.conf
interface=uap0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
EOF
cat <<EOF >> /etc/systemd/system/uap0.service
[Unit]
Description=Create uap0 interface
After=sys-subsystem-net-devices-wlan0.device
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/sbin/iw phy phy0 interface add uap0 type __ap
ExecStartPost=/usr/bin/ip link set dev uap0 address d8:3a:dd:06:5e:ca
ExecStartPost=/sbin/ifconfig uap0 up
ExecStop=/sbin/iw dev uap0 del
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl start uap0.service
sudo systemctl enable uap0.service
cat <<EOF >> /etc/hostapd/hostapd.conf
interface=uap0
ssid=GoNoteGo-Wifi
hw_mode=g
channel=4
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=swingset
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOF
cat <<EOF >> /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
EOF
sudo systemctl start hostapd
sudo systemctl start dnsmasq
sudo systemctl enable hostapd
sudo systemctl enable dnsmasq
cat <<EOF >> /etc/sysctl.conf
net.ipv4.ip_forward=1
EOF
# Attempt to not run config on first boot
sudo apt purge piwiz -y
sudo raspi-config nonint do_wifi_country US
touch /boot/ssh
echo "pi:$(echo 'raspberry' | openssl passwd -6 -stdin)" | sudo tee /boot/userconf > /dev/null
# Enable ssh
ssh-keygen -A &&
update-rc.d ssh enable
# Add commands to the bash history for debugging purposes
cat << EOF >> /home/pi/.bash_history
sudo reboot now
sudo systemctl daemon-reload
sudo systemctl status uap0.service
sudo systemctl status dnsmasq.service
sudo systemctl status hostapd.service
sudo journalctl -u uap0.service
sudo journalctl -u dnsmasq.service
sudo journalctl -u hostapd.service
ip addr show uap0
sudo ip addr add 192.168.4.1/24 dev uap0
cat /etc/rc.local
cat /etc/default/hostapd
cat /etc/hostapd/hostapd.conf
cat /etc/systemd/system/uap0.service
cat /etc/sysctl.conf
cat /etc/dhcpcd.conf
cat /etc/dnsmasq.conf
python -m http.server
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -t nat -L
sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
nano /home/pi/code/github/dbieber/GoNoteGo/gonotego/settings/secure_settings.py
/home/pi/code/github/dbieber/GoNoteGo/env/bin/python
/home/pi/code/github/dbieber/GoNoteGo/env/bin/supervisord -c /home/pi/code/github/dbieber/GoNoteGo/gonotego/supervisord.conf
/home/pi/code/github/dbieber/GoNoteGo/env/bin/supervisorctl -u go -p notego status
/home/pi/code/github/dbieber/GoNoteGo/env/bin/supervisorctl -u go -p notego restart all
cd /home/pi/code/github/dbieber/GoNoteGo/
EOF
- name: Compress the release image
run: |
sudo fdisk -l
sudo ls /etc/xdg/autostart/
mv ${{ steps.build_image.outputs.image }} go-note-go.img
xz -0 -T 0 -v go-note-go.img
- name: Upload release image
uses: actions/upload-artifact@v4
with:
name: Release image
path: go-note-go.img.xz