- Timestamp:
- Jul 18, 2010, 9:20:40 PM (14 years ago)
- Location:
- dasscm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
dasscm/trunk/dasscm.spec
r915 r916 12 12 Autoreqprov: on 13 13 Summary: Dass Configuration Management 14 Version: 1. 014 Version: 1.1 15 15 Release: 0 16 16 Requires: subversion perl … … 56 56 install -m 640 etc/dasscm.conf $RPM_BUILD_ROOT/etc/ 57 57 mkdir -p $RPM_BUILD_ROOT/var/lib/dasscm/ 58 mkdir -p $RPM_BUILD_ROOT/var/lib/dasscm/plugin-results/ 58 59 %if %(test -d /etc/bash_completion.d/ && echo 1 || echo 0) 59 60 %define use_bash_completion 1 … … 80 81 %defattr(-,root,root) 81 82 %dir /var/lib/dasscm/ 83 %dir /var/lib/dasscm/plugin-results/ 82 84 /usr/bin/dasscm 83 85 /usr/bin/dasscm_remote_update.sh -
dasscm/trunk/etc/dasscm.conf
r882 r916 37 37 # 38 38 DASSCM_PERMISSION_FILE="/etc/permissions.d/dasscm.permission_backup" 39 40 # 41 # plugin definitions 42 # 43 DASSCM_PLUGIN_TEST_RPMLIST="type rpm && test /var/lib/rpm/Packages -nt /var/lib/dasscm/plugin-results/RPMLIST" 44 DASSCM_PLUGIN_CMD_RPMLIST="rpm -qa --last" -
dasscm/trunk/usr/bin/dasscm
r915 r916 64 64 'complete_path' => 'complete_path', 65 65 'complete_repopath' => 'complete_repopath', 66 'plugins' => 'plugins', 66 67 ); 67 68 … … 185 186 'function' => \&complete_repopath 186 187 }, 188 'plugins' => { 189 'desc' => ["internal, perform plugins"], 190 'params' => [], 191 'function' => \&perform_plugins 192 }, 193 187 194 ); 188 195 … … 190 197 my $DASSCM_LOCAL_REPOSITORY_BASE; 191 198 my $DASSCM_REPOSITORY_NAME; 199 my $DASSCM_PLUGIN_RESULTS_PATH; 192 200 my $DASSCM_SVN_REPOSITORY; 193 201 my $DASSCM_CHECKOUT_USERNAME; … … 360 368 if ( $command ne "init" ) { 361 369 if ( not -d $DASSCM_REPO ) { 362 die 363 "Can't access local repository DASSCM_REPO\n($DASSCM_REPO)\nCheck configuration and execute\n dasscm init\n"; 370 fatalerror( 371 "Can't access local repository DASSCM_REPO", 372 "($DASSCM_REPO)", 373 "Check configuration and execute", 374 "dasscm init" 375 ); 364 376 } 365 377 … … 705 717 } 706 718 719 # 720 # en- or disable echo mode. 721 # used for reading passwords from STDIN 722 # 723 sub setEchoMode( $ ) 724 { 725 my $mode = shift; 726 if( $mode ) { 727 run_command( "stty echo" ); 728 } else { 729 run_command( "stty -echo" ); 730 } 731 } 732 733 734 sub write_array_to_file( $@ ) 735 { 736 my $filename = shift; 737 my @array = @_; 738 739 if ( ! -w dirname($filename) ) { 740 warning( "failed to write to $filename", "directory does not exist" ); 741 return; 742 } 743 744 # directory exists => write 745 if( ! open( OUTFILE, ">$filename" ) ) { 746 warning( "failed to open $filename: $!" ); 747 return; 748 } 749 750 foreach my $line (@array) { 751 print OUTFILE "$line"; 752 } 753 close(OUTFILE); 754 755 return 1; 756 } 757 758 759 sub perform_plugins() 760 { 761 check_env(); 762 763 my @plugin_results = (); 764 765 # get all defined plugins. 766 # Plugin definitions starting with DASSCM_PLUGIN_ 767 my @plugins = grep(/^DASSCM_PLUGIN_CMD_/, keys( %{$config} )); 768 769 for my $plugin (@plugins) { 770 my $plugin_name = substr( $plugin, length( "DASSCM_PLUGIN_CMD_" ) ); 771 my $plugin_test = $config->{'DASSCM_PLUGIN_TEST_' . $plugin_name}; 772 ( my $rc_test, my @result_test ) = run_command( $plugin_test ); 773 if ($verbose) { print "Plugin $plugin_name: "; } 774 if( $rc_test != 0 ) { 775 if ($verbose) { print "skipped\n"; } 776 } else { 777 if ($verbose) { print "$config->{$plugin}\n"; } 778 ( my $rc, my @result ) = run_command( $config->{$plugin} ); 779 if( $rc != 0 ) { 780 warning( "failed to run plugin $plugin" ); 781 } else { 782 my $plugin_result_file = $DASSCM_PLUGIN_RESULTS_PATH . "/" . $plugin_name; 783 write_array_to_file( $plugin_result_file, @result ); 784 push @plugin_results, $plugin_result_file; 785 } 786 } 787 } 788 return @plugin_results; 789 } 790 791 792 707 793 sub svn_check_credentials( $$;$$ ) 708 794 { … … 1053 1139 1054 1140 # hidden password input 1055 print "Enter password stty for $input_username: "; 1056 #ReadMode('noecho'); 1057 `stty -echo`; 1141 print "Enter password for $input_username: "; 1142 setEchoMode( 0 ); 1058 1143 my $input_password = <STDIN>; 1059 #ReadMode('normal'); 1060 `stty echo`; 1144 setEchoMode( 1 ); 1061 1145 chomp($input_password); 1062 1146 print "\n"; … … 1218 1302 add_helper($DASSCM_PERMISSION_FILE); 1219 1303 1304 for my $file ( perform_plugins() ) { 1305 add_helper($file); 1306 } 1307 1308 1220 1309 if ( $options{'message'} ) { 1221 1310 $svnOptions .= " --message \"$options{'message'}\" "; … … 1278 1367 # add permissions file 1279 1368 add_helper($DASSCM_PERMISSION_FILE); 1369 1370 for my $file ( perform_plugins() ) { 1371 add_helper($file); 1372 } 1373 1374 1280 1375 1281 1376 if ( $options{'message'} ) { … … 1433 1528 # check, if permissions have changed 1434 1529 permissions(); 1530 perform_plugins(); 1435 1531 1436 1532 # get modified files … … 1479 1575 # check, if permissions have changed 1480 1576 permissions(); 1577 perform_plugins(); 1481 1578 1482 1579 # get modified files … … 1737 1834 $DASSCM_REPOSITORY_NAME = $config->{'DASSCM_REPOSITORY_NAME'}; 1738 1835 1836 $DASSCM_PLUGIN_RESULTS_PATH = $config->{'DASSCM_LOCAL_REPOSITORY_BASE'} . "/" . "plugin-results/"; 1837 1739 1838 # TODO: check variables 1740 1839 $DASSCM_SVN_REPOSITORY =
Note:
See TracChangeset
for help on using the changeset viewer.