Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const initSamba = async () => {
const logConfigPath = '/etc/rsyslog.d/99-smbaudit.conf'
const logConfig = 'LOCAL7.* @127.0.0.1:3721'
// update rsyslog config if necessary
let config = null
try { config = await fs.readFileAsync(logConfigPath) } catch (e) {debug('initSamba: Not find Samba service')}
if (config !== logConfig) {
await fs.writeFileAsync(logConfigPath, logConfig)
await child.execAsync('systemctl restart rsyslog')
}
await child.execAsync('systemctl start nmbd')
await child.execAsync('systemctl start smbd')
}
hash.update(text)
digest = hash.digest().toString('hex')
// await mkdirpAsync(this.docDir)
tmppath = path.join(this.tmpDir, digest)
filepath = path.join(this.docDir, digest)
try {
let stats = await fs.lstatAsync(filepath)
return digest
}
catch (e) {
if (e.code !== 'ENOENT') throw e
}
await writeFileToDiskAsync(tmppath, text)
await child.execAsync(`chmod 444 ${tmppath}`)
await fs.renameAsync(tmppath, filepath)
return digest
}
const probeWS215iAsync = async () => {
try {
await fs.statAsync('/proc/BOARD_io')
let arr = await Promise.all([
child.execAsync('dd if=/dev/mtd0ro bs=1 skip=1697760 count=11'),
child.execAsync('dd if=/dev/mtd0ro bs=1 skip=1697664 count=20'),
child.execAsync('dd if=/dev/mtd0ro bs=1 skip=1660976 count=6 | xxd -p')
])
return {
serial: arr[0].toString(),
p2p: arr[1].toString(),
mac: arr[2].trim().match(/.{2}/g).join(':')
}
} catch (e) {}
}
const addUnixUserAsync = async (username, uid) => {
debug('addUnixUser', username, uid)
let cmd = 'adduser --disabled-password --disabled-login --no-create-home --gecos ",,," ' +
`--uid ${uid} --gid 65534 ${username}`
return child.execAsync(cmd)
}
function getInstalledTractorVersion () {
info('Checking local "tractor" version...');
return childProcess.execAsync(LOCAL_TRACTOR_VERSION_COMMAND)
.then(local => {
let { version } = JSON.parse(local).dependencies.tractor;
info(`Local version of "tractor" is: ${version}`);
return version;
})
.catch(() => {
info('"tractor" is not installed.');
});
}
return Promise.all([fs.writeFileAsync(newDest, contents, "utf8"),
fs.writeFileAsync(minDest, minified.code, "utf8")]);
});
}, {concurrency: 4});
return Promise.all(
[codecs, css, cp.execAsync("browserify src/audio/AudioPlayerBackend.js --standalone AudioPlayer > dist/worker/AudioPlayerWorker.js", execOpts).then(function() {
return fs.readFileAsync("dist/worker/AudioPlayerWorker.js", "utf8");
}).then(function(contents) {
contents = "self.DEBUGGING = false;\n" + contents;
var minified = UglifyJS.minify(contents, {
fromString: true
});
return fs.writeFileAsync("dist/worker/AudioPlayerWorker.min.js", minified.code, "utf8");
}),
cp.execAsync("browserify src/audio/TrackAnalyzerBackend.js --standalone TrackAnalyzer > dist/worker/TrackAnalyzerWorker.js", execOpts).then(function() {
return fs.readFileAsync("dist/worker/TrackAnalyzerWorker.js", "utf8");
}).then(function(contents) {
contents = "self.DEBUGGING = false;\n" + contents;
var minified = UglifyJS.minify(contents, {
fromString: true
});
return fs.writeFileAsync("dist/worker/TrackAnalyzerWorker.min.js", minified.code, "utf8");
}),
cp.execAsync("browserify src/application.js --standalone Application > dist/main.js", execOpts)
]);
});
function installTractor () {
info('Installing "tractor"...');
return childProcess.execAsync(INSTALL_DEPENDENCIES_COMMAND)
.catch(() => error(`Couldn't install "tractor". Either run "tractor init" again, or install it manually by running "npm install tractor@latest --save-dev"`))
.then(() => info('Installed "tractor".'));
}
}).then(function() {
return cp.execAsync("mv dist/css/min/app-css-public.css dist/css/app-css-public.min.css", execOpts);
}).then(function() {
return fs.readFileAsync("dist/css/min/critical.css", "utf8");
const addSmbUsersAsync = async (fusers) => {
let text = fusers.map(u => `${u.unixname}:${u.uid}:` + 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:' +
`${u.md4}:[U ]:${u.lct}:`).join('\n')
debug('addSmbUsers', text)
await mkdirpAsync('/run/wisnuc/smb')
await fs.writeFileAsync('/run/wisnuc/smb/tmp', text)
await child.execAsync('pdbedit -i smbpasswd:/run/wisnuc/smb/tmp')
debug('addSmbUsers, after', await child.execAsync('pdbedit -Lw'))
}
contents = "self.DEBUGGING = false;\n" + contents;
var minified = UglifyJS.minify(contents, {
fromString: true
});
return fs.writeFileAsync("dist/worker/AudioPlayerWorker.min.js", minified.code, "utf8");
}),
cp.execAsync("browserify src/audio/TrackAnalyzerBackend.js --standalone TrackAnalyzer > dist/worker/TrackAnalyzerWorker.js", execOpts).then(function() {
return fs.readFileAsync("dist/worker/TrackAnalyzerWorker.js", "utf8");
}).then(function(contents) {
contents = "self.DEBUGGING = false;\n" + contents;
var minified = UglifyJS.minify(contents, {
fromString: true
});
return fs.writeFileAsync("dist/worker/TrackAnalyzerWorker.min.js", minified.code, "utf8");
}),
cp.execAsync("browserify src/application.js --standalone Application > dist/main.js", execOpts)
]);
});