Added create user function.
This commit is contained in:
@@ -98,14 +98,21 @@ exec_in_container() {
|
||||
# Returns 0 if the command was successful
|
||||
local CONTAINER_NAME=$CONTAINER_NAME
|
||||
local COMMAND="$1"
|
||||
|
||||
# Check if the container is running
|
||||
if ! docker ps --format '{{.Names}}' | grep -q "^$CONTAINER_NAME$"; then
|
||||
print_header "Error: Container '$CONTAINER_NAME' is not running."
|
||||
print_header "Error: Container '$CONTAINER_NAME' is not running.
|
||||
|
||||
We can't execute commands inside it, you can run it with:
|
||||
|
||||
>>> $0 start"
|
||||
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Execute the command in the container
|
||||
OUTPUT=$(docker exec "$CONTAINER_NAME" bash -c "$COMMAND" 2>&1)
|
||||
|
||||
local EXIT_CODE=$?
|
||||
|
||||
# Check if the command succeeded
|
||||
@@ -159,6 +166,19 @@ set_up_scripts() {
|
||||
return 0
|
||||
}
|
||||
|
||||
create_user(){
|
||||
read -p "Enter username: " USERNAME
|
||||
read -p "Enter role (admin/user): " ROLE_INPUT
|
||||
local COMMAND="python3 -c 'from utils.scripts import create_user_script_sync;create_user_script_sync(username=\"$USERNAME\", role_input=\"$ROLE_INPUT\")'"
|
||||
exec_in_container "$COMMAND"
|
||||
local RETURN_CODE=$?
|
||||
|
||||
if [[ $RETURN_CODE -eq 0 ]]; then
|
||||
print_header $EXECUTION_MESSAGE
|
||||
else
|
||||
print_header "Couldn't create the user due to the above error."
|
||||
fi
|
||||
}
|
||||
|
||||
update_config() {
|
||||
print_header "Update configs."
|
||||
@@ -659,23 +679,26 @@ help() {
|
||||
print_header "help:
|
||||
|
||||
Source Code Management:
|
||||
install
|
||||
update_code
|
||||
upgrade
|
||||
rebuild
|
||||
> install
|
||||
> update_code
|
||||
> upgrade
|
||||
> rebuild
|
||||
|
||||
App Running:
|
||||
start
|
||||
restart
|
||||
status
|
||||
stop
|
||||
> status
|
||||
> start
|
||||
> restart
|
||||
> stop
|
||||
|
||||
Users Management:
|
||||
> create_user
|
||||
|
||||
Configurations:
|
||||
show_config
|
||||
update_config
|
||||
> show_config
|
||||
> update_config
|
||||
|
||||
Help:
|
||||
help
|
||||
> help
|
||||
"
|
||||
exit 1
|
||||
}
|
||||
@@ -695,6 +718,7 @@ main() {
|
||||
case "$1" in
|
||||
install) install ;;
|
||||
update_code) update_code ;;
|
||||
create_user) create_user ;;
|
||||
upgrade) upgrade ;;
|
||||
rebuild) set_up_middleware;;
|
||||
start) start ;;
|
||||
@@ -702,8 +726,8 @@ main() {
|
||||
status) status ;;
|
||||
stop) stop ;;
|
||||
show_config) show_config ;;
|
||||
update_config) update_config;;
|
||||
help) help;;
|
||||
update_config) update_config ;;
|
||||
help) help ;;
|
||||
*) echo "Invalid argument: $1"; help ;;
|
||||
esac
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user