reboot.js 506 B

12345678910111213141516171819
  1. ;(function(){
  2. var exec = require('child_process').execSync;
  3. var dir = __dirname, tmp;
  4. try{exec("crontab -l");
  5. }catch(e){tmp = e}
  6. if(0 > tmp.toString().indexOf('no')){ return }
  7. try{tmp = exec('which node').toString();
  8. }catch(e){console.log(e);return}
  9. try{tmp = exec('echo "@reboot '+tmp+' '+dir+'/../examples/http.js" > '+dir+'/reboot.cron');
  10. }catch(e){console.log(e);return}
  11. try{tmp = exec('crontab '+dir+'/reboot.cron');
  12. }catch(e){console.log(e);return}
  13. console.log(tmp.toString());
  14. }());