Replies: 2 comments 1 reply
-
Good question. I'm converting this to a discussion by the way. Not sure what language you want to use, but the easiest is JS because there's an official PocketBase SDK. Here's a minmal example using Bun and TypeScript: import PocketBase from 'pocketbase'
const pb = new PocketBase('http://localhost:8090')
// authenticate
const userData = await pb
.collection('users')
.authWithPassword(process.env.EMAIL as string, process.env.PASSWORD as string)
// get key from api endpoint
const key = await pb.send('/api/beszel/getkey', {}).then(({ key }) => key)
// theoretical script that would start the agent in background
await Bun.$`KEY="${key}" ./run-agent.sh`
// create system
await pb.collection('systems').create({
name: 'api-test',
host: 'localhost',
port: 45876,
users: userData.record.id,
}) As for the script to start the agent in the background, @MFYDev had the idea to make a one liner that would download the agent, then start and enable it as a systemd service automatically. So either he or I will make that in the future. I suggested building the service creation directly into the command, but I think his idea is better because you wouldn't need to manually download the binary first. edit: @yonas I just pushed an update that will fill system info and status with default values, so as of the next release you won't need to pass those in. |
Beta Was this translation helpful? Give feedback.
-
Thanks @henrygd ! |
Beta Was this translation helpful? Give feedback.
-
How do I do this?
I imagine it would be something like this:
beszel serve
beszel ssh pubkey
to get the server's SSH public keyPORT=xxxxx KEY="yyyyy" beszel-agent
Beta Was this translation helpful? Give feedback.
All reactions