Changeset 25664 for trunk/DataStoreServer/scripts/dsprodtool
- Timestamp:
- Sep 29, 2009, 11:30:32 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/DataStoreServer/scripts/dsprodtool (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataStoreServer/scripts/dsprodtool
r24196 r25664 12 12 use PS::IPP::Metadata::Config; 13 13 use File::Copy; 14 15 use Term::ReadKey; 14 16 15 17 use PS::IPP::Config qw($PS_EXIT_SUCCESS … … 36 38 my $dsroot; 37 39 my $dbname; 40 my $dbpass; 38 41 39 42 my $add; … … 78 81 } else { 79 82 $product = $del; 83 if (! -t STDIN) { 84 die "cannot delete product from script\n"; 85 } 86 print "*** Delete the Data Store Product $product? ***\n"; 87 print "*** to delete $product answer YES, and give password ***\n"; 88 print "*** WARNING this action is permanant *** \n"; 89 print "Delete? (YES/[n]): "; 90 91 my $line = ReadLine(0); 92 chomp $line; 93 exit 1 if !$line or ($line ne "YES"); 94 95 print "password: "; 96 ReadMode('noecho'); 97 $line = ReadLine(0); 98 ReadMode('normal'); 99 print "\n"; 100 chomp $line; 101 $dbpass = $line; 80 102 } 81 103 … … 106 128 unless defined $dbname; 107 129 my $dbuser = metadataLookupStr($siteConfig, 'DS_DBUSER'); 108 my $dbpass = metadataLookupStr($siteConfig, 'DS_DBPASSWORD');130 $dbpass = metadataLookupStr($siteConfig, 'DS_DBPASSWORD') if !$dbpass; 109 131 exit ($PS_EXIT_CONFIG_ERROR) unless defined $dbserver and $dbname and $dbuser and $dbpass; 110 132 111 133 my $dsn = "DBI:mysql:host=$dbserver;database=$dbname"; 112 113 my $dbh = DBI->connect($dsn, $dbuser, $dbpass) or die "Cannot connect to server\n";114 115 134 116 135 my $product_dir = "$dsroot/$product"; … … 118 137 119 138 if ($del) { 139 my $dbh = DBI->connect($dsn, $dbuser, $dbpass) or die "Cannot connect to server\n"; 120 140 # 121 141 # delete product … … 129 149 } 130 150 my $prod_id = $prod_row->{prod_id}; 131 132 # if requested, remove the product directory133 if ($remove) {134 if (system "rm -r $product_dir") {135 die("failed to remove $product_dir");136 }137 } else {138 # otherwise just zap the index script139 unlink("$index_script_name");140 }141 151 142 152 … … 152 162 $dbh->do("DELETE from dsProduct where prod_id = $prod_id"); 153 163 164 print "Product $product deleted.\n"; 165 166 # if requested, remove the product directory 167 if ($remove) { 168 print "Removing files from $product.\n"; 169 if (system "rm -r $product_dir") { 170 die("failed to remove $product_dir"); 171 } 172 } else { 173 # otherwise just zap the index script 174 unlink("$index_script_name"); 175 } 176 154 177 exit 0; 155 178 … … 158 181 # add a new product 159 182 # 183 my $dbh = DBI->connect($dsn, $dbuser, $dbpass) or die "Cannot connect to server\n"; 184 160 185 my $stmt = $dbh->prepare("SELECT prod_id FROM dsProduct WHERE prod_name = \'$product\'"); 161 186 $stmt->execute();
Note:
See TracChangeset
for help on using the changeset viewer.
