-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
284 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: SatellitePi Build | ||
|
||
on: | ||
# TODO not on every push | ||
push: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
name: build image | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: install packer | ||
run: | | ||
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - | ||
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | ||
sudo apt-get update && sudo apt-get install -y packer | ||
- name: build image | ||
run: | | ||
cd pi-image | ||
sudo packer init satellitepi.pkr.hcl | ||
sudo packer build --var branch=${GITHUB_REF_NAME} satellitepi.pkr.hcl | ||
- name: rename image | ||
run: | | ||
cd pi-image/output-satellitepi | ||
sudo mv image satellitepi-test.img | ||
# upload artifact | ||
- name: Upload production artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: satellitepi | ||
if-no-files-found: error | ||
path: | | ||
pi-image/output-satellitepi/*.img |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
output-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
SUBSYSTEM=="input", GROUP="input", MODE="0666" | ||
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0060", MODE:="666", GROUP="plugdev" | ||
KERNEL=="hidraw*", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0060", MODE:="666", GROUP="plugdev" | ||
SUBSYSTEM=="usb", ATTRS{idVendor}=="ffff", ATTRS{idProduct}=="1f40", MODE:="666", GROUP="plugdev" | ||
KERNEL=="hidraw*", ATTRS{idVendor}=="ffff", ATTRS{idProduct}=="1f40", MODE:="666", GROUP="plugdev" | ||
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0063", MODE:="666", GROUP="plugdev" | ||
KERNEL=="hidraw*", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0063", MODE:="666", GROUP="plugdev" | ||
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="006c", MODE:="666", GROUP="plugdev" | ||
KERNEL=="hidraw*", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="006c", MODE:="666", GROUP="plugdev" | ||
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="006d", MODE:="666", GROUP="plugdev" | ||
KERNEL=="hidraw*", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="006d", MODE:="666", GROUP="plugdev" | ||
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0080", MODE:="666", GROUP="plugdev" | ||
KERNEL=="hidraw*", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0080", MODE:="666", GROUP="plugdev" | ||
SUBSYSTEM=="usb", ATTRS{idVendor}=="ffff", ATTRS{idProduct}=="1f41", MODE:="666", GROUP="plugdev" | ||
KERNEL=="hidraw*", ATTRS{idVendor}=="ffff", ATTRS{idProduct}=="1f41", MODE:="666", GROUP="plugdev" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
The source code repository for this project can be found here: | ||
https://github.com/bitfocus/companion-satellite | ||
|
||
Full licensing information for Bitfocus Commpanion can be found by running 'satellite-license' | ||
in the terminal or visiting https://github.com/bitfocus/companion-satellite/blob/master/LICENSE in a web browser | ||
|
||
Any bugs, issues, or feature requests for the Companion Satellite software should be reported on the project's GitHub: | ||
https://github.com/bitfocus/companion-satellite/issues | ||
|
||
Companion Satellite should auto-start on this computer as soon as a viable network connection is detected. | ||
|
||
For more information on Companion Satellite specific commands you can run try running `satellite-help` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Set this to the ip address or hostname of your companion installation | ||
# examples: | ||
# - COMPANION_IP=192.168.100.1 | ||
# - COMPANION_IP=companion.example.org | ||
COMPANION_IP=127.0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash -e | ||
|
||
if [[ $(/usr/bin/id -u) -ne 0 ]]; then | ||
echo "Must be run as root. Try sudo satellite-edit-config" | ||
exit 1 | ||
fi | ||
|
||
# stop satellite | ||
systemctl stop satellite | ||
|
||
# open config editor | ||
nano /boot/satellite-config | ||
|
||
# restart satellite | ||
# reboot | ||
systemctl start satellite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
echo "To view the Companion Satellite License information run:" | ||
echo " $ satellite-license" | ||
echo "" | ||
|
||
echo "To stop/start/restart or check the status of Companion Satellite run:" | ||
echo " $ sudo systemctl [start/stop/restart/status] satellite" | ||
echo "" | ||
|
||
echo "To update Companion Satellite run:" | ||
echo " $ sudo satellite-update" | ||
echo "and follow the prompts" | ||
echo "" | ||
|
||
echo "To edit the companion configuration run:" | ||
echo " $ sudo companion-edit-config" | ||
echo "and follow the prompts" | ||
echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
less /usr/local/src/companion-satellite/LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash -e | ||
|
||
if [[ $(/usr/bin/id -u) -ne 0 ]]; then | ||
echo "Must be run as root. Try sudo satellite-update" | ||
exit 1 | ||
fi | ||
|
||
# stop satellite | ||
systemctl stop satellite | ||
|
||
# fetch new code | ||
cd /usr/local/src/companion-satellite | ||
git pull | ||
|
||
# TODO - prompt for which branch to use | ||
|
||
# do the update | ||
./pi-image/update.sh | ||
|
||
# restart satellite | ||
# reboot | ||
systemctl start satellite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[Unit] | ||
Description=Bitfocus Companion Satellite | ||
After=network-online.target | ||
Wants=network-online.target | ||
|
||
[Service] | ||
Type=simple | ||
User=satellite | ||
WorkingDirectory=/usr/local/src/companion-satellite | ||
EnvironmentFile=/boot/satellite-config | ||
ExecStart=/opt/fnm/aliases/default/bin/node /usr/local/src/companion-satellite/dist/main.js $COMPANION_IP | ||
Restart=on-failure | ||
KillSignal=SIGINT | ||
TimeoutStopSec=60 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
packer { | ||
required_plugins { | ||
arm-image = { | ||
version = "0.2.5" | ||
source = "github.com/solo-io/arm-image" | ||
} | ||
} | ||
} | ||
|
||
variable "branch" { | ||
type = string | ||
default = "master" | ||
} | ||
|
||
source "arm-image" "satellitepi" { | ||
iso_checksum = "sha256:d694d2838018cf0d152fe81031dba83182cee79f785c033844b520d222ac12f5" | ||
iso_url = "https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2022-01-28/2022-01-28-raspios-bullseye-arm64-lite.zip" | ||
last_partition_extra_size = 4294967296 | ||
qemu_binary = "qemu-aarch64-static" | ||
} | ||
|
||
build { | ||
sources = ["source.arm-image.satellitepi"] | ||
|
||
provisioner "shell" { | ||
#system setup | ||
inline = [ | ||
# # enable ssh | ||
# "touch /boot/ssh", | ||
|
||
# change the hostname | ||
"CURRENT_HOSTNAME=`cat /etc/hostname | tr -d \" \t\n\r\"`", | ||
"echo satellitepi > /etc/hostname", | ||
"sed -i \"s/127.0.1.1.*$CURRENT_HOSTNAME/127.0.1.1\tsatellitepi/g\" /etc/hosts", | ||
|
||
# add a system user | ||
"adduser --disabled-password satellite --gecos \"\"", | ||
|
||
# install some dependencies | ||
"apt-get update", | ||
"apt-get install -y git unzip curl libusb-1.0-0-dev libudev-dev cmake", | ||
"apt-get clean" | ||
] | ||
} | ||
|
||
provisioner "shell" { | ||
# run as root | ||
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} su root -c {{ .Path }}" | ||
inline_shebang = "/bin/bash -e" | ||
inline = [ | ||
# install fnm to manage node version | ||
# we do this to /opt/fnm, so that the satellite user can use the same installation | ||
"export FNM_DIR=/opt/fnm", | ||
"echo \"export FNM_DIR=/opt/fnm\" >> /root/.bashrc", | ||
"curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir /opt/fnm", | ||
"export PATH=/opt/fnm:$PATH", | ||
"eval \"`fnm env --shell bash`\"", | ||
|
||
# clone the repository | ||
"git clone https://github.com/bitfocus/companion-satellite.git -b ${var.branch} /usr/local/src/companion-satellite", | ||
"cd /usr/local/src/companion-satellite", | ||
|
||
# configure git for future updates | ||
"git config --global pull.rebase false", | ||
|
||
# run the update script | ||
"./pi-image/update.sh ${var.branch}", | ||
|
||
# enable start on boot | ||
"systemctl enable satellite", | ||
|
||
# copy config file into place | ||
"cp ./pi-image/satellite-config /boot/satellite-config" | ||
] | ||
} | ||
|
||
provisioner "shell" { | ||
# run as satellite user | ||
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} su satellite -c {{ .Path }}" | ||
inline_shebang = "/bin/bash -e" | ||
inline = [ | ||
"cd /usr/local/src/companion-satellite", | ||
|
||
# add the fnm node to this users path | ||
"echo \"export PATH=/opt/fnm/aliases/default/bin:\\$PATH\" >> ~/.bashrc" | ||
|
||
] | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash -e | ||
|
||
# this is the bulk of the update script | ||
# It is a separate file, so that the freshly cloned copy is invoked, not the old copy | ||
|
||
# imitiate the fnm setup done in .bashrc | ||
export FNM_DIR=/opt/fnm | ||
export PATH=/opt/fnm:$PATH | ||
eval "`fnm env`" | ||
|
||
cd /usr/local/src/companion-satellite | ||
|
||
# update the node version | ||
fnm use --install-if-missing | ||
fnm default $(fnm current) | ||
npm --unsafe-perm install -g yarn | ||
|
||
# install dependencies | ||
yarn config set network-timeout 100000 -g | ||
yarn | ||
|
||
# build typescript | ||
yarn build | ||
|
||
# update some tooling | ||
cp pi-image/50-satellite.rules /etc/udev/rules.d/ | ||
|
||
# update startup script | ||
cp pi-image/satellite.service /etc/systemd/system | ||
systemctl daemon-reload | ||
|
||
# install some scripts | ||
ln -s -f /usr/local/src/companion-satellite/pi-image/satellite-license /usr/local/bin/satellite-license | ||
ln -s -f /usr/local/src/companion-satellite/pi-image/satellite-help /usr/local/bin/satellite-help | ||
# This isn't something we want to allow for now, so skip these | ||
# ln -s -f /usr/local/src/companion-satellite/pi-image/satellite-update /usr/local/sbin/satellite-update | ||
# ln -s -f /usr/local/src/companion-satellite/pi-image/satellite-edit-config /usr/local/sbin/satellite-edit-config | ||
|
||
# install the motd | ||
ln -s -f /usr/local/src/companion-satellite/pi-image/motd /etc/motd |