Added seed code for caas-registry.
[ta/caas-registry.git] / docker-build / registry / security-utils / utils.sh
1 #!/bin/sh
2 # Copyright 2019 Nokia
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 del_user () {
17     if command -v userdel
18     then
19         userdel "$1"
20     else
21         deluser "$1"
22     fi
23 }
24
25 del_group () {
26     if command -v groupdel
27     then
28         groupdel "$1"
29     else
30         delgroup "$1"
31     fi
32 }
33
34 get_group_name () {
35     while read -r group_info
36     do
37         gid=$(echo $group_info | cut -d: -f3)
38         if [ "$gid" = "$1" ]
39         then
40             echo $(echo "$group_info" | cut -d: -f1);
41         fi
42     done < /etc/group
43 }