Skip to content

Instantly share code, notes, and snippets.

@ksimuk
Created April 2, 2014 07:48
Show Gist options
  • Save ksimuk/9929674 to your computer and use it in GitHub Desktop.
Save ksimuk/9929674 to your computer and use it in GitHub Desktop.
dropbox init script for boxparts
#!/usr/bin/env node
var DROPBOX_INIT = '/home/codio/.dropbox-dist/dropboxd'
var DROPBOX_EXCLUDE = 'dropbox.py'
var cp = require('child_process');
var fs = require('fs');
function dropBoxInit() {
var childInit = cp.spawn(DROPBOX_INIT, []);
childInit.stdout.on('data', function (data) {
data = '' + data;
if ((data).indexOf('This computer is now linked to Dropbox') !== -1) {
addExlude(function(){
childInit.kill('SIGKILL');
})
}
console.log(data);
});
childInit.stderr.on('data', function (data) {
console.err(data);
});
}
function addExlude(callback) {
console.log('Trying to exclude folders, please wait...')
setTimeout( function() { // delay to get list of files
var path = '/home/codio/Dropbox/';
var files = fs.readdirSync(path);
var params = ['exclude', 'add'];
for (var i = 0; i < files.length; ++i) {
params.push(path + files[i]);
}
var childExclude = cp.spawn(DROPBOX_EXCLUDE, params);
childExclude.on('close', function(){
callback();
});
}, 5000);
}
dropBoxInit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment