-
Notifications
You must be signed in to change notification settings - Fork 1
RANGER-5365:Add test users into Ranger Docker Base Image #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
929e30a
RANGER-5365:Add test users into Ranger Docker Base Image
c3ec9f7
RANGER-5365:Add test users into Ranger Docker Base Image - co-pilot r…
7416565
RANGER-5365:Add test users into Ranger Docker Base Image -review comm…
ed34e85
RANGER-5365:Add test users into Ranger Docker Base Image -build issue…
68b7092
RANGER-5365:Add test users into Ranger Docker Base Image -build issue…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| #!/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. | ||
|
|
||
| # Script to create users and groups in ranger containers | ||
| # This script is designed to be run during container initialization | ||
|
|
||
| set -e | ||
|
|
||
| # General-purpose function to create a group if it doesn't exist. | ||
| create_group_if_not_exists() { | ||
| local groupname=$1 | ||
|
|
||
| if ! getent group "$groupname" &>/dev/null; then | ||
| echo "Creating group: $groupname" | ||
| groupadd "$groupname" | ||
| echo "Group $groupname created successfully" | ||
| else | ||
| echo "Group $groupname already exists" | ||
| fi | ||
| } | ||
|
|
||
| # General-purpose function to create a user if it doesn't exist. | ||
| create_user_if_not_exists() { | ||
| local username=$1 | ||
| local home_dir=$2 | ||
| local primary_group=$3 | ||
|
|
||
| if ! id "$username" &>/dev/null; then | ||
| echo "Creating user: $username" | ||
| useradd -g "$primary_group" -m -d "$home_dir" -s /bin/bash "$username" | ||
|
|
||
| # Set a default password | ||
| echo "$username:$username" | chpasswd | ||
rameeshm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| echo "User $username created successfully" | ||
| else | ||
| echo "User $username already exists" | ||
| fi | ||
| } | ||
|
|
||
| # Function to create users and groups if not exist | ||
| create_users_and_groups() { | ||
| local group_name=$1 | ||
| local users=$2 | ||
|
|
||
| echo "Creating group '$group_name' with users: $users" | ||
|
|
||
| # Create group and users | ||
| create_group_if_not_exists "$group_name" | ||
| for u in $users; do | ||
| create_user_if_not_exists "$u" "/home/$u" "$group_name" | ||
| done | ||
| } | ||
|
|
||
| # Main function to create all users and groups if not exist | ||
| create_all_users_and_groups() { | ||
| echo "Starting user and group creation..." | ||
|
|
||
| # Create ranger group and users | ||
| create_users_and_groups "ranger" "ranger rangeradmin rangerusersync rangertagsync rangerkms rangerauditserver" | ||
|
|
||
| # Create hadoop group and users | ||
| create_users_and_groups "hadoop" "hdfs yarn hive hbase kafka ozone" | ||
|
|
||
| # Create knox group and user | ||
| create_users_and_groups "knox" "knox" | ||
|
|
||
| # Create test users in test group | ||
| create_users_and_groups "testgroup" "testuser1 testuser2 testuser3" | ||
|
|
||
| echo "User and group creation completed successfully..." | ||
| } | ||
|
|
||
| # Execute the main function | ||
| create_all_users_and_groups | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.