Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.32 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. my $i = @sources; # 0 (zero)
  43.  
  44. for my $k ( keys %$SOGoUserSources )
  45. {
  46.     if( ref $SOGoUserSources->{$k} eq 'HASH')
  47.     {
  48.         my $source = $SOGoUserSources->{$k};
  49.         $sources[$i] = join ";", map { "$_=$source->{$_}" } keys %$source;
  50.         $i++;
  51.     }
  52. }
  53.  
  54. my $str = join ",", map { "{$_}" } @sources;
  55. print "\ndefaults write sogod SOGoUserSources '($str)'\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement