Skip to content

Commit

Permalink
Remaster (#157)
Browse files Browse the repository at this point in the history
* Restructure

* More scaffolding and config format changes

* Initialise angula app

* Build recipe for development

* Clean

* Workflow for remaster

* Fix syntax

* Fix syntax

* Update readme

* Add badge

* Update README.md

* No apache in remaster

* simple run

* Run with input fix

* [158]feat(dev-environment): configured angular proxy / added instruct… (#159)

* [158]feat(dev-environment): configured angular proxy / added instructions in readme

* [158]chore(readme): update readme

* Fixed some typos, used correct port

* Remove vscode

* Working unit test for os release info

* Add test for backend to CI

* Add os info handler

* Enrich system info response with temperature

* Add kernel info to the api

* Api cosmetics

* Trim new line suffix

* Landing page scaffolding

* periodic poll update

* Feature/websocket comms (#163)

This PR provides the scaffolding for single connection communication between the UI and the backend (sitting on the raspberry pi)

Leaving the logs for now but we should remove some chatty ones before final release (which is gonna take a while)

Inception
The FE and BE commincation will be in a biderectional Command => Event driven approach.
The FE implementation splits the websocket (on inteface level) into a source (for reading the events) and a sink (for sending the commands) .
A sink is essentially a consumer and a source a producer. In this case the interface is exposing the Source for consumers (component views) to process events and the sink for sending commands (i.e. with a service call interfacing a component) (thus replacing http calls )

* pre commit

* Switch to pre-commit

* Fix linting

* Instructions for pre commit

* unused method

* Feature/dev environment setup (#171)

* fiear(dev-environment): add install-dev section in makefile update go.sum

* feat(install-dev): add git to dev dependencies

* Feature/poweroff component (#172)

## Feature
- Simple component that provides a poweroff and reboot interface
- Simple backend implementation - no scheduling
- Connecting the component calls to the websocket e2e
## Fixes
- Try to reconnect if websocket closes

Resolves #172

* feat(websockets): add rfc ping pong, incremental backoff, handle subscriptions in liveinfo (#173)

* feat(websockets): add rfc ping pong, incremental backoff, handle subscriptions in liveinfo

* chore(linting): remove unneeded printf

* chore(configration): update interval

* Reboot and shutdown by issuing syscalls instead of calling shell commands (#174)

Currently the poweroff function inherits the priviledges of the gui since we are running this from the e.g. gnome-terminal and poweroff and reboot work without needing root priviledges as they inherit the gui ones (I think). However when it runs as a service this will not apply.

Go has also a linux syscall API that we can use instead of issuing shell commands which will dramatically decrease response times (although not a big deal for power management, having this paradigm in would be beneficial for later)

* simple skin with routing on components (#175)

Very simple main view, with mob friendly side panel and routing outlet in the main screen to navigate components

Libary updates

* Feature/166 online indicator (#176)

* feat(websockets): add rfc ping pong, incremental backoff, handle subscriptions in liveinfo

* chore(linting): remove unneeded printf

* chore(configration): update interval

* feat(OnineIndicator): added online indicator module/ updated websocket service to report connectivity

* chore(linting): update precommit hook

* - Servified pi-web-agent (#177)

* - Servified pi-web-agent (currently tested on fedora)
- Created convenient make commands for installation/uninstallation - only for dev usage but anyone can use
- Fixed an issue with the routing that was refreshing the page
- Fixed an issue with golang routing to be able to serve all assets

* Feature/package deb (#181)

- Major cleanup of unused files
- Auto releases debian packages on a new tag

* Update README.md

* Update README.md

* Feature/new logo (#186)

* favicon + logo

* Update README.md

* Attempt to fix installation scripts for updates

* Scaffolding for configuration + preparation for setting passphrase (#192)

* Scaffolding for configuration + preparation for setting passphrase

* Setup config on dev & user installation

* dev installation/uninstallation fixes

* Feature/165 certificate setup (#194)

Https with certificate setup on install

* Feature/background update check (#196)

- cron daily for update checks
- Update + output terminal to show progress

* Fix syntax

Co-authored-by: Andreas Galazis <agalazis@users.noreply.github.com>
Co-authored-by: NANOUU <59022292+antoniasymeonidou@users.noreply.github.com>
  • Loading branch information
3 people authored May 3, 2021
1 parent a39f907 commit 9924614
Show file tree
Hide file tree
Showing 409 changed files with 18,656 additions and 21,412 deletions.
1 change: 1 addition & 0 deletions .executables
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/lib/piwebagent2/update_system
42 changes: 42 additions & 0 deletions .github/workflows/release_remaster.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
push:
tags:
- 0.7.*
name: Release
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 0
- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install -g @angular/cli
- name: Prepare debian packaging
run: make package-debian
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
workdir: target/piwebagent2/
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
40 changes: 40 additions & 0 deletions .github/workflows/sanity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
on:
push:
branches:
- '*/*' # matches every branch containing a single '/'
- remaster
- '!master' # excludes master

name: Build
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v1

- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install -g @angular/cli

- name: Generic (dev) build
run: make build

- name: Test service
run: make test-backend
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.htpasswd
*.pwa
*.pyc
.vscode
node_modules/
target/
*.zip
service/web/config
service/system/usr/lib/piwebagent2/update_check
112 changes: 112 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# to be run in target/piwebagent2/

builds:
- id: piwebagent
dir: ../../service/web
main: ./cmd/pi-web-agent.go
binary: piwebagent2
goos:
- linux

goarch:
- arm
- arm64
nfpms:
# note that this is an array of nfpm configs
-
# ID of the nfpm config, must be unique.
# Defaults to "default".
id: piwebagent

# Name of the package.
# Defaults to `ProjectName`.
package_name: piwebagent2

# You can change the file name of the package.
# Default: `{{ .PackageName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}`
file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

# Build IDs for the builds you want to create NFPM packages for.
# Defaults to all builds.
builds:
- piwebagent

# Your app's vendor.
# Default is empty.
vendor: vaslabs
# Your app's homepage.
# Default is empty.
homepage: https://github.com/vaslabs/pi-web-agent

# Your app's maintainer (probably you).
# Default is empty.
maintainer: Vasilis Nicolaou <vaslabsco@gmail.com>

# Your app's description.
# Default is empty.
description: A web based desktop replacement for our beloved Raspberry PI's

# Your app's license.
# Default is empty.
license: GNU GENERAL PUBLIC LICENSE Version 2

# Formats to be generated.
formats:
- deb

# Override default /usr/local/bin destination for binaries
bindir: /usr/bin

# Version Epoch.
# Default is extracted from `version` if it is semver compatible.
epoch: 2

# Version Prerelease.
# Default is extracted from `version` if it is semver compatible.
prerelease: beta1

# Version Metadata (previously deb.metadata).
# Default is extracted from `version` if it is semver compatible.
# Setting metadata might interfere with version comparisons depending on the packager.
version_metadata: git

# Version Release.
release: 1

# Section.
section: default

# Priority.
priority: extra

# Contents to add to the package.
# GoReleaser will automatically add the binaries.
contents:
- src: etc/sudoers.d/piwebagent2
dst: /etc/sudoers.d/piwebagent2

- src: lib/systemd/system/piwebagent2.service
dst: /lib/systemd/system/piwebagent2.service
file_info:
mode: 0644

- src: etc/piwebagent2/config/config.env
dst: /etc/piwebagent2/config/config.env
type: "config|noreplace"

- src: usr/share/piwebagent2/assets
dst: /usr/share/piwebagent2/assets

- src: usr/lib/piwebagent2/update_system
dst: /usr/lib/piwebagent2/update_system
file_info:
mode: 0550

# Scripts to execute during the installation of the package.
# Keys are the possible targets during the installation process
# Values are the paths to the scripts which will be executed
scripts:
preinstall: "scripts/preinstall.sh"
postinstall: "scripts/postinstall.sh"
preremove: "scripts/preremove.sh"
postremove: "scripts/postremove.sh"
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:
- repo: local
hooks:
- id: lint-fix-angular-app
name: Lint and fix linting issues in angular app
entry: bash -c 'npm --prefix ui/pi-web-agent-app run lint -- --fix'
language: system
pass_filenames: false
18 changes: 0 additions & 18 deletions JSONFetchKey.py

This file was deleted.

69 changes: 69 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

dev_pwa_root_path_prefix := /home/pi/pi-web-agent/service/system/
executables := $(shell cat .executables)
dev_executables := $(shell l="";for i in $$(cat .executables); do l="$$l $(dev_pwa_root_path_prefix)$$i"; done; echo $$l)
run-backend: build-rpi-backend
chmod +x service/web/pi-web-agent \
&& rsync -a --exclude 'node_modules' . rpi:/home/pi/pi-web-agent \
&& ssh rpi "/bin/bash -c '\
sudo service piwebagent2 stop; \
sudo killall -9 pi-web-agent; \
export PWA_ROOT_PATH_PREFIX=\"$(dev_pwa_root_path_prefix)\"; \
chmod +x $(dev_executables) ;\
/home/pi/pi-web-agent/service/system/etc/cron.daily/update_check; \
[ -z $$(cat $(dev_pwa_root_path_prefix)usr/lib/piwebagent2/update_check) ] \
&& cp /home/pi/pi-web-agent/service/web/test/test-resources/update_check $(dev_pwa_root_path_prefix)usr/lib/piwebagent2/update_check; \
/home/pi/pi-web-agent/service/web/pi-web-agent'; \
"

run-frontend:
npm --prefix ui/pi-web-agent-app start || cd -

build: build-dev-ui build-backend

test-backend:
cd service/web && go test ./test/ && cd -

build-dev-ui:
npm --prefix ui/pi-web-agent-app i &&npm --prefix ui/pi-web-agent-app run ng build -- --base-href /

build-backend:
cd service/web && go build -o pi-web-agent cmd/pi-web-agent.go && cd -

install-dev:
sudo apt-get update && sudo apt-get install git nodejs npm && curl -L https://git.io/vQhTU | bash -s -- --version 1.16

uninstall-go:
curl -L https://git.io/vQhTU | bash -s -- --remove

clean:
rm -r service/web/assets/pi-web-agent-app

check-hook:
[ -f .git/hooks/pre-commit ] && echo "Hook ready" || pre-commit install || echo "Please install pre-commit (https://pre-commit.com/)"

package-dev: build
./package.sh

install: package-dev
sudo ./install.sh

make uninstall:
sudo ./uninstall.sh



build-rpi-ui:
npm --prefix ui/pi-web-agent-app i \
&&npm --prefix ui/pi-web-agent-app run ng build -- --prod --base-href /

build-rpi-backend:
cd service/web && env GOOS=linux GOARCH=arm GOARM=5 go build -o pi-web-agent cmd/pi-web-agent.go && cd -

build-rpi: build-rpi-ui build-rpi-backend

package-rpi: build-rpi
./package.sh

package-debian: package-rpi
./debian.sh
Loading

0 comments on commit 9924614

Please sign in to comment.