-
Notifications
You must be signed in to change notification settings - Fork 4
/
check_modules.tcl
executable file
·47 lines (41 loc) · 1.26 KB
/
check_modules.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env tclsh
##
## CLI Script: this script checks if all modules and only existing modules are listed in yate.conf
##
package require Tcl 8.6
package require fileutil
package require cmdline
set options {
{lib.arg "/usr/local/lib/yate" "where all the yate modules are"}
{yate.conf.arg "/usr/local/etc/yate/yate.conf" "yate.conf"}
}
set usage "$::argv0 <options>..."
if {[catch {
array set cfg [::cmdline::getoptions argv $options $usage]
} e]} {
puts stderr $e
exit 1
}
set all_modules [lmap entry [glob -directory $cfg(lib) -- *.yate */*.yate] {
lindex [file split $entry] end
}]
set yateconf [::fileutil::cat -- $cfg(yate.conf)]
regexp -lineanchor -- {^\[modules\].*?\n\[} $yateconf all
set yateconf_modules {}
foreach {_ entry} [regexp -all -inline -line -- {^;?([a-zA-Z].*\.yate)=(?:true|false)} $all] {
lappend yateconf_modules $entry
}
puts "* all modules:\n $all_modules"
puts "* yateconf modules:\n $yateconf_modules"
puts "-------------"
puts "* should be added to $cfg(yate.conf):"
foreach entry $all_modules {
if {[lsearch -exact $yateconf_modules $entry] >= 0} {continue}
puts ";${entry}=true"
}
puts "-------------"
puts "* can be removed:"
foreach entry $yateconf_modules {
if {[lsearch -exact $all_modules $entry] >= 0} {continue}
puts $entry
}