-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
97f6434
commit 503b9e4
Showing
33 changed files
with
3,070 additions
and
4 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Submodule ocs2-prolinuxd
deleted from
98f381
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,107 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# Next.js build output | ||
.next | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and *not* Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
tmp/ | ||
plasma-mobile-nightly/ |
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,41 @@ | ||
pkgname=prolinuxd | ||
pkgver=1.0.0_git$GIT_VERNUM | ||
pkgrel=0 | ||
pkgdesc="Sineware Cloud Daemon for ProLinux Plasma Mobile Nightly" | ||
arch="all !ppc64le !s390x !armhf !riscv64" | ||
url="https://sineware.ca/" | ||
license="GPL-2.0" | ||
depends=" | ||
nodejs | ||
bash | ||
" | ||
makedepends=" | ||
nodejs | ||
npm | ||
bash | ||
git | ||
" | ||
source="https://github.com/Sineware/ocs2-prolinuxd/archive/refs/heads/main.zip" | ||
options="net !fhs" | ||
|
||
build() { | ||
npm ci | ||
npm run build | ||
} | ||
|
||
package() { | ||
mkdir -p "$pkgdir/opt/prolinuxd" | ||
mkdir -p "$pkgdir/etc/init.d" | ||
mkdir -p "$pkgdir/usr/share/applications" | ||
mkdir -p "$pkgdir/usr/sbin" | ||
cp -r dist/* "$pkgdir/opt/prolinuxd/" | ||
|
||
cp distro-files/prolinuxd "$pkgdir/opt/prolinuxd/" | ||
cp distro-files/prolinuxd.initd "$pkgdir/etc/init.d/prolinuxd" | ||
cp distro-files/prolinux.toml "$pkgdir/opt/prolinuxd/prolinux-default.toml" | ||
cp distro-files/session-wrapper.desktop "$pkgdir/opt/prolinuxd/" | ||
cp distro-files/app-icon.png "$pkgdir/opt/prolinuxd/" | ||
|
||
cp distro-files/prolinux-config.desktop "$pkgdir/usr/share/applications/" | ||
cp distro-files/plctl "$pkgdir/usr/sbin/" | ||
} |
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,11 @@ | ||
# Sineware Cloud Services Daemon (prolinuxd) | ||
|
||
ProLinuxD is a system daemon designed to expand Linux distributions with additional features and integrate then into Sineware Cloud services. | ||
|
||
ProLinux is a Sineware project developing operating system technologies. | ||
|
||
--- | ||
|
||
### Features | ||
|
||
TODO |
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,2 @@ | ||
# ProLinux Settings | ||
Simple UI for configuring ProLinuxD. |
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,94 @@ | ||
import { spawn } from 'child_process'; | ||
import { WebSocket } from 'ws'; | ||
|
||
function textBoxDialog(title: string, text: string): Promise<{data: string, exitCode: number | null}> { | ||
return new Promise((resolve, reject) => { | ||
const child = spawn('kdialog', ['--title', title, '--inputbox', text]); | ||
let data = ''; | ||
child.stdout.on('data', (chunk) => { | ||
data += chunk; | ||
}); | ||
child.on('close', (code) => { | ||
resolve({data, exitCode: code}); | ||
}); | ||
}); | ||
} | ||
function alertDialog(title: string, text: string): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
const child = spawn('kdialog', ['--title', title, '--msgbox', text]); | ||
child.on('close', () => { | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
function startProgressDialog(title: string, text: string): Promise<string> { | ||
return new Promise((resolve, reject) => { | ||
const child = spawn('kdialog', ['--title', title, '--progressbar', text, "100"]); | ||
// return qdbus object path | ||
child.stdout.on('data', (chunk) => { | ||
resolve(chunk.toString().trim()); | ||
}); | ||
}); | ||
} | ||
function updateProgressDialog(path: string, value: number): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
const child = spawn('qdbus', [...path.split(" "), 'Set', '', 'value', value.toString()]); | ||
child.on('close', () => { | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
function closeProgressDialog(path: string): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
const child = spawn('qdbus', [...path.split(" "), 'close']); | ||
child.on('close', () => { | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); | ||
async function main() { | ||
const path = await startProgressDialog('ProLinuxD', 'ProLinux Config Tool is working...'); | ||
await sleep(1000); | ||
|
||
process.on('uncaughtException', async function (err) { | ||
await closeProgressDialog(path); | ||
await alertDialog('ProLinuxD', 'Failed to connect to ProLinuxD: ' + err.message); | ||
console.error(err); | ||
process.exit(1); | ||
}); | ||
let ws = new WebSocket("ws+unix:///tmp/prolinuxd.sock");; | ||
|
||
//updateProgressDialog(path, 50); | ||
//await sleep(1000); | ||
|
||
ws.on('open', async () => { | ||
console.log('connected'); | ||
let token = await textBoxDialog('ProLinuxD Device Access Token', 'Enter the organization device access token:'); | ||
console.log(token) | ||
if(token.data.trim() === "") { | ||
await alertDialog('ProLinuxD', 'No token entered'); | ||
await sleep(1000); | ||
await closeProgressDialog(path); | ||
process.exit(1); | ||
} | ||
ws.send(JSON.stringify({ | ||
action: "set-token", | ||
payload: { | ||
token: token.data.trim() | ||
} | ||
})); | ||
console.log('sent token'); | ||
await alertDialog('ProLinuxD', 'Set token! Please restart your device.'); | ||
await sleep(1000); | ||
await closeProgressDialog(path); | ||
process.exit(1); | ||
}); | ||
|
||
ws.on("error", async (err) => { | ||
await closeProgressDialog(path); | ||
await alertDialog('ProLinuxD', 'Failed to connect to ProLinuxD'); | ||
process.exit(1); | ||
}); | ||
} | ||
main(); |
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 @@ | ||
# ProLinux CLI | ||
`plctl` (**P**ro**L**inux **C**on**t**ro**l**) is the command line frontend tool to interact with ProLinuxD, over the | ||
local websocket (/tmp/prolinuxd.sock). |
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,104 @@ | ||
import { Command } from "commander"; | ||
import { callWS, streamWS } from "../../plctl"; | ||
import { LocalActions, ProLinuxInfo, RemoteUpdate } from "../../../src/constants"; | ||
|
||
export async function registerPL2Commands(program: Command) { | ||
|
||
const update = program.command('update').description('prolinux update tools') | ||
update.command('status').description('get available updates and current system info').action(async () => { | ||
const status = (await callWS(LocalActions.STATUS, {}, true)); | ||
const prolinuxInfo = status.buildInfo as ProLinuxInfo; | ||
const updateInfo = (await callWS(LocalActions.GET_UPDATE_INFO, {}, true)); | ||
|
||
console.log("----------------------------------------"); | ||
console.log("- Product: " + prolinuxInfo.product + ", Variant " + prolinuxInfo.variant + ", Channel " + prolinuxInfo.channel); | ||
console.log("- Installed: Build " + prolinuxInfo.buildnum + ", " + prolinuxInfo.uuid); | ||
console.log("----------------------------------------"); | ||
console.log("- Available (remote): "); | ||
|
||
const update: RemoteUpdate = updateInfo.update; | ||
const updateAvailable = updateInfo.updateAvailable; | ||
|
||
if(updateAvailable) { | ||
console.log(" - Build " + update.buildnum + ", " + update.uuid); | ||
console.log(" - Update available!"); | ||
} else { | ||
console.log(" - No update available."); | ||
} | ||
|
||
if(status.disableKexec) { | ||
console.log("**WARNING** Kexec is disabled! You MUST update the boot partition manually or your device will not boot!"); | ||
} | ||
|
||
console.log("----------------------------------------"); | ||
}); | ||
update.command('install').description('install the latest update').action(async () => { | ||
try { | ||
console.log("----------------------------------------"); | ||
console.log("Dispatching update..."); | ||
const status = (await callWS(LocalActions.STATUS, {}, true)); | ||
await callWS(LocalActions.START_UPDATE, {}, true); | ||
await streamWS(LocalActions.UPDATE_PROGRESS, (data, ws) => { | ||
const progress = data.progress; | ||
const total = data.total; | ||
const newRoot = data.newRoot; | ||
const buildnum = data.buildnum; | ||
|
||
const percent = Math.round((progress / total) * 100); | ||
|
||
console.clear(); | ||
console.log("----------------------------------------"); | ||
console.log("Installing ProLinux Update, Build " + buildnum); | ||
console.log("Progress: " + percent + "% (" + progress + "/" + total + ") to root " + newRoot + "..."); | ||
|
||
if(percent == 100) { | ||
console.log("Done! Reboot your device to apply the update."); | ||
ws.close(); | ||
if(status.disableKexec) { | ||
console.log("**WARNING** Kexec is disabled! You MUST update the boot partition manually or your device will not boot!"); | ||
} | ||
} | ||
}); | ||
} catch(e) { | ||
console.log("Error: " + e); | ||
} | ||
}); | ||
|
||
// Root Lock | ||
program.command('root-lock') | ||
.argument('<state>', 'on/off') | ||
.description('Set the root lock on/off (immutable overlay)') | ||
.action(async (str, options) => { | ||
if(str == "on") { | ||
await callWS(LocalActions.SET_LOCKED_ROOT, { lockedRoot: true }, true); | ||
} else if(str == "off") { | ||
await callWS(LocalActions.SET_LOCKED_ROOT, { lockedRoot: false }, true); | ||
} else { | ||
console.log("Invalid state. Must be on or off."); | ||
return; | ||
} | ||
console.log("Done!"); | ||
console.log("Changes to the root will only be persisted after a reboot. Please reboot now!"); | ||
}); | ||
program.command('reset-writable') | ||
.description('Reset the writable overlay') | ||
.action(async (str, options) => { | ||
await callWS(LocalActions.SET_RESET_PERSISTROOT_FLAG, {}, true); | ||
console.log("Done!"); | ||
console.log("The persistroot/writable layer will be reset on the next boot. Please reboot now!"); | ||
}); | ||
program.command('disable-kexec') | ||
.description('Disables Kexec boot - use the firmware kernel from /boot.') | ||
.action(async (str, options) => { | ||
if(str == "on") { | ||
await callWS(LocalActions.SET_DISABLE_KEXEC, { disableKexec: true }, true); | ||
} else if(str == "off") { | ||
await callWS(LocalActions.SET_DISABLE_KEXEC, { disableKexec: false }, true); | ||
} else { | ||
console.log("Invalid state. Must be on or off."); | ||
return; | ||
} | ||
console.log("Done! Please reboot now."); | ||
}); | ||
} | ||
// sudo zsync http://espi.sineware.ca/repo/prolinux/mobile/dev/arm64/prolinux-root-mobile-dev.squish.zsync -o ~/prolinux_b.squish |
Oops, something went wrong.