Esempio n. 1
0
AndroidProject.prototype._getPropertiesFile = function (filename) {
    if (!this._propertiesEditors[filename]) {
        if (fs.existsSync(filename)) {
            this._propertiesEditors[filename] = properties_parser.createEditor(filename);
        } else {
            this._propertiesEditors[filename] = properties_parser.createEditor();
        }
    }

    return this._propertiesEditors[filename];
};
Esempio n. 2
0
    _getPropertiesFile: function (filename) {
        if (!this._propertiesEditors[filename]) {
            if (fs.existsSync(filename)) {
                this._propertiesEditors[filename] = properties_parser.createEditor(filename);
            } else {
                this._propertiesEditors[filename] = properties_parser.createEditor();
            }
        }

        return this._propertiesEditors[filename];
    }
Esempio n. 3
0
exports.updateAppKey = function(req, res) {
    var projectId = req.param("projectId");
    var outputDir = Utils.getProjectDir(projectId);
    var alias = req.param("alias");
    var password = req.param("password");
    try {
        if (req.files && req.files.file) {
            // dont use rename here, because rename breaks when files are on different filesystems
            fse.copySync(req.files.file.path, path.join(outputDir, "application.keystore"));
            fse.removeSync(req.files.file.path);
        }
        // update properties file
        var propertiesFile = path.join(outputDir, "storyquest.properties");
        var properties = {};
        if (fs.existsSync(propertiesFile))
            properties = propertiesParser.parse(fs.readFileSync(propertiesFile, "utf8"));
        properties.KEYSTORE = config.projectsDirFromAndroidContext + "/" + projectId + "/" + "application.keystore";
        properties.STORE_PASSWORD = password;
        properties.KEY_PASSWORD = password;
        properties.KEY_ALIAS = alias;
        var propEditor = propertiesParser.createEditor();
        for (var property in properties)
            if (Object.hasOwnProperty.call(properties, property))
                propEditor.set(property, properties[property]);
        propEditor.save(propertiesFile, function() {
            return res.json(200, {});
        });
    } catch(err) {
        return res.json(500, {type: "REQUEST_FAILED", "message": err});
    }
};
Esempio n. 4
0
function execute(options) {
  sh.config.fatal = true;

  // add user
  sh.echo('Adding user `' + options.username + '`');
  sh.exec('useradd -s /bin/bash -m ' + options.username);
  sh.exec('chown -R ' + options.username + ':' + options.username + ' /home/' + options.username);
  // add user to sudo group (append)
  sh.exec('usermod -a -G sudo ' + options.username);

  sh.echo('Applying password');
  // add user password
  nexpect.spawn("passwd", options.username)
    .expect("Enter new UNIX password:"******"Retype new UNIX password:"******"/etc/sudoers", {separator: ' '});
  editor.set(options.username, 'ALL=(ALL) NOPASSWD:ALL');
  editor.save();

  //sh.echo('Applying public key authentication and block root login');
  //if (!fs.existsSync(pathSSH(options.username))) {
  //    sh.exec('mkdir ' + pathSSH(options.username));
  //}
  //sh.exec('touch ' + pathAuthorizedKeys(options.username));
  //sh.echo(options.publicKey).toEnd(pathAuthorizedKeys(options.username));
  //
  // backup original config file
  //sh.cp('-f', '/etc/ssh/sshd_config', '/etc/ssh/sshd_config.bak');
  //
  //editor = prop.createEditor("/etc/ssh/sshd_config", { separator: ' ' });
  //editor.set('Port', options.port);
  //editor.set('RSAAuthentication', 'yes');
  //editor.set('PubkeyAuthentication', 'yes');
  //editor.set('PermitRootLogin', 'no');
  //editor.set('PasswordAuthentication', 'yes');
  //editor.save();

  // restart ssh
  sh.exec('service ssh restart');

  sh.echo('Done Successful');
  sh.exit(0);
}
Esempio n. 5
0
exports.storeSettings = function(req, res) {
    if (!req.param("projectId"))
        return res.json(500, {type: "REQUEST_FAILED", "message":"No projectId given."});
    else {
        // write settings file
        var settingsFile = path.join(Utils.getProjectDir(req.param("projectId")), "storyquest.json");
        var settings = {
            id: req.body.id,
            name: req.body.name,
            author: req.body.author,
            publisher: req.body.publisher,
            sequence: req.body.sequence,
            theme: req.body.theme
        };
        fs.writeFile(settingsFile, JSON.stringify(settings), function(err) {
            if (err)
                return res.json(500, {type: "REQUEST_FAILED", "message":err});
            else
                return res.json(200, {});
        });
        // write properties file
        var propertiesFile = path.join(Utils.getProjectDir(req.param("projectId")), "storyquest.properties");
        // for security reasons, only store certain fields, take others (eg paths) from system config
        var properties = {
            STORYQUEST_TEMPLATE_PATH: config.templateDirFromAndroidContext,
            STORYQUEST_PROJECT_PATH: config.projectsDirFromAndroidContext + "/" + req.param("projectId") + "/",
            STORYQUEST_ICON_PATH: config.projectsDirFromAndroidContext + "/" + req.param("projectId") + "/icon.png"
        };
        if (fs.existsSync(propertiesFile))
            properties = Utils.mergeObjects(properties, propertiesParser.parse(fs.readFileSync(propertiesFile, "utf8")));
        properties.APP_LABEL = req.body.APP_LABEL;
        properties.GOOGLE_SERVICES_ID = req.body.GOOGLE_SERVICES_ID;
        properties.APP_ID = req.body.APP_ID;
        properties.APP_VERSION_CODE = "" + req.body.APP_VERSION_CODE;
        properties.APP_VERSION_NAME = req.body.APP_VERSION_NAME;
        var propEditor = propertiesParser.createEditor();
        for (var property in properties) {
            if (properties.hasOwnProperty(property)) {
                propEditor.set(property, properties[property]);
            }
        }
        try {
            propEditor.save(propertiesFile, function() {
                return res.json(200, {});
            })
        } catch (err) {
            return res.json(500, {type: "REQUEST_FAILED", "message":err});
        }
    }
};
Esempio n. 6
0
 child.stdout.on("close", function(exitCode, signal) {
     // update properties file
     var propertiesFile = path.join(outputDir, "storyquest.properties");
     var properties = {};
     if (fs.existsSync(propertiesFile))
         properties = propertiesParser.parse(fs.readFileSync(propertiesFile, "utf8"));
     properties.KEYSTORE = config.projectsDirFromAndroidContext + "/" + projectId + "/" + "application.keystore";
     properties.STORE_PASSWORD = password;
     properties.KEY_PASSWORD = password;
     properties.KEY_ALIAS = alias;
     var propEditor = propertiesParser.createEditor();
     for (var property in properties)
         if (Object.hasOwnProperty.call(properties, property))
             propEditor.set(property, properties[property]);
     propEditor.save(propertiesFile, function() {
         return res.json(200, {});
     });
 });
