improve setup automation

This commit is contained in:
Boaz Sender 2025-04-02 11:01:33 -07:00
parent f002f7a140
commit 4a912fc912
9 changed files with 65 additions and 16 deletions

View file

@ -6,8 +6,9 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"deploy:broadcaster": "rsync -avx rsync -a --exclude-from='exclude.txt' ./ grace@broadcaster.local:portal", "deploy": "npm run build && rsync -av --exclude-from='exclude.txt' ./ grace@listener.local:portal",
"deploy:listener": "npm run build && rsync -avx rsync -a --exclude-from='exclude.txt' ./ grace@listener.local:portal" "setup:broadcaster": "rsync -av --exclude-from='exclude.txt' ./ grace@broadcaster.local:portal",
"setup:listener": "rsync -av --exclude-from='exclude.txt' ./ grace@listener.local:portal && ssh grace@listener.local -t 'cd portal/setup/listener && chmod +x install.sh && sudo ./install.sh; bash -l'"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View file

@ -1,41 +1,31 @@
#!/bin/bash #!/bin/bash
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)" 1>&2 echo "This script must be run as root. Try again with \n sudo ./install.sh" 1>&2
exit 1 exit 1
fi fi
is_Raspberry=$(cat /proc/device-tree/model | awk '{print $1}') is_Raspberry=$(cat /proc/device-tree/model | awk '{print $1}')
if [ "x${is_Raspberry}" != "xRaspberry" ] ; then if [ "x${is_Raspberry}" != "xRaspberry" ] ; then
echo "Sorry, this only works on raspberry pi" echo "This script contains drivers for the Raspberry pi and will not work on the current platform."
exit 1 exit 1
fi fi
ver="1.0"
# we create a dir with this version to ensure that 'dkms remove' won't delete
# the sources during kernel updates
marker="0.0.0"
apt update apt update
apt -y install git vim zsh mplayer apt -y install git vim zsh mplayer
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
curl https://get.volta.sh | bash curl https://get.volta.sh | bash
volta install node volta install node
git clone git@git.featherboaz.com:boazsender/portal.git
cd portal cd portal
npm install npm install
npx prisma generate && npx prisma db push && npx prisma db seed npx prisma generate && npx prisma db push && npx prisma db seed
cp ./screen.service /lib/systemd/system/ cp ./screen.service /lib/systemd/system/
cp player.service /lib/systemd/system/ cp ./player.service /lib/systemd/system/
git clone https://github.com/waveshare/WM8960-Audio-HAT git clone https://github.com/waveshare/WM8960-Audio-HAT
cd WM8960-Audio-HAT cd WM8960-Audio-HAT
sh ./install.sh sudo ./install.sh
systemctl daemon-reload systemctl daemon-reload
systemctl enable player systemctl enable player
@ -45,6 +35,10 @@ systemctl start player
systemctl start screen systemctl start screen
systemctl start wm8960-soundcard systemctl start wm8960-soundcard
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
echo "------------------------------------------------------" echo "------------------------------------------------------"
echo "The Black Portal listening device has been provisioned." echo "The Black Portal listening device has been provisioned."
echo "Reboot this raspberry pi now in order for things to work" echo "Reboot this raspberry pi now in order for things to work"

54
setup/listener/readme.md Normal file
View file

@ -0,0 +1,54 @@
# Listener software (Mplayer + drivers)
## Summary
User: grace
Hostname: listener.local
Password: emergence
Running mplayer, soundcard library, lcd graphics library, and custom python code for text printing logic.
## Bill of Materials
- Raspberry pi zero 2 wh - https://www.waveshare.com/product/raspberry-pi/boards-kits/raspberry-pi-zero-2-w-cat/raspberry-pi-zero-2-w.htm?sku=21038
- Waveshare UPS with 1000mah battery - https://www.waveshare.com/ups-hat-c.htm
- Waveshare sound card hat with speakers- https://www.waveshare.com/wm8960-audio-hat.htm
- 1602 LCD screen - https://www.waveshare.com/lcd1602-i2c-module-blue.htm?sku=30496
- Jumper wires - https://www.waveshare.com/product/accessories/adapters-cables-antennas/jumper-wires/jumper-wire-1-pin-2.54-pitch-200mm.htm
- mini HDMI to hdmi cable - https://hosatech.com/products/video/hdmi/hdmc-400/
- micro USB male to usb a femail adapter - https://www.amazon.com/dp/B01C6032G0
- Keyboard with usb a cable - https://www.amazon.com/AmazonBasics-Matte-Keyboard-QWERTY-Layout/dp/B07WJ5D3H4/
## Hardware assembly
- Solder header to the pi if not pre-soldered
- Plug the battery into the UPS board
- Screw the UPS to the pi
- Screw a next level of standoffs to the pi
- Put the audio hat on the pi's headers, and screw it to the standoffs
- Plug in the speakers
- Plug the jumper wires into the screen and the pi according to the [screen-wiring.png](screen-wiring.png) file (via https://peppe8o.com/1602-lcd-raspberry-pi-display/).
## Pre work
1. Install raspian lite 64 for raspi zero. Make sure to configure user and wifi and turn on ssh services when you install.
2. Boot the pi.
## Setup instructions
### Using node and npm
If you have node and npm installed, you can run this command from inside this repository:
```
npm run setup:listener
```
If you'd like to install node and npm try installing https://volta.sh and then running volta install node@latest.
### Using the terminal
If you do not have node and npm installed you can run this command from inside this repository:
```
rsync -av --exclude-from='exclude.txt' ./ grace@listener.local:portal && ssh grace@listener.local -t 'cd portal/setup/listener && chmod +x install.sh && sudo ./install.sh; bash -l'
```