This repository has been archived on 2021-12-26. You can view files and clone it, but cannot push or open issues or pull requests.
Files
docker-debian-playground/scripts/start.sh

45 lines
992 B
Bash

#!/bin/bash
echo "---Checking if UID: ${UID} matches user---"
usermod -u ${UID} ${USER}
echo "---Checking if GID: ${GID} matches user---"
usermod -g ${GID} ${USER}
echo "---Setting umask to ${UMASK}---"
umask ${UMASK}
echo "---Checking for optional scripts---"
if [ -f /opt/scripts/user.sh ]; then
echo "---Found optional script, executing---"
chmod +x /opt/scripts/user.sh
/opt/scripts/user.sh
else
echo "---No optional script found, continuing---"
fi
echo "${USER}:${USER_PWD}" | chpasswd
unset USER_PWD
echo "root:${ROOT_PWD}" | chpasswd
unset ROOT_PWD
if [ ! -f ${DATA_DIR}/sshd_config ]; then
cp /etc/ssh/sshd_config ${DATA_DIR}/sshd_config
fi
echo "---Starting...---"
chown -R ${UID}:${GID} /opt/scripts
chown -R ${UID}:${GID} ${DATA_DIR}
term_handler() {
kill -SIGTERM "$killpid"
wait "$killpid" -f 2>/dev/null
exit 143;
}
trap 'kill ${!}; term_handler' SIGTERM
su ${USER} -c "/opt/scripts/start-server.sh" &
killpid="$!"
while true
do
wait $killpid
exit 0;
done