argument validation and fixing of copy ssl at creation time feature

This commit is contained in:
Lloyd Hilaiel 2012-05-31 22:34:37 +03:00
Родитель ed97a4f5b7
Коммит e2764afcab
2 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -77,6 +77,14 @@ verbs['create'] = function(args) {
.describe('t', 'Instance type, dictates VM speed and cost. i.e. t1.micro or m1.large (see http://aws.amazon.com/ec2/instance-types/)')
.describe('p', 'public SSL key (installed automatically when provided)')
.describe('s', 'secret SSL key (installed automatically when provided)')
.check(function(argv) {
// p and s are all or nothing
if (argv.s ? !argv.p : argv.p) throw "-p and -s are both required";
if (argv.s) {
if (!path.existsSync(argv.s)) throw "file '" + argv.s + "' doesn't exist";
if (!path.existsSync(argv.p)) throw "file '" + argv.p + "' doesn't exist";
}
})
.default('t', 't1.micro')
var opts = parser.argv;

Просмотреть файл

@ -26,10 +26,10 @@ exports.copyUpConfig = function(host, config, cb) {
};
exports.copySSL = function(host, pub, priv, cb) {
var cmd = 'scp -o "StrictHostKeyChecking no" ' + pub + ' proxy@' + host + ":.";
var cmd = 'scp -o "StrictHostKeyChecking no" ' + pub + ' proxy@' + host + ":cert.pem";
child_process.exec(cmd, function(err, r) {
if (err) return cb(err);
var cmd = 'scp -o "StrictHostKeyChecking no" ' + priv + ' proxy@' + host + ":.";
var cmd = 'scp -o "StrictHostKeyChecking no" ' + priv + ' proxy@' + host + ":key.pem";
child_process.exec(cmd, function(err, r) {
var cmd = 'ssh -o "StrictHostKeyChecking no" proxy@' + host + " 'forever restartall'";
child_process.exec(cmd, cb);