-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage_gitlab_users.sh
More file actions
executable file
·63 lines (44 loc) · 1.89 KB
/
manage_gitlab_users.sh
File metadata and controls
executable file
·63 lines (44 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash -e
# Set default values for parameters, case they are empty or undefined
: "${GIT_ROOT:=$(git rev-parse --show-toplevel)}"
: "${SCRIPT_HOME:=$GIT_ROOT/GitLab/}"
: "${GITLAB_SERVER:=gitlab-test}"
SCRIPT_NAME="$(basename "$0")"
echo "--- -----------------------------------------------------------------------------------------"
echo "-S- ${SCRIPT_NAME}: Manage GitLab Users (in ${GITLAB_SERVER})"
echo "--- -----------------------------------------------------------------------------------------"
echo "-I- Running as '$(whoami)' on '$(hostname)'"
source "$(dirname "$0")/../Unix_Admin/bin/devops_fun.sh"
# -------------------------------------------------------------------------------------- #
export GITLAB_TOKEN="$("${GIT_ROOT}"/GitLab/get_gitlab_token.sh "${GITLAB_SERVER}" "${GITLAB_TOKEN}")"
do_fun_validate_param_silent GITLAB_TOKEN
do_fun_validate_param GITLAB_SERVER
do_fun_validate_param ACTION
if [[ ${VERBOSE:-false} != "false" ]]
then
do_func_show_env_vars
do_func_show_command_version python
do_func_show_command_version python3
# Activate command-echo
set -x
fi
cd "$SCRIPT_HOME"
# Prepare/use the Virtual-Env ______________________________
VENV_DIR="${SCRIPT_NAME%.*}_venv" # Strip the extension from the (short) filename
VENV_COMMAND=virtualenv
do_fun_confirm_we_have_python3_package "${VENV_COMMAND}"
do_fun_reset_virtualenv_dir "${VENV_DIR}" "${RESET_VENV}"
# Create the Virtual-Env (force python3)
virtualenv -p "$(which python3)" "${VENV_DIR}"
# Initialize the Virtual-Env
source "${VENV_DIR}/bin/activate"
# Install Required Python Packages on the Virtual-Env
pip3 install -r "${VENV_DIR}_requirements.txt"
do_func_show_python3_packages
python3 ./manage_gitlab_users.py \
--server "${GITLAB_SERVER}" \
--token "${GITLAB_TOKEN}" \
--action "${ACTION}" \
${DRY_RUN} \
${VERBOSE} \
"$@" # Pass any command-line parameters