Xu Xiaodong avatar Xu Xiaodong committed abe3f5b

initial commit

Comments (0)

Files changed (2)

+#!/usr/bin/env perl
+#
+# name:      modup
+# author:    Xu Xiaodong <xxdlhy@gmail.com>
+# license:   GPL
+# created:   2011 May 27
+# modified:  2011 May 27
+#
+
+use strict;
+use warnings;
+
+use File::Copy qw(cp);
+use File::Find;
+use Tie::File;
+
+my $addr = shift;
+my $dir  = shift;
+
+mkdir "$ENV{HOME}/work/modup/$addr" unless -d $addr;
+
+find(
+  sub {
+    my ( $user, $pass );
+
+    if ( $_ =~ /(config\.js)\z/ ) {
+      open my $in_fh, '<', $1
+        or die "Can't open $1: $!\n";
+
+      while (<$in_fh>) {
+        $user = $1 if /myUsername:"EV7632LCD(.*)"/;
+        $pass = $1 if /myPassword:"(.*)"/;
+      }
+
+      close $in_fh;
+
+      my $file = "$ENV{HOME}/work/modup/$addr/tomcat-users_${user}.xml";
+
+      cp( "$ENV{HOME}/work/modup/tomcat-users.xml", $file );
+
+      tie my @lines, 'Tie::File', $file
+        or die "Can't read $file: $!\n";
+
+      for (@lines) {
+        s/(.*username="EV7632LCD)(.*)("\spassword=")(.*)("\sroles.*)/$1$user$3$pass$5/;
+      }
+
+      untie @lines;
+    }
+  },
+  $dir
+);
+
+# vim: ai:et:ts=2:sw=2:sts=2:tw=78:ft=perl
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<tomcat-users>
+
+  <role rolename="rolevmt"/>
+  <role rolename="digestdemo"/>
+  
+  <user username="EV7632LCD001" password="asdf33253##%#" roles="digestdemo,rolevmt"/>
+
+</tomcat-users>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.