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');
|
execSync('mv /usr/lib/raspiwifi/reset_device/static_files/raspiwifi.conf /etc/raspiwifi');
|
||||||
|
|
||||||
/* TODO: Setting up CRON for running monitoring jobs */
|
const command = '@reboot root run-parts /etc/cron.raspiwifi/'
|
||||||
this.printColor(null, 'Setting up CRON for running monitoring jobs');
|
if (!this.hasConfiguredCronJob(command)) {
|
||||||
execSync('echo "# RaspiWiFi Startup" >> /etc/crontab');
|
/* TODO: Setting up CRON for running monitoring jobs */
|
||||||
execSync('echo "@reboot root run-parts /etc/cron.raspiwifi/" >> /etc/crontab');
|
this.printColor(null, 'Setting up CRON for running monitoring jobs');
|
||||||
|
execSync('echo "# RaspiWiFi Startup" >> /etc/crontab');
|
||||||
|
execSync('echo "'+ command+'" >> /etc/crontab');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Finishing things up */
|
/* Finishing things up */
|
||||||
this.printColor(null, 'Finishing things up');
|
this.printColor(null, 'Finishing things up');
|
||||||
execSync('touch /etc/raspiwifi/host_mode');
|
execSync('touch /etc/raspiwifi/host_mode');
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.prototype.hasConfiguredCronJob = function(command){
|
Utils.prototype.hasConfiguredCronJob = function (command) {
|
||||||
const cronResult = execSync('cat /etc/crontab');
|
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 }) {
|
Utils.prototype.updateMainConfigFile = function ({ ssid, autoConfig, autoConfigDelay, sslEnabled, serverPort, wpaEnabled, wpaSecret }) {
|
||||||
|
|||||||
@ -131,7 +131,9 @@ const consoleReset = lib.consoleColorCodes.Reset;
|
|||||||
let shouldReboot = false;
|
let shouldReboot = false;
|
||||||
do {
|
do {
|
||||||
inp = readline.question(
|
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'
|
defaultInput: 'n'
|
||||||
})
|
})
|
||||||
@ -141,6 +143,6 @@ const consoleReset = lib.consoleColorCodes.Reset;
|
|||||||
if (shouldReboot)
|
if (shouldReboot)
|
||||||
lib.reboot();
|
lib.reboot();
|
||||||
|
|
||||||
lib.hasConfiguredCronJob('@reboot root run-parts /etc/cron.raspiwifi/')
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user