Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.27 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use Text::ASCIITable;
  6. use Getopt::Std;
  7. use Config::General;
  8.  
  9. #my $CONF2SOGO_CONFIGURATION_FILE = "./SOGo.conf";
  10.  
  11. #####################################################################
  12. #
  13. # Configuration loading stage.
  14. #
  15. #####################################################################
  16.  
  17. my $configuration = new Config::General("SOGo.conf");
  18. my %conf = $configuration->getall;
  19.  
  20. #####################################################################
  21. #
  22. # Grab all the "flat" variables (variables not inside a hash)
  23. #
  24. #####################################################################
  25.  
  26. foreach my $k ( keys %conf )
  27. {
  28.     # For each key found, we do an individual 'defaults write key value'
  29.     if(ref $conf{$k} eq 'HASH')
  30.     {
  31.         # ignore...
  32.     }
  33.     else
  34.     {
  35.         print "defaults write sogod $k $conf{$k}\n";
  36.         #system("defaults write sogod $k $conf{$k}");
  37.     }
  38. }
  39.  
  40. my $SOGoUserSources = $conf{SOGoUserSources};
  41. my @sources;
  42.  
  43. for my $k ( keys %$SOGoUserSources )
  44. {
  45.     if( ref $SOGoUserSources->{$k} eq 'HASH')
  46.     {
  47.         my $source = $SOGoUserSources->{$k};
  48.         push @sources, join ";", map { "$_=$source->{$_}" } keys %$source;
  49.     }
  50. }
  51.  
  52. my $str = join ",", map { "{$_}" } @sources;
  53. print "\ndefaults write sogod SOGoUserSources '($str)'\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement