Compare commits
2 commits
1a430e1b4a
...
952aaced2b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
952aaced2b | ||
|
|
daceb05d52 |
17
index.js
17
index.js
|
|
@ -33,10 +33,25 @@ const main = async () => {
|
|||
}
|
||||
}
|
||||
}
|
||||
console.log("Call forwards:", forwards);
|
||||
|
||||
// Search all forwards for any target that is between 700 and 800. If it exists, log to console and run `asterisk -x "database del CF[U/B] <ext>"` to delete it
|
||||
for (const [key, target] of Object.entries(forwards)) {
|
||||
const targetExt = parseInt(target, 10);
|
||||
if (targetExt >= 700 && targetExt < 800) {
|
||||
console.log(`Deleting forward ${key} to target ${target}`);
|
||||
const delCommand = `asterisk -x "database del ${key.replace('/', ' ')}"`;
|
||||
const { error, stdout, stderr } = await runAsterisk(delCommand);
|
||||
if (error) {
|
||||
console.error(`Error executing command "${delCommand}": ${error}`);
|
||||
} else {
|
||||
console.log(`Successfully deleted forward ${key}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Unexpected error: ${err}`);
|
||||
}
|
||||
setTimeout(main, 3000); // Run every 60 seconds
|
||||
};
|
||||
|
||||
const startup = async () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue