account_activate.coffee | |
---|---|
Import necessary Node.js libraries. | path = require "path"
fs = require "fs"
spawn = require("child_process").spawn |
Import necessary Puppy libraries. | Configuration = require("./puppy").Configuration |
Command ImplementationThe
| |
The JavaScript dispatch program slices | module.exports.command = (args) -> |
Load the user configuration, set defaults. | configuration = new Configuration()
server = configuration.get("server") or "portoroz.prettyrobots.com"
delete configuration.local["home"]
delete configuration.global["home"] |
Request the host server for the account. Then invoke the account registration command on the host server via SSH using the user's default identity. That is, the identities provided by the SSH configuration or the SSH agent, and not a specific identity. | configuration.home (home, user) ->
console.log [ home, user ]
process.exit 1
[ code ] = args
stdout = ""
ssh = spawn "ssh", [ "-T", home, "/usr/bin/sudo", "-u", user, "/puppy/bin/account_activate" ]
ssh.stdin.end(code)
ssh.stdout.on "data", (chunk) -> process.stdout.write chunk.toString()
ssh.stderr.on "data", (chunk) -> process.stdout.write chunk.toString()
ssh.on "exit", (code) ->
if code is 0
process.stdout.write "Activation successful. Welcome to Puppy.\n"
else
process.stdout.write "Unable to activate.\n"
|