using check for cronjob & enhanced reboot message
This commit is contained in:
@ -122,20 +122,24 @@ Utils.prototype.copyConfigs = function (isWpaEabled) {
|
||||
|
||||
execSync('mv /usr/lib/raspiwifi/reset_device/static_files/raspiwifi.conf /etc/raspiwifi');
|
||||
|
||||
/* TODO: Setting up CRON for running monitoring jobs */
|
||||
this.printColor(null, 'Setting up CRON for running monitoring jobs');
|
||||
execSync('echo "# RaspiWiFi Startup" >> /etc/crontab');
|
||||
execSync('echo "@reboot root run-parts /etc/cron.raspiwifi/" >> /etc/crontab');
|
||||
const command = '@reboot root run-parts /etc/cron.raspiwifi/'
|
||||
if (!this.hasConfiguredCronJob(command)) {
|
||||
/* TODO: Setting up CRON for running monitoring jobs */
|
||||
this.printColor(null, 'Setting up CRON for running monitoring jobs');
|
||||
execSync('echo "# RaspiWiFi Startup" >> /etc/crontab');
|
||||
execSync('echo "'+ command+'" >> /etc/crontab');
|
||||
}
|
||||
|
||||
|
||||
/* Finishing things up */
|
||||
this.printColor(null, 'Finishing things up');
|
||||
execSync('touch /etc/raspiwifi/host_mode');
|
||||
}
|
||||
|
||||
Utils.prototype.hasConfiguredCronJob = function(command){
|
||||
Utils.prototype.hasConfiguredCronJob = function (command) {
|
||||
const cronResult = execSync('cat /etc/crontab');
|
||||
return cronResult.toString().indexOf(command)!==-1;
|
||||
|
||||
return cronResult.toString().indexOf(command) !== -1;
|
||||
|
||||
}
|
||||
|
||||
Utils.prototype.updateMainConfigFile = function ({ ssid, autoConfig, autoConfigDelay, sslEnabled, serverPort, wpaEnabled, wpaSecret }) {
|
||||
|
||||
@ -131,7 +131,9 @@ const consoleReset = lib.consoleColorCodes.Reset;
|
||||
let shouldReboot = false;
|
||||
do {
|
||||
inp = readline.question(
|
||||
`${lib.consoleColorCodes.FgRed}Would you like to do that now? [y/N]: ${consoleReset}`,
|
||||
`${lib.consoleColorCodes.FgRed}
|
||||
Initial setup is complete. A reboot is required to start in WiFi configuration mode...\n
|
||||
Would you like to do that now? [y/N]: ${consoleReset}`,
|
||||
{
|
||||
defaultInput: 'n'
|
||||
})
|
||||
@ -141,6 +143,6 @@ const consoleReset = lib.consoleColorCodes.Reset;
|
||||
if (shouldReboot)
|
||||
lib.reboot();
|
||||
|
||||
lib.hasConfiguredCronJob('@reboot root run-parts /etc/cron.raspiwifi/')
|
||||
|
||||
}());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user