Ejemplo n.º 1
0
module.exports = function() {
  let banner;
  let entry;

  return {
    options(options) {
      entry = path.resolve(options.entry);
      return options;
    },

    load(id) {
      if (id !== entry) {
        return;
      }
      const source = fs.readFileSync(id, "utf-8");
      const match = source.match(/^\s*(#!.*)/);
      if (match) {
        banner = match[1];
        return (
          source.slice(0, match.index) +
          source.slice(match.index + banner.length)
        );
      }
    },

    transformBundle(code) {
      if (banner) {
        return { code: banner + "\n" + code };
      }
    },

    onwrite(bundle) {
      if (banner) {
        fs.chmodSync(bundle.dest, 0o755 & ~process.umask());
      }
    }
  };
};
Ejemplo n.º 2
0
        engines.map(function(engine){
            // CB-5192; on Windows scriptSrc doesn't have file extension so we shouldn't check whether the script exists

            var scriptPath = engine.scriptSrc ? '"' + engine.scriptSrc + '"' : null;

            if(scriptPath && (isWindows || fs.existsSync(engine.scriptSrc)) ) {

                var d = Q.defer();
                if(!isWindows) { // not required on Windows
                    fs.chmodSync(engine.scriptSrc, '755');
                }
                child_process.exec(scriptPath, function(error, stdout, stderr) {
                    if (error) {
                        events.emit('warn', engine.name +' version check failed ('+ scriptPath +'), continuing anyways.');
                        engine.currentVersion = null;
                    } else {
                        engine.currentVersion = cleanVersionOutput(stdout, engine.name);
                        if (engine.currentVersion === '') {
                            events.emit('warn', engine.name +' version check returned nothing ('+ scriptPath +'), continuing anyways.');
                            engine.currentVersion = null;
                        }
                    }

                    d.resolve(engine);
                });
                return d.promise;

            } else {

                if(engine.currentVersion) {
                    engine.currentVersion = cleanVersionOutput(engine.currentVersion, engine.name);
                } else {
                    events.emit('warn', engine.name +' version not detected (lacks script '+ scriptPath +' ), continuing.');
                }

                return Q(engine);
            }
        })
Ejemplo n.º 3
0
function finishIt(err, stdout, stderr) {
  if (err) {
    console.log('Error extracting archive', err)
    process.exit(1)
  } else {
    // Look for the extracted directory, so we can rename it.
    var files = fs.readdirSync(tmpPath)
    var wasRenamed = false
    for (var i = 0; i < files.length; i++) {
      var file = path.join(tmpPath, files[i])
      if (fs.statSync(file).isDirectory()) {
        console.log('Renaming extracted folder', files[i], ' -> phantom')
        fs.renameSync(file, libPath)
        wasRenamed = true
        break
      }
    }

    // For issolating extraction problems, https://github.com/Obvious/phantomjs/issues/15
    if (!wasRenamed) {
      console.log('Temporary files not renamed, maybe zip extraction failed.')
      process.exit(1)
      return
    }

    // Check that the binary is user-executable and fix it if it isn't (problems with unzip library)
    if (process.platform != 'win32') {
      var stat = fs.statSync(helper.path)
      // 64 == 0100 (no octal literal in strict mode)
      if (!(stat.mode & 64)) {
        console.log('Fixing file permissions')
        fs.chmodSync(helper.path, '755')
      }
    }

    console.log('Done. Phantomjs binary available at', helper.path)
  }
}
Ejemplo n.º 4
0
test('npm whoami with bearer auth', { timeout: 2 * 1000 }, function (t) {
  var s = '//localhost:' + common.port +
          '/:_authToken = wombat-developers-union\n'
  fs.writeFileSync(FIXTURE_PATH, s, 'ascii')
  fs.chmodSync(FIXTURE_PATH, '0444')

  function verify (req, res) {
    t.equal(req.method, 'GET')
    t.equal(req.url, '/-/whoami')

    res.setHeader('content-type', 'application/json')
    res.writeHead(200)
    res.end(JSON.stringify({ username: '******' }), 'utf8')
  }

  var server = createServer(verify)

  server.listen(common.port, function () {
    common.npm(
      [
        'whoami',
        '--userconfig=' + FIXTURE_PATH,
        '--registry=http://localhost:' + common.port + '/'
      ],
      opts,
      function (err, code, stdout, stderr) {
        t.ifError(err)

        t.equal(stderr, '', 'got nothing on stderr')
        t.equal(code, 0, 'exit ok')
        t.equal(stdout, 'wombat\n', 'got username')
        rimraf.sync(FIXTURE_PATH)
        server.close()
        t.end()
      }
    )
  })
})
Ejemplo n.º 5
0
test("npm whoami with bearer auth", {timeout : 2 * 1000}, function (t) {
  var s = "//localhost:" + common.port +
          "/:_authToken = wombat-developers-union\n"
  fs.writeFileSync(FIXTURE_PATH, s, "ascii")
  fs.chmodSync(FIXTURE_PATH, "0444")

  function verify(req, res) {
    t.equal(req.method, "GET")
    t.equal(req.url, "/-/whoami")

    res.setHeader("content-type", "application/json")
    res.writeHeader(200)
    res.end(JSON.stringify({username : "******"}), "utf8")
  }

  var server = createServer(verify)

  server.listen(common.port, function () {
    common.npm(
      [
        "whoami",
        "--userconfig=" + FIXTURE_PATH,
        "--registry=http://localhost:" + common.port + "/"
      ],
      opts,
      function (err, code, stdout, stderr) {
        t.ifError(err)

        t.equal(stderr, "", "got nothing on stderr")
        t.equal(code, 0, "exit ok")
        t.equal(stdout, "wombat\n", "got username")
        rimraf.sync(FIXTURE_PATH)
        server.close()
        t.end()
      }
    )
  })
})
Ejemplo n.º 6
0
function start_server() {
	var is_unix_socket = (typeof config.LISTEN_PORT == 'string');
	if (is_unix_socket) {
		try { fs.unlinkSync(config.LISTEN_PORT); } catch (e) {}
	}
	// Start web server
	require('./web');
	// Start thread deletion module
	if (config.PRUNE)
		require('./prune');
	if (is_unix_socket)
		fs.chmodSync(config.LISTEN_PORT, '777'); // TEMP

	process.on('SIGHUP', hot_reloader);
	db.on_pub('reloadHot', hot_reloader);

	process.nextTick(pid_setup);

	winston.info('Listening on '
			+ (config.LISTEN_HOST || '')
			+ (is_unix_socket ? '' : ':')
			+ (config.LISTEN_PORT + '.'));
}
Ejemplo n.º 7
0
 engines.map(function(engine){
     if(fs.existsSync(engine.scriptSrc)){
         fs.chmodSync(engine.scriptSrc, '755');
         var d = Q.defer();
         child_process.exec(engine.scriptSrc, function(error, stdout, stderr) {
             if (error) {
                 require('../plugman').emit('log', 'Cordova project '+ engine.scriptSrc +' script failed (has a '+ engine.scriptSrc +' script, but something went wrong executing it), continuing anyways.');
                 engine.currentVersion = null;
                 d.resolve(engine); // Yes, resolve. We're trying to continue despite the error.
             } else {
                 var version = cleanVersionOutput(stdout, engine.name);
                 engine.currentVersion = version;
                 d.resolve(engine);
             }
         });
         return d.promise;
     }else if(engine.currentVersion){
         return cleanVersionOutput(engine.currentVersion, engine.name)
     }else{
         require('../plugman').emit('verbose', 'Cordova project '+ engine.scriptSrc +' not detected (lacks a '+ engine.scriptSrc +' script), continuing.');
         return null;
     }
 })
Ejemplo n.º 8
0
function deploy_config(source_path, destination_path, context) {
	var files = findit.sync(source_path, {'relative': true})

	for(var i = 0; i < files.length; i++) {
		var file     = files[i]
		var file_src = source_path      + '/' + file
		var file_dst = destination_path + '/' + file
		var stat = fs.statSync(file_src)

		if(stat.isDirectory()) {
			mkdirp.sync(file_dst, stat.mode)
			continue
		}
		if(!stat.isFile()) {
			continue
		}

		var template = fs.readFileSync(file_src, {encoding: "utf-8"})
		var result = apply_context(template, context)
		fs.writeFileSync(file_dst, result)
		fs.chmodSync(file_dst, stat.mode)
	}
}
Ejemplo n.º 9
0
  function addHookScript(cliHookPath, hookDirectoryName, hookFilename) {
    // add the root hooks directory if the project doesn't have it
    try {
      var projectHookPath = path.join('hooks');
      if( !fs.existsSync(projectHookPath) ) {
        fs.mkdirSync(projectHookPath);
      }

      // add the hook directory (ie: after_prepare) if the project doesn't have it
      projectHookPath = path.join(projectHookPath, hookDirectoryName);
      if( !fs.existsSync(projectHookPath) ) {
        fs.mkdirSync(projectHookPath);
      }

      var projectScript = path.join(projectHookPath, hookFilename);
      if( !fs.existsSync(projectHookPath) ) {
        // copy the hook script to the project
        try {
          var cliScript = path.join(cliHookPath, hookFilename);
          fs.writeFileSync(projectScript, fs.readFileSync(cliScript));
        } catch(e) {
          console.log( ('addCliHookDirectory fs.createReadStream: ' + e).error );
          return;
        }
      }

      // make the script file executable
      try {
        fs.chmodSync(projectScript, '755');
      } catch(e) {
        console.log( ('addCliHookDirectory fs.chmodSync: ' + e).error );
      }

    } catch(e) {
      console.log('Error adding hook script ' + hookDirectoryName + '/' + hookFilename + ', ' + e);
    }
  }
Ejemplo n.º 10
0
FS.prototype.delete = function (path, recursive) {
    recursive = recursive || false;

    var internalPath = this.toInternalPath(path);
    var _f = require('fs');

    if (this.exists(path)) {
        _f.chmodSync(internalPath, 0x1ff);
        if (this.isDir(path)) {
            if (recursive === true) {
                var subfiles = this.readDir(path);
                for (var fileToDelete in subfiles) {
                    if (subfiles.hasOwnProperty(fileToDelete)) {
                        this.delete(subfiles[fileToDelete], recursive);
                    }
                }
            }
            if (_f.rmdirSync(internalPath) === false) {
                throw new Error('Cannot delete directory "' + path + '"');
            }
            else {
                return true;
            }
        }
        else {
            if (_f.unlinkSync(internalPath) === false) {
                throw new Error('Cannot delete file "' + path + '"');
            }
            else {
                return true;
            }
        }
    }
    else {
        throw new Error('The file "' + path + '" doesn\'t exist.');
    }
};
Ejemplo n.º 11
0
    end() {
        if (this.warning) {
            this.log(`\n${chalk.yellow.bold('WARNING!')} Kubernetes configuration generated with missing images!`);
            this.log(this.warningMessage);
        } else {
            this.log(`\n${chalk.bold.green('Kubernetes configuration successfully generated!')}`);
        }

        this.log(`${chalk.yellow.bold('WARNING!')} You will need to push your image to a registry. If you have not done so, use the following commands to tag and push the images:`);
        for (let i = 0; i < this.appsFolders.length; i++) {
            const originalImageName = this.appConfigs[i].baseName.toLowerCase();
            const targetImageName = this.appConfigs[i].targetImageName;
            if (originalImageName !== targetImageName) {
                this.log(`  ${chalk.cyan(`docker image tag ${originalImageName} ${targetImageName}`)}`);
            }
            this.log(`  ${chalk.cyan(`${this.dockerPushCommand} ${targetImageName}`)}`);
        }

        this.log('\nYou can deploy all your apps by running the following script:');
        this.log(`  ${chalk.cyan('./kubectl-apply.sh')}`);
        if (this.gatewayNb + this.monolithicNb >= 1) {
            const namespaceSuffix = this.kubernetesNamespace === 'default' ? '' : ` -n ${this.kubernetesNamespace}`;
            this.log('\nUse these commands to find your application\'s IP addresses:');
            for (let i = 0; i < this.appsFolders.length; i++) {
                if (this.appConfigs[i].applicationType === 'gateway' || this.appConfigs[i].applicationType === 'monolith') {
                    this.log(`  ${chalk.cyan(`kubectl get svc ${this.appConfigs[i].baseName.toLowerCase()}${namespaceSuffix}`)}`);
                }
            }
            this.log();
        }
        // Make the apply script executable
        try {
            fs.chmodSync('kubectl-apply.sh', '755');
        } catch (err) {
            this.log(`${chalk.yellow.bold('WARNING!')}Failed to make 'kubectl-apply.sh' executable, you may need to run 'chmod +x kubectl-apply.sh'`);
        }
    }
Ejemplo n.º 12
0
function extractDownload(filePath) {
  var deferred = kew.defer()
  // extract to a unique directory in case multiple processes are
  // installing and extracting at once
  var extractedPath = filePath + '-extract-' + Date.now()
  var options = {cwd: extractedPath}

  mkdirp.sync(extractedPath, '0777')
  // Make double sure we have 0777 permissions; some operating systems
  // default umask does not allow write by default.
  fs.chmodSync(extractedPath, '0777')

  if (filePath.substr(-4) === '.zip') {
    console.log('Extracting zip contents')

    try {
      var zip = new AdmZip(filePath)
      zip.extractAllTo(extractedPath, true)
      deferred.resolve(extractedPath)
    } catch (err) {
      console.error('Error extracting zip')
      deferred.reject(err)
    }

  } else {
    console.log('Extracting tar contents (via spawned process)')
    cp.execFile('tar', ['jxf', filePath], options, function (err, stdout, stderr) {
      if (err) {
        console.error('Error extracting archive')
        deferred.reject(err)
      } else {
        deferred.resolve(extractedPath)
      }
    })
  }
  return deferred.promise
}
Ejemplo n.º 13
0
 var createHost = function () {
   // console.log('createHost');
   try {
     fs.writeFileSync(newfile, str);
     fs.chmodSync(newfile, '755');
     proc.exec(
       ['sudo mv ', newfile, ' ', hostmapper.HOSTSPATH].join(''),
       function (error, stdout, stderr) {
         if (error !== null) {
           console.log('failed to move the new host file.');
           console.log(error);
           process.exit(1);
         }
         console.log('done');
         process.exit(0);
       }
     );
   }
   catch (er) {
     console.log('failed to write a host');
     console.log(er);
     process.exit(1);
   }
 };
Ejemplo n.º 14
0
function mkpathRecurseSync(parts, mode)
{
	if (parts.length === 0)
		return;

	var working = parts.pop();
	if (working !== "")
	{
		var exists = fs.existsSync(working);
		if (!exists)
		{
			fs.mkdirSync(working);
			fs.chmodSync(working, mode);
		}
		else
		{
			var stats = fs.statSync(working);
			if (!stats.isDirectory())
				throw new Error("Path contains a file.");
		}
	}

	mkpathRecurseSync(parts, mode);
}
Ejemplo n.º 15
0
      filePair.src.forEach(function(src) {
        if (detectDestType(filePair.dest) === 'directory') {
          dest = (isExpandedPair) ? filePair.dest : unixifyPath(path.join(filePair.dest, src));
        } else {
          dest = filePair.dest;
        }

          if (filePair.orig.touch && !(dest = filePair.orig.touch(src, dest))) {
              return;
          }

        if (grunt.file.isDir(src)) {
          grunt.verbose.writeln('Creating ' + chalk.cyan(dest));
          grunt.file.mkdir(dest);
          tally.dirs++;
        } else {
          grunt.verbose.writeln('Copying ' + chalk.cyan(src) + ' -> ' + chalk.cyan(dest));
          grunt.file.copy(src, dest, copyOptions);
          if (options.mode !== false) {
            fs.chmodSync(dest, (options.mode === true) ? fs.lstatSync(src).mode : options.mode);
          }
          tally.files++;
        }
      });
Ejemplo n.º 16
0
	function writeFile(srcPath, destPath, content, options) {
		grunt.file.write(destPath, content, options);
		if (options.mode !== false) {
			fs.chmodSync(destPath, (options.mode === true) ? fs.lstatSync(srcPath).mode : options.mode);
		}
	}
Ejemplo n.º 17
0
	function runTask(task, path, modulePath, callback) {
		
		killTask();
		
		task = task || "";
		// Execute grunt command
		var exec = require('child_process').exec;
		process.chdir(path);
		if (isWin) {
			//var spawn = require('child_process').spawn;
			//cmd =  spawn(modulePath +"/node/node_modules/.bin/grunt.cmd", ['--no-color', task]);
			
			cmd = exec(modulePath + "/node/node_modules/.bin/grunt --no-color " + task, function (error, stdout, stderr) {
				if (callback) {
					if (error) {
						callback(stderr);
					} else {
						callback(false, stdout);
					}
				}
			});
			
			cmd.stderr.on('data', function (data) {
				domain.emitEvent("grunt", "change", data.toString());
			});
			
			cmd.stdout.on('data', function (data) {
				domain.emitEvent("grunt", "change", data.toString());
			});
			cmd.on('error', function () { console.log(arguments); });

		
		} else {
		
			//Handle permission denied error on MAC
            var stat = fs.statSync(modulePath + "/node/node_modules/.bin/grunt");
             
            if(parseInt(stat.mode.toString(8), 10).toString().search('555$') === -1) {
               fs.chmodSync( modulePath + "/node/node_modules/.bin/grunt", '555');
            }
			
			cmd = exec("echo '\"" + modulePath + "/node/node_modules/.bin/grunt\" --no-color " + task + "' | bash --login",  function (error, stdout, stderr) {
				if (callback) {
					if (error) {
						callback(stderr);
					} else {
						callback(stdout);
					}
				}
			});
			
			
			cmd.stderr.on('data', function (data) {
				console.log(data.toString());
				domain.emitEvent("grunt", "change", data.toString());
			});
			
			cmd.stdout.on('data', function (data) {
				console.log(data.toString());
				domain.emitEvent("grunt", "change", data.toString());
			});
			
			cmd.on('error', function () {console.log(arguments); });
		}
    }
Ejemplo n.º 18
0
exports.spawn = function(cmd, args, opts) {
    args = args || [];
    opts = opts || {};
    var spawnOpts = {};
    var d = Q.defer();

    if (iswin32) {
        cmd = resolveWindowsExe(cmd);
        // If we couldn't find the file, likely we'll end up failing,
        // but for things like "del", cmd will do the trick.
        if (path.extname(cmd) != '.exe') {
            var cmdArgs = '"' + [cmd].concat(args).map(maybeQuote).join(' ') + '"';
            // We need to use /s to ensure that spaces are parsed properly with cmd spawned content
            args = [['/s', '/c', cmdArgs].join(' ')];
            cmd = 'cmd';
            spawnOpts.windowsVerbatimArguments = true;
        } else if (!fs.existsSync(cmd)) {
            // We need to use /s to ensure that spaces are parsed properly with cmd spawned content
            args = ['/s', '/c', cmd].concat(args).map(maybeQuote);
        }
    }

    if (opts.stdio == 'ignore') {
        spawnOpts.stdio = 'ignore';
    } else if (opts.stdio == 'inherit') {
        spawnOpts.stdio = 'inherit';
    }
    if (opts.cwd) {
        spawnOpts.cwd = opts.cwd;
    }
    if (opts.env) {
        spawnOpts.env = _.extend(_.extend({}, process.env), opts.env);
    }
    if (opts.chmod && !iswin32) {
        try {
            // This fails when module is installed in a system directory (e.g. via sudo npm install)
            fs.chmodSync(cmd, '755');
        } catch (e) {
            // If the perms weren't set right, then this will come as an error upon execution.
        }
    }

    events.emit(opts.printCommand ? 'log' : 'verbose', 'Running command: ' + maybeQuote(cmd) + ' ' + args.map(maybeQuote).join(' '));

    var child = child_process.spawn(cmd, args, spawnOpts);
    var capturedOut = '';
    var capturedErr = '';

    if (child.stdout) {
        child.stdout.setEncoding('utf8');
        child.stdout.on('data', function(data) {
            capturedOut += data;
        });

        child.stderr.setEncoding('utf8');
        child.stderr.on('data', function(data) {
            capturedErr += data;
        });
    }

    child.on('close', whenDone);
    child.on('error', whenDone);
    function whenDone(arg) {
        child.removeListener('close', whenDone);
        child.removeListener('error', whenDone);
        var code = typeof arg == 'number' ? arg : arg && arg.code;

        events.emit('verbose', 'Command finished with error code ' + code + ': ' + cmd + ' ' + args);
        if (code === 0) {
            d.resolve(capturedOut.trim());
        } else {
            var errMsg = cmd + ': Command failed with exit code ' + code;
            if (capturedErr) {
                errMsg += ' Error output:\n' + capturedErr.trim();
            }
            var err = new Error(errMsg);
            err.code = code;
            d.reject(err);
        }
    }

    return d.promise;
};
Ejemplo n.º 19
0
setTimeout(function () {
   // 모드 변경 - rw/rw/r
   console.log('파일 모드 변경');
   fs.chmodSync(file, '664');
}, 3000);
Ejemplo n.º 20
0
function setupLinux(callback) {
    fs.writeFileSync(__dirname + '/../../../iobroker', "node node_modules/iobroker.js-controller/iobroker.js $1 $2 $3 $4 $5", {mode: '777'});
    console.log('Write "./iobroker start" to start the ioBroker');
    try {
        if (!fs.existsSync(__dirname + '/../../iobroker.js-controller/iobroker')) {
            fs.writeFileSync(__dirname + '/../../iobroker.js-controller/iobroker', "#!/usr/bin/env node\nrequire(__dirname + '/lib/setup.js');");
        }
        fs.chmodSync(__dirname + '/../../../iobroker', '777');
        fs.chmodSync(__dirname + '/../../iobroker.js-controller/iobroker', '777');
    } catch (e) {
        console.error('Cannot set permissions of ' + path.normalize(__dirname + '/../../iobroker.js-controller/iobroker'));
        console.log('You can still manually copy ')
    }

    // replace @@path@@ with position of
    var parts = __dirname.replace(/\\/g, '/').split('/');
    // remove lib
    parts.pop();
    // remove iobroker
    parts.pop();
    var text = '';

    var home = JSON.parse(JSON.stringify(parts));
    // remove node_modules
    home.pop();

    text += 'sudo cp ' + path.normalize(__dirname + '/../install/iobroker') + ' /usr/bin/\n';
    text += 'sudo chmod 777 /usr/bin/iobroker\n';
    text += 'sudo cp ' + path.normalize(__dirname + '/../install/linux/iobroker.sh') + ' /etc/init.d/\n';
    text += 'sudo chmod 777 /etc/init.d/iobroker.sh\n';
    text += 'sudo bash ' + path.normalize(__dirname + '/../install/linux/install.sh') + '\n';

    try {
        fs.writeFileSync(__dirname + '/../../../install.sh', text, {mode: 511});
    } catch (e) {

    }

    try{
        // check if /etc/init.d/ exists
        if (fs.existsSync('/usr/bin')) {
            fs.writeFileSync('/usr/bin/iobroker', 'node ' + home.join('/') + '/node_modules/iobroker.js-controller/iobroker.js $1 $2 $3 $4 $5', {mode: "777"});
            fs.chmodSync('/usr/bin/iobroker', '777');
        }
    } catch (e) {
        console.warn('Cannot create file /usr/bin/iobroker!. Non critical');
        // create files for manual coping
        fs.writeFileSync(__dirname + '/../install/iobroker', 'node ' + home.join('/') + '/node_modules/iobroker.js-controller/iobroker.js $1 $2 $3 $4 $5', {mode: "777"});
        console.log('');
        console.log('-----------------------------------------------------');
        console.log('You can manually copy file into /usr/bin/. Just write:');
        console.log('    sudo cp ' + path.normalize(__dirname + '/../install/iobroker') + ' /usr/bin/');
        console.log('    sudo chmod 777 /usr/bin/iobroker');
        console.log('-----------------------------------------------------');
    }

    // check if /etc/init.d/ exists
    if (fs.existsSync('/etc/init.d')) {
        // replace @@path@@ with position of
        var _path = parts.join('/') + '/iobroker.js-controller/';

        var txt = fs.readFileSync(__dirname + '/../install/linux/iobroker.sh');
        txt = txt.toString().replace(/@@PATH@@/g, _path);
        txt = txt.toString().replace(/@@HOME@@/g, home.join('/'));
        fs.writeFileSync(__dirname + '/../install/linux/iobroker.sh', txt, {mode: '777'});
        fs.chmodSync(__dirname + '/../install/linux/iobroker.sh', '777');

        // copy iobroker.sh from install/linux to /etc/init.d/
        copyFile(__dirname + '/../install/linux/iobroker.sh', '/etc/init.d/iobroker.sh', function (err) {
            txt = fs.readFileSync(__dirname + '/../install/linux/install.sh');
            txt = txt.toString().replace(/@@PATH@@/g, _path);

            fs.writeFileSync(__dirname + '/../install/linux/install.sh', txt, {mode: '777'});
            fs.chmodSync(__dirname + '/../install/linux/install.sh', '777');

            var exec = require('child_process').exec;
            // js-controller installed as npm
            var child;

            if (err) {
                console.error('Cannot copy file to /etc/init.d/iobroker.sh: ' + err);
                console.log('');
                console.log('-----------------------------------------------------');
                console.log('You can manually copy file and install autostart: ');
                console.log('     sudo cp ' + path.normalize(__dirname + '/../install/linux/iobroker.sh') + ' /etc/init.d/');
                console.log('     sudo chmod 777 /etc/init.d/iobroker.sh');
                console.log('     sudo bash ' + path.normalize(__dirname + '/../install/linux/install.sh'));
                console.log('-----------------------------------------------------');
                console.log(' or just start "sudo bash ' + path.normalize(__dirname + '/../../../install.sh') + '"');
                console.log('-----------------------------------------------------');
                if (callback) callback();
            } else {
                // call
                //echo "Set permissions..."
                //find /opt/iobroker/ -type d -exec chmod 777 {} \;
                //find /opt/iobroker/ -type f -exec chmod 777 {} \;
                //chown -R $IO_USER:$IO_USER /opt/iobroker/
                //chmod 777 /etc/init.d/iobroker.sh
                //#Replace user pi with current user
                //sed -i -e "s/IOBROKERUSER=.*/IOBROKERUSER=$IO_USER/" /etc/init.d/iobroker.sh
                //chown root:root /etc/init.d/iobroker.sh
                //update-rc.d /etc/init.d/iobroker.sh defaults
                if (gIsSudo) {
                    child = exec('sudo bash ' + __dirname + '/../install/linux/install.sh');
                } else {
                    child = exec('bash ' + __dirname + '/../install/linux/install.sh');
                }
                child.stderr.pipe(process.stdout);
                child.on('exit', function (errCode) {
                    console.log('Auto-start was enabled. Write "update-rc.d -f iobroker.sh remove" to disable auto-start');
                    console.log('iobroker is started. Go to "http://ip-addr:8081" to open the admin UI.');
                    if (callback) callback();
                });
            }
        });
    }
}
Ejemplo n.º 21
0
function createExecutableHook(file) {
  fs.writeFileSync(file, template.content);
  fs.chmodSync(file, '755');
}
Ejemplo n.º 22
0
 res.on('end', function() {
   // Make file executable.
   fs.chmodSync(filepath, 457);
   console.log('Finished!');
 });
Ejemplo n.º 23
0
 genkey.addListener( 'exit', function( code, signal ) {
     fs.chmodSync('certs/server.key', '600');
     loadServer();
 });
Ejemplo n.º 24
0
		return _super.download.apply(this, arguments).then(function () {
			if (self.executable !== 'java') {
				fs.chmodSync(pathUtil.join(self.directory, executable), parseInt('0755', 8));
			}
		});
Ejemplo n.º 25
0
fs.readdirSync(fixturesdir).forEach(function(file) {
  fs.chmodSync(join(fixturesdir, file), '0600');
});
Ejemplo n.º 26
0
	server.listen(pathname, () => {
		fs.chmodSync(pathname, Config.replsocketmode || 0o600);
		socketPathnames.add(pathname);
	});
Ejemplo n.º 27
0
 .on('finish', () => {
   fs.chmodSync(`${dest_64}/create_desktop_file.sh`, '755');
 });
Ejemplo n.º 28
0
 ws.on('finish', function() {
     if(type.indexOf('linux') !== -1) {
         fs.chmodSync(relaseFile, '0755');
     }
     releaseDone.resolve(type);
 });
Ejemplo n.º 29
0
http.createServer(app).listen(app.get('port'), function(){
  if (fs.existsSync(SOCKET_FILE)) {
    fs.chmodSync(SOCKET_FILE, 666); // some system need this to work right;
  }
  console.log('Express server listening on port ' + app.get('port'));
});
Ejemplo n.º 30
0
 files.forEach(function(file) {
     fs.chmodSync(path.join(destination, file.path), file.mode);
 });