#!/usr/bin/env bash main() { local username="${1:-abc}" local uid="${2:-1000}" local gid="${3:-1000}" local home="${4:-/home/abc}" usermod -d "/root" "${username}" groupmod -o -g "${gid}" "${username}" usermod -o -u "${uid}" "${username}" usermod -d "${home}" "${username}" # Ensure tty group exists with GID 4 (Alpine standard) if ! getent group tty >/dev/null; then addgroup -g 4 tty fi # Add user to tty group for /dev/pts/* access addgroup "${username}" tty 2>/dev/null if tty -s; then local tty_device tty_device="$(tty)" if [ -f "${tty_device}" ]; then chmod g+rw "${tty_device}" 2>/dev/null fi fi } main "${@}"