You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
920 B
Bash
42 lines
920 B
Bash
#!/bin/bash
|
|
|
|
# Function to create user
|
|
create_user() {
|
|
# Check if USERNAME and PASSWORD are set
|
|
if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
|
|
echo "USERNAME and PASSWORD environment variables must be set"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if user already exists
|
|
if id "$USERNAME" &>/dev/null; then
|
|
echo "User $USERNAME already exists"
|
|
else
|
|
# Create user with specified username and password
|
|
echo "Creating user: $USERNAME"
|
|
useradd -m -s /bin/bash "$USERNAME"
|
|
echo "$USERNAME:$PASSWORD" | chpasswd
|
|
usermod -aG sudo "$USERNAME"
|
|
fi
|
|
}
|
|
|
|
# Function to configure XRDP
|
|
configure_xrdp() {
|
|
# Start XRDP service
|
|
service xrdp start
|
|
}
|
|
|
|
# Function to configure SSH
|
|
configure_ssh() {
|
|
# Start SSH service
|
|
service ssh start
|
|
}
|
|
|
|
# Main script execution
|
|
create_user
|
|
configure_xrdp
|
|
configure_ssh
|
|
|
|
# Keep the container running
|
|
tail -f /dev/null
|