80 lines
3.0 KiB
JavaScript
80 lines
3.0 KiB
JavaScript
#! /usr/bin/env runjs
|
|
|
|
var args = require('component-args.js');
|
|
|
|
var printHelp = () => {
|
|
println('macostool.js cmd');
|
|
println('help Print help');
|
|
println('list-java Print java list')
|
|
println('list-network Print network devices');
|
|
println('listen-tcp Print TCP listen');
|
|
println('listen-udp Print UDP listen');
|
|
println('wifi-info Print WIFI info');
|
|
println('wifi-scan Print WIFI scan');
|
|
println('print-route Print route list');
|
|
println('install-brew Install brew');
|
|
println('install-jenv Install jenv')
|
|
println('install-ports Install MacPorts');
|
|
println('install-sdkman Install SDKMAN');
|
|
println('install-dart Install Dart');
|
|
};
|
|
|
|
var main = () => {
|
|
var parsedArgs = args.parseARGS();
|
|
if (parsedArgs.args.length == 0) {
|
|
printHelp();
|
|
return;
|
|
}
|
|
|
|
var commands = {
|
|
'listen-tcp': () => { // ==OR== netstat -Waltn | grep LISTEN
|
|
$$.shell().inheritIO().commands('lsof', '-iTCP', '-sTCP:LISTEN', '-n', '-P').run();
|
|
},
|
|
'listen-udp': () => {
|
|
$$.shell().inheritIO().commands('lsof', '-iUDP', '-P', '-n').run();
|
|
},
|
|
'wifi-info': () => {
|
|
$$.shell().inheritIO().commands('/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport', '-I').run();
|
|
},
|
|
'wifi-scan': () => {
|
|
$$.shell().inheritIO().commands('/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport', '-s').run();
|
|
},
|
|
'list-java': () => {
|
|
$$.shell().inheritIO().commands('/usr/libexec/java_home', '-V').run();
|
|
},
|
|
'list-network': () => {
|
|
$$.shell().inheritIO().commands('networksetup', '-listallhardwareports').run();
|
|
},
|
|
'print-route': () => {
|
|
$$.shell().inheritIO().commands('netstat', '-nr').run();
|
|
},
|
|
'install-brew': () => {
|
|
$$.shell().inheritIO().commands('/usr/bin/ruby', '-e', '"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"').run();
|
|
},
|
|
'install-jenv': () => {
|
|
$$.shell().inheritIO().commands('sh', '-c', 'curl -L -s get.jenv.io | bash').run();
|
|
},
|
|
'install-ports': () => {
|
|
println('Please access: https://www.macports.org/install.php');
|
|
},
|
|
'install-sdkman': () => {
|
|
$$.shell().inheritIO().commands('sh', '-c', 'curl -s "https://get.sdkman.io" | bash').run();
|
|
},
|
|
'install-dart': () => {
|
|
// https://www.dartlang.org/install/mac
|
|
println('$ brew tap dart-lang/dart');
|
|
println('$ brew install dart');
|
|
}
|
|
};
|
|
var nullCommand = (cmd) => {
|
|
println('[ERROR] Command not found: ' + cmd);
|
|
println();
|
|
printHelp();
|
|
};
|
|
|
|
(commands[parsedArgs.args[0]] || nullCommand)(parsedArgs.args[0]);
|
|
};
|
|
|
|
main();
|
|
|