Skip to content

Commit 9924614

Browse files
vaslabsagalazisantoniasymeonidou
authored
Remaster (#157)
* 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 <[email protected]> Co-authored-by: NANOUU <[email protected]>
1 parent a39f907 commit 9924614

File tree

409 files changed

+18656
-21412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

409 files changed

+18656
-21412
lines changed

.executables

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
usr/lib/piwebagent2/update_system
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on:
2+
push:
3+
tags:
4+
- 0.7.*
5+
name: Release
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
node-version: [12.x]
12+
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
13+
defaults:
14+
run:
15+
shell: bash
16+
steps:
17+
- uses: actions/checkout@v1
18+
with:
19+
fetch-depth: 0
20+
- name: Cache node modules
21+
uses: actions/cache@v1
22+
with:
23+
path: ~/.npm
24+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
25+
restore-keys: |
26+
${{ runner.os }}-node-
27+
- name: Node ${{ matrix.node-version }}
28+
uses: actions/setup-node@v1
29+
with:
30+
node-version: ${{ matrix.node-version }}
31+
- name: Install dependencies
32+
run: npm install -g @angular/cli
33+
- name: Prepare debian packaging
34+
run: make package-debian
35+
- name: Run GoReleaser
36+
uses: goreleaser/goreleaser-action@v2
37+
with:
38+
version: latest
39+
args: release --rm-dist
40+
workdir: target/piwebagent2/
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

.github/workflows/sanity.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
on:
2+
push:
3+
branches:
4+
- '*/*' # matches every branch containing a single '/'
5+
- remaster
6+
- '!master' # excludes master
7+
8+
name: Build
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: [12.x]
15+
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
16+
defaults:
17+
run:
18+
shell: bash
19+
steps:
20+
- uses: actions/checkout@v1
21+
22+
- name: Cache node modules
23+
uses: actions/cache@v1
24+
with:
25+
path: ~/.npm
26+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-node-
29+
- name: Node ${{ matrix.node-version }}
30+
uses: actions/setup-node@v1
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
- name: Install dependencies
34+
run: npm install -g @angular/cli
35+
36+
- name: Generic (dev) build
37+
run: make build
38+
39+
- name: Test service
40+
run: make test-backend

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
.htpasswd
22
*.pwa
33
*.pyc
4+
.vscode
5+
node_modules/
6+
target/
7+
*.zip
8+
service/web/config
9+
service/system/usr/lib/piwebagent2/update_check

.goreleaser.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# to be run in target/piwebagent2/
2+
3+
builds:
4+
- id: piwebagent
5+
dir: ../../service/web
6+
main: ./cmd/pi-web-agent.go
7+
binary: piwebagent2
8+
goos:
9+
- linux
10+
11+
goarch:
12+
- arm
13+
- arm64
14+
nfpms:
15+
# note that this is an array of nfpm configs
16+
-
17+
# ID of the nfpm config, must be unique.
18+
# Defaults to "default".
19+
id: piwebagent
20+
21+
# Name of the package.
22+
# Defaults to `ProjectName`.
23+
package_name: piwebagent2
24+
25+
# You can change the file name of the package.
26+
# Default: `{{ .PackageName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}`
27+
file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
28+
29+
# Build IDs for the builds you want to create NFPM packages for.
30+
# Defaults to all builds.
31+
builds:
32+
- piwebagent
33+
34+
# Your app's vendor.
35+
# Default is empty.
36+
vendor: vaslabs
37+
# Your app's homepage.
38+
# Default is empty.
39+
homepage: https://github.com/vaslabs/pi-web-agent
40+
41+
# Your app's maintainer (probably you).
42+
# Default is empty.
43+
maintainer: Vasilis Nicolaou <[email protected]>
44+
45+
# Your app's description.
46+
# Default is empty.
47+
description: A web based desktop replacement for our beloved Raspberry PI's
48+
49+
# Your app's license.
50+
# Default is empty.
51+
license: GNU GENERAL PUBLIC LICENSE Version 2
52+
53+
# Formats to be generated.
54+
formats:
55+
- deb
56+
57+
# Override default /usr/local/bin destination for binaries
58+
bindir: /usr/bin
59+
60+
# Version Epoch.
61+
# Default is extracted from `version` if it is semver compatible.
62+
epoch: 2
63+
64+
# Version Prerelease.
65+
# Default is extracted from `version` if it is semver compatible.
66+
prerelease: beta1
67+
68+
# Version Metadata (previously deb.metadata).
69+
# Default is extracted from `version` if it is semver compatible.
70+
# Setting metadata might interfere with version comparisons depending on the packager.
71+
version_metadata: git
72+
73+
# Version Release.
74+
release: 1
75+
76+
# Section.
77+
section: default
78+
79+
# Priority.
80+
priority: extra
81+
82+
# Contents to add to the package.
83+
# GoReleaser will automatically add the binaries.
84+
contents:
85+
- src: etc/sudoers.d/piwebagent2
86+
dst: /etc/sudoers.d/piwebagent2
87+
88+
- src: lib/systemd/system/piwebagent2.service
89+
dst: /lib/systemd/system/piwebagent2.service
90+
file_info:
91+
mode: 0644
92+
93+
- src: etc/piwebagent2/config/config.env
94+
dst: /etc/piwebagent2/config/config.env
95+
type: "config|noreplace"
96+
97+
- src: usr/share/piwebagent2/assets
98+
dst: /usr/share/piwebagent2/assets
99+
100+
- src: usr/lib/piwebagent2/update_system
101+
dst: /usr/lib/piwebagent2/update_system
102+
file_info:
103+
mode: 0550
104+
105+
# Scripts to execute during the installation of the package.
106+
# Keys are the possible targets during the installation process
107+
# Values are the paths to the scripts which will be executed
108+
scripts:
109+
preinstall: "scripts/preinstall.sh"
110+
postinstall: "scripts/postinstall.sh"
111+
preremove: "scripts/preremove.sh"
112+
postremove: "scripts/postremove.sh"

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: lint-fix-angular-app
5+
name: Lint and fix linting issues in angular app
6+
entry: bash -c 'npm --prefix ui/pi-web-agent-app run lint -- --fix'
7+
language: system
8+
pass_filenames: false

JSONFetchKey.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

Makefile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
dev_pwa_root_path_prefix := /home/pi/pi-web-agent/service/system/
3+
executables := $(shell cat .executables)
4+
dev_executables := $(shell l="";for i in $$(cat .executables); do l="$$l $(dev_pwa_root_path_prefix)$$i"; done; echo $$l)
5+
run-backend: build-rpi-backend
6+
chmod +x service/web/pi-web-agent \
7+
&& rsync -a --exclude 'node_modules' . rpi:/home/pi/pi-web-agent \
8+
&& ssh rpi "/bin/bash -c '\
9+
sudo service piwebagent2 stop; \
10+
sudo killall -9 pi-web-agent; \
11+
export PWA_ROOT_PATH_PREFIX=\"$(dev_pwa_root_path_prefix)\"; \
12+
chmod +x $(dev_executables) ;\
13+
/home/pi/pi-web-agent/service/system/etc/cron.daily/update_check; \
14+
[ -z $$(cat $(dev_pwa_root_path_prefix)usr/lib/piwebagent2/update_check) ] \
15+
&& cp /home/pi/pi-web-agent/service/web/test/test-resources/update_check $(dev_pwa_root_path_prefix)usr/lib/piwebagent2/update_check; \
16+
/home/pi/pi-web-agent/service/web/pi-web-agent'; \
17+
"
18+
19+
run-frontend:
20+
npm --prefix ui/pi-web-agent-app start || cd -
21+
22+
build: build-dev-ui build-backend
23+
24+
test-backend:
25+
cd service/web && go test ./test/ && cd -
26+
27+
build-dev-ui:
28+
npm --prefix ui/pi-web-agent-app i &&npm --prefix ui/pi-web-agent-app run ng build -- --base-href /
29+
30+
build-backend:
31+
cd service/web && go build -o pi-web-agent cmd/pi-web-agent.go && cd -
32+
33+
install-dev:
34+
sudo apt-get update && sudo apt-get install git nodejs npm && curl -L https://git.io/vQhTU | bash -s -- --version 1.16
35+
36+
uninstall-go:
37+
curl -L https://git.io/vQhTU | bash -s -- --remove
38+
39+
clean:
40+
rm -r service/web/assets/pi-web-agent-app
41+
42+
check-hook:
43+
[ -f .git/hooks/pre-commit ] && echo "Hook ready" || pre-commit install || echo "Please install pre-commit (https://pre-commit.com/)"
44+
45+
package-dev: build
46+
./package.sh
47+
48+
install: package-dev
49+
sudo ./install.sh
50+
51+
make uninstall:
52+
sudo ./uninstall.sh
53+
54+
55+
56+
build-rpi-ui:
57+
npm --prefix ui/pi-web-agent-app i \
58+
&&npm --prefix ui/pi-web-agent-app run ng build -- --prod --base-href /
59+
60+
build-rpi-backend:
61+
cd service/web && env GOOS=linux GOARCH=arm GOARM=5 go build -o pi-web-agent cmd/pi-web-agent.go && cd -
62+
63+
build-rpi: build-rpi-ui build-rpi-backend
64+
65+
package-rpi: build-rpi
66+
./package.sh
67+
68+
package-debian: package-rpi
69+
./debian.sh

0 commit comments

Comments
 (0)