using check for cronjob & enhanced reboot message

This commit is contained in:
jkoschke
2022-08-26 13:13:04 +02:00
parent 9d4b211a20
commit 6d75241c2c
2 changed files with 15 additions and 9 deletions

View File

@ -122,19 +122,23 @@ Utils.prototype.copyConfigs = function (isWpaEabled) {
execSync('mv /usr/lib/raspiwifi/reset_device/static_files/raspiwifi.conf /etc/raspiwifi');
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 "@reboot root run-parts /etc/cron.raspiwifi/" >> /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;
}

View File

@ -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/')
}());