#!/bin/bash
set -u

# This script sets up the base docker container for use with Helix Installer
# and SDP testing. It expects to be run as root within the container.

# Create base directories for use by Helix Installer tests.

# Create QA test user for sudo access.
groupadd qa
useradd -d /home/qa -s /bin/bash -m qa -g qa

echo 'qa ALL=(ALL) NOPASSWD:ALL' > /tmp/qa
chmod 0440 /tmp/qa
chown root:root /tmp/qa
mv /tmp/qa /etc/sudoers.d/.
echo 'qa:F@stSCM!' | chpasswd

# Helpful profile for qa user login profile - for manual testing mainly
# Add 'go*' aliases go cd to Helix Installer test OS users.
BASH_PROF=/home/qa/.bash_profile
cat <<"EOF" > $BASH_PROF
export PS1='$USER@${HOSTNAME%%.*}:$PWD '
alias go='sudo su - perforce'
alias go2='sudo su - cooldude'
EOF

chown qa:qa $BASH_PROF
