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
1d416c1
commit c3ec70b
Showing
16 changed files
with
251 additions
and
93 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
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
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,59 @@ | ||
import { WebSocket } from 'ws'; | ||
import { Command } from 'commander'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
|
||
async function connectWS() { | ||
let ws = new WebSocket("ws+unix:///tmp/prolinuxd.sock"); | ||
return ws; | ||
} | ||
export function callWS(action: string, payload: any, promise: boolean = true): Promise<any> { | ||
return new Promise (async (resolve, reject) => { | ||
const ws = await connectWS(); | ||
let id = uuidv4(); | ||
let msg = { action, payload, id }; | ||
console.log("[Call] Sending message: " + JSON.stringify(msg)); | ||
if(promise) { | ||
const listener = (e: any) => { | ||
let msg = JSON.parse(e.data); | ||
if (msg.id === id) { | ||
if(msg.payload.status) { | ||
resolve(msg.payload.data); | ||
} else { | ||
reject(new Error(msg.payload.data.msg)); | ||
} | ||
ws.removeEventListener("message", listener); | ||
} | ||
} | ||
ws.addEventListener("message", listener); | ||
} | ||
ws.send(JSON.stringify(msg)); | ||
if(!promise) resolve({}); | ||
}); | ||
} | ||
|
||
const program = new Command(); | ||
|
||
program | ||
.name('pactl') | ||
.description('ProLinuxD CLI Utility') | ||
.version('0.0.1'); | ||
|
||
program.command('status') | ||
.description('get the status of ProLinuxD') | ||
.action((str, options) => { | ||
|
||
}); | ||
program.command('set-device-token') | ||
.description('set the Sineware Cloud device token') | ||
.argument('<token>', 'device token') | ||
.action((str, options) => { | ||
|
||
}); | ||
|
||
program.command('restart') | ||
.description('Restart ProLinuxD') | ||
.action((str, options) => { | ||
|
||
}); | ||
|
||
program.parse(); |
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,7 @@ | ||
[Desktop Entry] | ||
Type=Application | ||
Name=ProLinux Config Tool | ||
Exec=/usr/bin/node /opt/prolinuxd/prolinux-config/index.js | ||
Icon=/opt/prolinuxd/app-icon.png | ||
Terminal=false | ||
X-KDE-FormFactor=desktop;tablet;handset; |
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
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 |
---|---|---|
|
@@ -13,4 +13,5 @@ error_log="/var/log/prolinuxd.err" | |
|
||
depend() { | ||
want net | ||
before tinydm | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Oops, something went wrong.