Repository: incubator-ranger
Updated Branches:
  refs/heads/tag-policy 21204fe62 -> 6b79130d9


RANGER-700:Provide a wrapper shell script to run the FileSourceUserGroupBuilder 
process


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/d60c4df2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/d60c4df2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/d60c4df2

Branch: refs/heads/tag-policy
Commit: d60c4df2af863e38a4253ced8e510b36d5e606a1
Parents: 21204fe
Author: rmani <[email protected]>
Authored: Wed Oct 28 16:18:35 2015 -0700
Committer: rmani <[email protected]>
Committed: Wed Oct 28 16:18:35 2015 -0700

----------------------------------------------------------------------
 src/main/assembly/usersync.xml                  |  9 +++
 .../run-filesource-usersync.sh                  | 72 ++++++++++++++++++++
 2 files changed, 81 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d60c4df2/src/main/assembly/usersync.xml
----------------------------------------------------------------------
diff --git a/src/main/assembly/usersync.xml b/src/main/assembly/usersync.xml
index 161a443..211db7c 100644
--- a/src/main/assembly/usersync.xml
+++ b/src/main/assembly/usersync.xml
@@ -134,6 +134,15 @@
             </includes>
             <fileMode>544</fileMode>
         </fileSet>
+        <fileSet>
+                <directoryMode>755</directoryMode>
+                <fileMode>755</fileMode>
+                <outputDirectory>/usersync_tool</outputDirectory>
+                <directory>ugsync/filesourceusersynctool</directory>
+            <includes>
+                <include>run-filesource-usersync.sh</include>
+            </includes>
+        </fileSet>
        <fileSet>
                 <directoryMode>755</directoryMode>
                 <fileMode>755</fileMode>

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d60c4df2/ugsync/filesourceusersynctool/run-filesource-usersync.sh
----------------------------------------------------------------------
diff --git a/ugsync/filesourceusersynctool/run-filesource-usersync.sh 
b/ugsync/filesourceusersynctool/run-filesource-usersync.sh
new file mode 100644
index 0000000..6badfa1
--- /dev/null
+++ b/ugsync/filesourceusersynctool/run-filesource-usersync.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+# 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.
+
+usage() {
+  echo "usage: run-filesource-usergroupsync.sh
+ -h                  show help.
+ -i <arg>            Input file name ( csv or json file )
+                         JSON FILE FORMAT
+                               {
+                               "user1":["group-1", "group-2", "group-3"],
+                               "user2":["group-x","group-y","group-z"]
+                               }
+
+                     CSV FILE FORMAT
+                    user-1,group-1,group-2,group-3
+                    user-2,group-x,group-y,group-z"
+  exit 1
+}
+
+logdir="/var/log/ranger/usersync"
+scriptPath=$(cd "$(dirname "$0")"; pwd)
+ugsync_home="${scriptPath}/.."
+cp="${ugsync_home}/dist/*:${ugsync_home}/lib/*:${ugsync_home}/conf"
+
+JAVA_CMD="java -Dlogdir=${logdir} -cp ${cp} 
org.apache.ranger.unixusersync.process.FileSourceUserGroupBuilder"
+
+while getopts "i:h" opt; do
+  case $opt in
+    i) JAVA_CMD="$JAVA_CMD $OPTARG"
+       fileName=$OPTARG
+       ;;
+    h) usage
+       ;;
+   \?) echo -e \\n"Option -$OPTARG not allowed."
+        usage
+        ;;
+  esac
+done
+
+if [ $OPTIND -eq 1 ];
+then
+  usage;
+fi
+
+echo "JAVA commnad = $JAVA_CMD"
+
+if [ "${JAVA_HOME}" != "" ]
+then
+       export JAVA_HOME
+       PATH="${JAVA_HOME}/bin:${PATH}"
+       export PATH
+fi
+$JAVA_CMD
+errorCode=$?
+if [ ${errorCode} -eq 0 ]; then
+    echo "Successfully loaded users/groups from file ${fileName}"
+else
+    echo "Failed to load users/groups from file ${fileName}: error 
code=${errorCode}"
+fi

Reply via email to