50 lines
1021 B
Bash
Executable File
50 lines
1021 B
Bash
Executable File
#!/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
|
|
command: ["/bin/bash", "-c", "/usr/local/bin/create_ubuntu_user.sh ${USER_NAME} ${PASSWORD} && /usr/local/bin/start_services.sh"]
|
|
|
|
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
|