From: Terry F. <tf...@us...> - 2002-12-03 19:39:59
|
Update of /cvsroot/oscar/oscar/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv2067 Modified Files: start_over Log Message: Added code to delete all .configurator.values files from packages subdirectories. This restores a package's configuration back to default values. Also, fixed the problem with indentation in the code. (Some lines had tabs and some had spaces. Now all lines have spaces.) Index: start_over =================================================================== RCS file: /cvsroot/oscar/oscar/scripts/start_over,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -r1.34 -r1.35 *** start_over 5 Nov 2002 05:46:12 -0000 1.34 --- start_over 3 Dec 2002 19:39:56 -0000 1.35 *************** *** 4,86 **** my @known_rpms = qw( ! apache ! autoupdate ! autoupdate-cfg-redhat ! autoupdate-oscar ! c3-profiled ! c3 ! hdf5-oscar ! hdf5-oscar-module ! lam-module ! lam ! loghost ! mpich-oscar-module ! mpich-oscar ! ntpconfig ! pvm-modules-oscar ! pvm ! oda ! openpbs-oscar ! openpbs-oscar-mom ! openpbs-oscar-server ! openpbs-oscar-gui ! openpbs-oscar-commands ! openpbs-oscar-client ! sync_users-oscar ! ssh-oscar ! maui-oscar ! libdbdcsv-perl ! libappconfig-perl ! rrdtool ! systeminstaller ! systeminstaller-x11 ! systemconfigurator ! systemimager-server ! systemimager-common ! systemimager-client ! systemimager-i386boot ! systemimager-ia64boot ! tftp-hpa ! ganglia-monitor-core ! ganglia-php-rrd-client ! env-switcher ! modules ! ); my @known_services = qw( ! dhcpd ! gmond ! httpd ! maui ! ntpd ! mysqld ! pbs_server ! systemimager ! ); my @leave_rpms = qw( ! libpng ! ); # find oscar home directory my $oscar_home = ""; if ( exists $ENV{OSCAR_HOME} && -d $ENV{OSCAR_HOME} ) { ! $oscar_home = $ENV{OSCAR_HOME}; } else { ! chomp(my $prog = $0); ! chomp(my $cwd = `pwd`); ! my $path = ( $prog =~ /^\// ) ? $prog : "$cwd/$prog"; ! $path =~ s/\/[^\/]+\/\.\.\//\//g ! while $path =~ /\/[^\/]+\/\.\.\//; ! $path =~ s/\/\.\//\//g ! while $path =~ /\/\.\//; ! if ( $path =~ /\/scripts\/[^\/]+$/ ) { ! $oscar_home = $path; ! $oscar_home =~ s/\/scripts\/[^\/]+$//g; ! } } if ( ! -d $oscar_home ) { ! print "Cannot find OSCAR base directory from env var OSCAR_HOME or execution path\n"; ! exit 1; } print "Using $oscar_home as OSCAR base directory\n"; --- 4,84 ---- my @known_rpms = qw( ! apache ! autoupdate ! autoupdate-cfg-redhat ! autoupdate-oscar ! c3-profiled ! c3 ! hdf5-oscar ! hdf5-oscar-module ! lam-module ! lam ! loghost ! mpich-oscar-module ! mpich-oscar ! ntpconfig ! pvm-modules-oscar ! pvm ! oda ! openpbs-oscar ! openpbs-oscar-mom ! openpbs-oscar-server ! openpbs-oscar-gui ! openpbs-oscar-commands ! openpbs-oscar-client ! sync_users-oscar ! ssh-oscar ! maui-oscar ! libdbdcsv-perl ! libappconfig-perl ! rrdtool ! systeminstaller ! systeminstaller-x11 ! systemconfigurator ! systemimager-server ! systemimager-common ! systemimager-client ! systemimager-i386boot ! systemimager-ia64boot ! tftp-hpa ! ganglia-monitor-core ! ganglia-php-rrd-client ! env-switcher ! modules ! ); my @known_services = qw( ! dhcpd ! gmond ! httpd ! maui ! ntpd ! mysqld ! pbs_server ! systemimager ! ); my @leave_rpms = qw( ! libpng ! ); # find oscar home directory my $oscar_home = ""; if ( exists $ENV{OSCAR_HOME} && -d $ENV{OSCAR_HOME} ) { ! $oscar_home = $ENV{OSCAR_HOME}; } else { ! chomp(my $prog = $0); ! chomp(my $cwd = `pwd`); ! my $path = ( $prog =~ /^\// ) ? $prog : "$cwd/$prog"; ! $path =~ s/\/[^\/]+\/\.\.\//\//g while $path =~ /\/[^\/]+\/\.\.\//; ! $path =~ s/\/\.\//\//g while $path =~ /\/\.\//; ! if ( $path =~ /\/scripts\/[^\/]+$/ ) { ! $oscar_home = $path; ! $oscar_home =~ s/\/scripts\/[^\/]+$//g; ! } } if ( ! -d $oscar_home ) { ! print "Cannot find OSCAR base directory from env var OSCAR_HOME or execution path\n"; ! exit 1; } print "Using $oscar_home as OSCAR base directory\n"; *************** *** 102,106 **** my @oscar_rpm_files = @oscar_rpm_paths; foreach ( @oscar_rpm_files ) { ! $_ =~ s,^.*/,,g; } @oscar_rpm_files = sort_uniq( @oscar_rpm_files ); --- 100,104 ---- my @oscar_rpm_files = @oscar_rpm_paths; foreach ( @oscar_rpm_files ) { ! $_ =~ s,^.*/,,g; } @oscar_rpm_files = sort_uniq( @oscar_rpm_files ); *************** *** 108,113 **** my @oscar_rpms = @oscar_rpm_files; foreach ( @oscar_rpms ) { ! # $_ =~ s,\.[^\.]+\.rpm$,,g; ! $_ =~ s,\-[0-9]+.*$,,g; } @oscar_rpms = sort_uniq( @oscar_rpms ); --- 106,111 ---- my @oscar_rpms = @oscar_rpm_files; foreach ( @oscar_rpms ) { ! # $_ =~ s,\.[^\.]+\.rpm$,,g; ! $_ =~ s,\-[0-9]+.*$,,g; } @oscar_rpms = sort_uniq( @oscar_rpms ); *************** *** 126,136 **** my @oscar_services = (); foreach my $oscar_rpm_path ( @oscar_rpm_paths ) { ! my @files = `rpm -qpl $oscar_rpm_path`; ! chomp @files; ! my @service_files = grep( /^\/etc\/rc\.d\/init\.d\/[^\/]/, @files ); ! foreach ( @service_files ) { ! $_ =~ s,^.*/,,g; ! } ! push @oscar_services, @service_files; } @oscar_services = sort_uniq( @oscar_services ); --- 124,134 ---- my @oscar_services = (); foreach my $oscar_rpm_path ( @oscar_rpm_paths ) { ! my @files = `rpm -qpl $oscar_rpm_path`; ! chomp @files; ! my @service_files = grep( /^\/etc\/rc\.d\/init\.d\/[^\/]/, @files ); ! foreach ( @service_files ) { ! $_ =~ s,^.*/,,g; ! } ! push @oscar_services, @service_files; } @oscar_services = sort_uniq( @oscar_services ); *************** *** 147,151 **** # Delete the clients first so /etc/hosts gets cleaned do_command( "/usr/bin/mksimachine --Delete --all" ) ! if -x "/usr/bin/mksimachine"; uninstall_rpms(@oscar_rpms); --- 145,149 ---- # Delete the clients first so /etc/hosts gets cleaned do_command( "/usr/bin/mksimachine --Delete --all" ) ! if -x "/usr/bin/mksimachine"; uninstall_rpms(@oscar_rpms); *************** *** 173,247 **** sub delete_oscar_users { ! my @oscar_users = qw( ! oscartst ! ); ! foreach my $oscar_user (@oscar_users) { ! print "Removing user $oscar_user\n"; ! do_command("userdel -r $oscar_user"); ! } } sub stop_services { ! my @found_services = @_; ! my @all_services = ( @found_services, @known_services ); ! @all_services = sort_uniq( @all_services ); ! foreach my $service (@all_services) { ! do_command( "service $service stop" ) ! if -r "/etc/rc.d/init.d/$service"; ! } } sub cleanup_files { ! my @dirs = ( ! '/opt/kernel_picker', ! '/opt/opium', ! '/etc/systemimager', ! '/etc/dhcpd.conf', ! '/etc/profile.d/mpi-00mpich.csh', ! '/etc/profile.d/mpi-00mpich.sh', ! '/etc/profile.d/mpi-01lam.csh', ! '/etc/profile.d/mpi-01lam.sh', ! '/etc/systeminstaller', ! '/opt/autoupdate', ! '/opt/env-switcher*', ! '/opt/lam*', ! '/opt/maui', ! '/opt/modules', ! '/opt/mpich*', ! '/opt/pbs', ! '/opt/rrdtool-1.0.35', ! '/usr/local/lib/systemimager', ! '/var/lib/clamdr', ! '/var/lib/systemimager', ! '/var/lib/systeminstaller', ! '/var/log/systemimager', ! '/var/spool/pbs', ! "$oscar_home/.oscar", ! ); ! foreach my $file (@dirs) { ! print "rm -rf $file \n"; ! system("rm -rf $file"); ! } } sub do_command { ! my ( $command ) = ( @_ ); ! print "$command\n"; ! return system( "$command" ); } sub delete_from_pool { ! my @rpm_files = @_; ! my $dir = "/tftpboot/rpm/"; ! foreach my $rpm_file (@rpm_files) { ! do_command( "rm -f $dir$rpm_file" ) ! if -r "$dir$rpm_file"; ! } } sub _is_installed { ! my $rpm = shift; ! return !system("rpm -q $rpm >/dev/null"); } --- 171,250 ---- sub delete_oscar_users { ! my @oscar_users = qw( ! oscartst ! ); ! foreach my $oscar_user (@oscar_users) { ! print "Removing user $oscar_user\n"; ! do_command("userdel -r $oscar_user"); ! } } sub stop_services { ! my @found_services = @_; ! my @all_services = ( @found_services, @known_services ); ! @all_services = sort_uniq( @all_services ); ! foreach my $service (@all_services) { ! do_command( "service $service stop" ) if -r "/etc/rc.d/init.d/$service"; ! } } sub cleanup_files { ! my @dirs = ( ! '/opt/kernel_picker', ! '/opt/opium', ! '/etc/systemimager', ! '/etc/dhcpd.conf', ! '/etc/profile.d/mpi-00mpich.csh', ! '/etc/profile.d/mpi-00mpich.sh', ! '/etc/profile.d/mpi-01lam.csh', ! '/etc/profile.d/mpi-01lam.sh', ! '/etc/systeminstaller', ! '/opt/autoupdate', ! '/opt/env-switcher*', ! '/opt/lam*', ! '/opt/maui', ! '/opt/modules', ! '/opt/mpich*', ! '/opt/pbs', ! '/opt/rrdtool-1.0.35', ! '/usr/local/lib/systemimager', ! '/var/lib/clamdr', ! '/var/lib/systemimager', ! '/var/lib/systeminstaller', ! '/var/log/systemimager', ! '/var/spool/pbs', ! "$oscar_home/.oscar", ! ); ! foreach my $file (@dirs) { ! print "rm -rf $file \n"; ! system("rm -rf $file"); ! } ! ! # Remove the .configurator.values files from each package directory ! use File::Find (); ! File::Find::find({wanted => \&wanted}, "$oscar_home/packages"); ! sub wanted { ! /^\.configurator\.values\z/s && unlink($_); ! } } sub do_command { ! my ( $command ) = ( @_ ); ! print "$command\n"; ! return system( "$command" ); } sub delete_from_pool { ! my @rpm_files = @_; ! my $dir = "/tftpboot/rpm/"; ! foreach my $rpm_file (@rpm_files) { ! do_command( "rm -f $dir$rpm_file" ) if -r "$dir$rpm_file"; ! } } sub _is_installed { ! my $rpm = shift; ! return !system("rpm -q $rpm >/dev/null"); } *************** *** 249,290 **** sub sort_uniq { ! my ( @input_list ) = @_; ! my %seen; ! foreach my $value ( @input_list ) { ! $seen{$value}++; ! } ! my @result = sort ( keys %seen ); ! return @result; } sub uninstall_rpms { ! my @found_rpms = @_; ! my @all_rpms = ( @found_rpms, @known_rpms ); ! @all_rpms = sort_uniq( @all_rpms ); ! my @deleteme = (); ! foreach my $rpm (@all_rpms) { if(_is_installed($rpm)) { ! if ( ! grep( /^$rpm$/, @leave_rpms ) ) { ! push @deleteme, $rpm; ! } } } ! if(scalar(@deleteme)) { ! my $rpmcmd = 'rpm -e --allmatches --nodeps ' . (join ' ', @deleteme); ! if ( do_command($rpmcmd) ) { ! print "couldn't uninstall the rpms, trying again with --noscripts\n"; ! @deleteme = (); ! foreach my $rpm (@all_rpms) { ! if(_is_installed($rpm)) { ! if ( ! grep( /^$rpm$/, @leave_rpms ) ) { ! push @deleteme, $rpm; ! } ! } ! my $rpmcmd = 'rpm -e --allmatches --nodeps --noscripts ' . (join ' ', @deleteme); ! !do_command($rpmcmd) or croak "couldn't uninstall the rpms"; ! } ! } ! } ! return 1; } --- 252,293 ---- sub sort_uniq { ! my ( @input_list ) = @_; ! my %seen; ! foreach my $value ( @input_list ) { ! $seen{$value}++; ! } ! my @result = sort ( keys %seen ); ! return @result; } sub uninstall_rpms { ! my @found_rpms = @_; ! my @all_rpms = ( @found_rpms, @known_rpms ); ! @all_rpms = sort_uniq( @all_rpms ); ! my @deleteme = (); ! foreach my $rpm (@all_rpms) { ! if(_is_installed($rpm)) { ! if ( ! grep( /^$rpm$/, @leave_rpms ) ) { ! push @deleteme, $rpm; ! } ! } ! } ! if (scalar(@deleteme)) { ! my $rpmcmd = 'rpm -e --allmatches --nodeps ' . (join ' ', @deleteme); ! if ( do_command($rpmcmd) ) { ! print "couldn't uninstall the rpms, trying again with --noscripts\n"; ! @deleteme = (); ! foreach my $rpm (@all_rpms) { if(_is_installed($rpm)) { ! if ( ! grep( /^$rpm$/, @leave_rpms ) ) { ! push @deleteme, $rpm; ! } } + my $rpmcmd = 'rpm -e --allmatches --nodeps --noscripts ' . (join ' ', @deleteme); + !do_command($rpmcmd) or croak "couldn't uninstall the rpms"; + } } ! } ! return 1; } |