|
| 1 | +#!/usr/bin/env perl |
| 2 | + |
| 3 | +use v5.18; |
| 4 | + |
| 5 | +use lib '../lib'; |
| 6 | +use Scot::Env; |
| 7 | +use Try::Tiny; |
| 8 | +use Data::Compare; |
| 9 | +use Data::Dumper; |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +my @required = ( |
| 14 | + { |
| 15 | + config_file => "/opt/scot/etc/scot.cfg.pl", |
| 16 | + install_ver => "../install/src/scot/scot.cfg.pl", |
| 17 | + attributes => [ |
| 18 | + "location", |
| 19 | + "site_identifier", |
| 20 | + "default_share_policy", |
| 21 | + "log_config", |
| 22 | + "modules", |
| 23 | + "get_method", |
| 24 | + "default_groups", |
| 25 | + "group_mode", |
| 26 | + "mode", |
| 27 | + "default_groups", |
| 28 | + "federation", |
| 29 | + "row_limit", |
| 30 | + "session_expiration", |
| 31 | + "admin_group", |
| 32 | + "file_store_root", |
| 33 | + "epoch_cols", |
| 34 | + "int_cols", |
| 35 | + "mojo_defaults", |
| 36 | + "entry_actions", |
| 37 | + "forms" |
| 38 | + ], |
| 39 | + }, |
| 40 | + { |
| 41 | + config_file => "/opt/scot/etc/alert.cfg.pl", |
| 42 | + install_ver => "../install/src/scot/scot.cfg.pl", |
| 43 | + attributes => [ |
| 44 | + "location", |
| 45 | + "site_identifier", |
| 46 | + "default_share_policy", |
| 47 | + "time_zone", |
| 48 | + "log_config", |
| 49 | + "modules", |
| 50 | + "leave_unseen", |
| 51 | + "verbose", |
| 52 | + "max_processes", |
| 53 | + "fetch_mode", |
| 54 | + "since", |
| 55 | + "approved_alert_domains", |
| 56 | + "approved_accounts", |
| 57 | + "parser_dir", |
| 58 | + "default_groups", |
| 59 | + "default_owner", |
| 60 | + ], |
| 61 | + }, |
| 62 | + { |
| 63 | + config_file => "/opt/scot/etc/flair.cfg.pl", |
| 64 | + install_ver => "../install/src/scot/flair.cfg.pl", |
| 65 | + attributes => [ |
| 66 | + "location", |
| 67 | + "site_identifier", |
| 68 | + "default_share_policy", |
| 69 | + "time_zone", |
| 70 | + "servername", |
| 71 | + "username", |
| 72 | + "password", |
| 73 | + "authtype", |
| 74 | + "log_config", |
| 75 | + "modules", |
| 76 | + "stomp_host", |
| 77 | + "stomp_port", |
| 78 | + "topic", |
| 79 | + "max_workers", |
| 80 | + "default_owner", |
| 81 | + ], |
| 82 | + }, |
| 83 | + { |
| 84 | + config_file => "/opt/scot/etc/reflair.cfg.pl", |
| 85 | + install_ver => "../install/src/scot/reflair.cfg.pl", |
| 86 | + attributes => [ |
| 87 | + "location", |
| 88 | + "site_identifier", |
| 89 | + "time_zone", |
| 90 | + "servername", |
| 91 | + "username", |
| 92 | + "password", |
| 93 | + "authtype", |
| 94 | + "log_config", |
| 95 | + "modules", |
| 96 | + "stomp_host", |
| 97 | + "stomp_port", |
| 98 | + "topic", |
| 99 | + "max_workers", |
| 100 | + ], |
| 101 | + }, |
| 102 | + { |
| 103 | + config_file => "/opt/scot/etc/backup.cfg.pl", |
| 104 | + install_ver => "../install/src/scot/backup.cfg.pl", |
| 105 | + attributes => [ |
| 106 | + "location", |
| 107 | + "log_config", |
| 108 | + "dbname", |
| 109 | + "pidfile", |
| 110 | + "bkuplocation", |
| 111 | + "cacheimg", |
| 112 | + "tarloc", |
| 113 | + "cleanup", |
| 114 | + "es_server", |
| 115 | + "es_backup_location", |
| 116 | + ], |
| 117 | + }, |
| 118 | + { |
| 119 | + config_file => "/opt/scot/etc/restore.cfg.pl", |
| 120 | + install_ver => "../install/src/scot/restore.cfg.pl", |
| 121 | + attributes => [ |
| 122 | + "location", |
| 123 | + "log_config", |
| 124 | + "dbname", |
| 125 | + "pidfile", |
| 126 | + "bkuplocation", |
| 127 | + "cacheimg", |
| 128 | + "tarloc", |
| 129 | + "cleanup", |
| 130 | + "es_server", |
| 131 | + "es_backup_location", |
| 132 | + ], |
| 133 | + }, |
| 134 | + { |
| 135 | + config_file => "/opt/scot/etc/game.cfg.pl", |
| 136 | + install_ver => "../install/src/scot/game.cfg.pl", |
| 137 | + attributes => [ |
| 138 | + "location", |
| 139 | + "log_config", |
| 140 | + "days_ago", |
| 141 | + "modules", |
| 142 | + ], |
| 143 | + }, |
| 144 | + { |
| 145 | + config_file => "/opt/scot/etc/metrics.cfg.pl", |
| 146 | + install_ver => "../install/src/scot/metrics.cfg.pl", |
| 147 | + attributes => [ |
| 148 | + "time_zone", |
| 149 | + "log_config", |
| 150 | + "modules", |
| 151 | + ], |
| 152 | + }, |
| 153 | + { |
| 154 | + config_file => "/opt/scot/etc/stretch.cfg.pl", |
| 155 | + install_ver => "../install/src/scot/stretch.cfg.pl", |
| 156 | + attributes => [ |
| 157 | + "location", |
| 158 | + "time_zone", |
| 159 | + "log_config", |
| 160 | + "max_workers", |
| 161 | + "stomp_host", |
| 162 | + "stomp_port", |
| 163 | + "topic", |
| 164 | + "default_owner", |
| 165 | + "modules", |
| 166 | + ], |
| 167 | + }, |
| 168 | +); |
| 169 | + |
| 170 | +my @attrs_needed = (); |
| 171 | + |
| 172 | +foreach my $req (@required) { |
| 173 | + |
| 174 | + my $default = load_config($req->{install_ver}); |
| 175 | + my $actual = load_config($req->{config_file}); |
| 176 | + |
| 177 | + foreach my $attr (@{$req->{attributes}}) { |
| 178 | + |
| 179 | + |
| 180 | + say "\nAttribute: ".$attr; |
| 181 | + say "------------------------------\n"; |
| 182 | + |
| 183 | + try { |
| 184 | + |
| 185 | + my $value = $actual->{$attr}; |
| 186 | + my $default = $default->{$attr}; |
| 187 | + |
| 188 | + if ( defined $value ) { |
| 189 | + say " attribute exists."; |
| 190 | + } |
| 191 | + else { |
| 192 | + push @attrs_needed, { |
| 193 | + config => $req->{config_file}, |
| 194 | + attribute => $attr, |
| 195 | + }; |
| 196 | + } |
| 197 | + |
| 198 | + if ( examine($default, $value) ) { |
| 199 | + say " attribute has default value"; |
| 200 | + } |
| 201 | + else { |
| 202 | + say " attribure has changed value"; |
| 203 | + } |
| 204 | + } |
| 205 | + catch { |
| 206 | + say " ERROR: attribute does not exist in ". |
| 207 | + $req->{config_file}; |
| 208 | + }; |
| 209 | + } |
| 210 | +} |
| 211 | + |
| 212 | +say "________________________________________________"; |
| 213 | +say "Missing Attributes in configs"; |
| 214 | +say "________________________________________________"; |
| 215 | +say Dumper(\@attrs_needed); |
| 216 | + |
| 217 | +sub examine { |
| 218 | + my $def = shift; |
| 219 | + my $val = shift; |
| 220 | + return Compare($def, $val); |
| 221 | +} |
| 222 | + |
| 223 | +sub load_config { |
| 224 | + my $file = shift; |
| 225 | + unless ( -r $file ) { |
| 226 | + die "Config file not readable!\n"; |
| 227 | + }; |
| 228 | + no strict 'refs'; |
| 229 | + my $cont = new Safe 'MCONFIG'; |
| 230 | + my $result = $cont->rdo($file); |
| 231 | + my $hname = 'MCONFIG::environment'; |
| 232 | + my %copy = %$hname; |
| 233 | + my $href = \%copy; |
| 234 | + return $href; |
| 235 | +} |
| 236 | + |
| 237 | + |
0 commit comments