Esempio n. 7
0
exports.writeProp = function(propPath,options){
    // console.log("exist:"+fs.existsSync(propPath));
    // console.log("exist:"+propPath);
    if (fs.existsSync(propPath) && !fs.statSync(propPath).isDirectory()) {
        var _date = new Date();
        var comment = _date.getFullYear() + "/" + (_date.getMonth()+1) +"/"+ (_date.getDate()) +" generate by zipH5 program";
        
        var propParser = PropParser.createEditor(propPath);
        // propParser.addHeadComment(comment);
        propParser.set("MD5",options.md5);
        propParser.get("MAIN") || propParser.set("MAIN","main.html");
        propParser.set("VERSION",options.version);
        propParser.save();
        
    } else {
        throw new Error("MANIFEST.properties may have error, please check");
    }
}
  module.readProperties = function (file, onErr) {
    try {
      var p = propParser.createEditor('./' + file);

      // Validate Propertys file
      if ( p.get(pDEBUG) === undefined) {
        onErr("Property " + pDEBUG + " not defined");
      } else {
        DEBUG = (p.get(pDEBUG) === "true");
      }
      if ( p.get(pWSPORT) === undefined) {
        onErr("Property " + pWSPORT + " not defined");
      } else {
        config.ws.port = p.get(pWSPORT);
      }
      if ( p.get(pWSSSL) === undefined) {
        onErr("Property " + pWSSSL + " not defined");
      } else {
        config.ws.ssl = p.get(pWSSSL);
      }
      if ( p.get(pRESTPORT) === undefined) {
        onErr("Property " + pRESTPORT + " not defined");
      } else {
        config.rest.port = p.get(pRESTPORT);
      }
      if ( p.get(pRESTSSL) === undefined) {
        onErr("Property " + pRESTSSL + " not defined");
      } else {
        config.rest.ssl = (p.get(pRESTSSL) === "true");
      }
      if ( p.get(pSBHOST) === undefined) {
        onErr("Property " + pSBHOST + " not defined");
      } else {
        config.sb.host = p.get(pSBHOST);
      }
      if ( p.get(pSBPORT) === undefined) {
        onErr("Property " + pSBPORT + " not defined");
      } else {
        config.sb.port = p.get(pSBPORT);
      }
    } catch (err) {
      onErr(err.stack);
    }
  };
function setProperties(name, port, properties)
{
  properties = new HashMap(properties);

  var PropertiesParser = require('properties-parser');
  var propertiesFilePath = 'servers/'+name+'/server.properties';
  var fileProperties = PropertiesParser.createEditor(propertiesFilePath);

  for(i=0; i < properties.count();i++)
  {
    key = properties.keys()[i];
    console.log("Set Property "+key+" to: "+properties.get(key));
    fileProperties.set(key,properties.get(key));
  }
  console.log("Set the Port to:"+port);
  fileProperties.set("server-port",port);

  //Save
  fileProperties.save();
  console.log("Saved the properties.");

  unblock(name);
}
Esempio n. 10
0
 getProjectSdkDir: function (project_dir) {
     var localProperties = properties_parser.createEditor(path.resolve(project_dir, 'local.properties'));
     return localProperties.get('sdk.dir');
 },
Esempio n. 11
0
    _getPropertiesFile: function (filename) {
        if (!this._propertiesEditors[filename])
            this._propertiesEditors[filename] = properties_parser.createEditor(filename);

        return this._propertiesEditors[filename];
    }