chrodev/create_user.sh

50 lines
1021 B
Bash
Raw Permalink Normal View History

2024-07-23 16:40:12 -04:00
#!/bin/bash
USER_NAME=$1
USER_ID=$2
SSH_PORT=$3
VNC_PORT=$4
PASSWORD=$5 # New parameter for password
# Create user directory
mkdir -p ./data/$USER_ID
# Create a docker-compose file for this user
cat << EOF > docker-compose.user_${USER_ID}.yml
version: '3'
services:
user_${USER_ID}:
build: .
image: ubuntu_dev_env:latest
networks:
- frontend
- backend
volumes:
- ./data/${USER_ID}:/home/${USER_NAME}
environment:
- USER_NAME=${USER_NAME}
- USER_ID=${USER_ID}
- USER_PASSWORD=${PASSWORD}
ports:
- "${SSH_PORT}:22"
- "${VNC_PORT}:5901"
cap_add:
- SYS_ADMIN
security_opt:
- seccomp:unconfined
2024-07-23 23:25:47 -04:00
command: ["/bin/bash", "-c", "/usr/local/bin/create_ubuntu_user.sh ${USER_NAME} ${PASSWORD} && /usr/local/bin/start_services.sh"]
2024-07-23 16:40:12 -04:00
networks:
frontend:
external: true
name: frontend
backend:
external: true
name: backend
EOF
# Start the new service
docker-compose -f docker-compose.user_${USER_ID}.yml up -d