@@ -0,0 +1,12 @@
|
||||
/** Shared helpers for drive-resident /bin scripts (prepended before each command). */
|
||||
function bareStdin(ctx) {
|
||||
return typeof ctx.shellStdin === 'string' ? ctx.shellStdin : ''
|
||||
}
|
||||
|
||||
async function run(ctx, argv) {
|
||||
if (typeof ctx.runHdms === 'function') {
|
||||
await ctx.runHdms(argv)
|
||||
return
|
||||
}
|
||||
ctx.console.error('hdms: unavailable')
|
||||
}
|
||||
+4
-1
@@ -5,6 +5,9 @@ function bareStdin(ctx) {
|
||||
|
||||
async function run(ctx, argv) {
|
||||
ctx.console.log(
|
||||
'Bare OS — builtins: cd, export, exit | /bin: basename cat clear date dirname echo env exit false head help hostname id ls nl pathchk printenv pwd rm seq sleep sort tail test touch true tty uname wc which whoami'
|
||||
'Bare OS — default user: guest | builtins: cd, export, exit, login, logout | /bin: basename cat clear date dirname echo env exit false head hdms help hostname id login logout ls nl pathchk printenv pwd rm savevault seq sleep sort tail test touch true tty uname wc which whoami'
|
||||
)
|
||||
ctx.console.log(
|
||||
'Identity: login [--new] <passphrase> | logout [--save] | savevault (encrypt copy of personal drive under /.bare/vault/)'
|
||||
)
|
||||
}
|
||||
|
||||
+5
-4
@@ -4,10 +4,11 @@ function bareStdin(ctx) {
|
||||
}
|
||||
|
||||
async function run(ctx, argv) {
|
||||
const u = ctx.vfs.env.USER || 'user'
|
||||
const uid = ctx.vfs.env.UID || '1000'
|
||||
const gid = ctx.vfs.env.GID || '1000'
|
||||
const g = ctx.vfs.env.GROUP || u
|
||||
const e = ctx.vfs.env
|
||||
const u = e.USER || e.LOGNAME || 'guest'
|
||||
const uid = e.UID || (e.BARE_OS_IDENTITY === 'guest' ? '65534' : '1000')
|
||||
const gid = e.GID || (e.BARE_OS_IDENTITY === 'guest' ? '65534' : '1000')
|
||||
const g = e.GROUP || u
|
||||
const rest = argv.slice(1)
|
||||
const wantG = rest.includes('-g') || rest.includes('--group')
|
||||
const wantU = rest.includes('-u') || rest.includes('--user')
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/** Shared helpers for drive-resident /bin scripts (prepended before each command). */
|
||||
function bareStdin(ctx) {
|
||||
return typeof ctx.shellStdin === 'string' ? ctx.shellStdin : ''
|
||||
}
|
||||
|
||||
async function run(ctx, argv) {
|
||||
const rest = argv.slice(1)
|
||||
let createNew = false
|
||||
if (rest[0] === '--new') {
|
||||
createNew = true
|
||||
rest.shift()
|
||||
}
|
||||
const passphrase = rest.join(' ')
|
||||
if (!passphrase) {
|
||||
ctx.console.error('usage: login [--new] <passphrase>')
|
||||
return
|
||||
}
|
||||
const reg = ctx.applyRegister
|
||||
const unlock = ctx.applyUnlock
|
||||
if (typeof reg !== 'function' || typeof unlock !== 'function') {
|
||||
ctx.console.error('login: not supported in this environment')
|
||||
return
|
||||
}
|
||||
try {
|
||||
if (createNew) await reg.call(ctx, passphrase)
|
||||
else await unlock.call(ctx, passphrase)
|
||||
} catch (err) {
|
||||
ctx.console.error(err?.message ?? String(err))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/** Shared helpers for drive-resident /bin scripts (prepended before each command). */
|
||||
function bareStdin(ctx) {
|
||||
return typeof ctx.shellStdin === 'string' ? ctx.shellStdin : ''
|
||||
}
|
||||
|
||||
async function run(ctx, argv) {
|
||||
const save = argv.includes('--save')
|
||||
const logout = ctx.applyLogout
|
||||
if (typeof logout !== 'function') {
|
||||
ctx.console.error('logout: not supported in this environment')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await logout.call(ctx, { save })
|
||||
} catch (err) {
|
||||
ctx.console.error(err?.message ?? String(err))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/** Shared helpers for drive-resident /bin scripts (prepended before each command). */
|
||||
function bareStdin(ctx) {
|
||||
return typeof ctx.shellStdin === 'string' ? ctx.shellStdin : ''
|
||||
}
|
||||
|
||||
async function run(ctx, argv) {
|
||||
const save = ctx.saveVault
|
||||
if (typeof save !== 'function') {
|
||||
ctx.console.error('savevault: not supported in this environment')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await save.call(ctx)
|
||||
} catch (err) {
|
||||
ctx.console.error(err?.message ?? String(err))
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,5 +4,5 @@ function bareStdin(ctx) {
|
||||
}
|
||||
|
||||
async function run(ctx, argv) {
|
||||
ctx.console.log(ctx.vfs.env.USER || ctx.vfs.env.LOGNAME || 'user')
|
||||
ctx.console.log(ctx.vfs.env.USER || ctx.vfs.env.LOGNAME || 'guest')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user