40 lines
865 B
Bash
Executable File
40 lines
865 B
Bash
Executable File
#!/bin/sh
|
|
|
|
|
|
HOME_BASE="/usr/share/app/python_app/modules"
|
|
|
|
# Check we got users
|
|
if [ ! -f 'users.txt' ] ; then
|
|
echo "Missing file users.txt"
|
|
exit 1
|
|
fi
|
|
|
|
# Must be ascii for cut
|
|
separator="="
|
|
|
|
# Generate passwords if not done yet
|
|
genPassowrd () {
|
|
tr -dc A-Za-z0-9 </dev/urandom | head -c $1
|
|
}
|
|
if [ ! -f 'passwords.txt' ] ; then
|
|
for user in $(cat users.txt) ; do
|
|
echo "$user$separator$(genPassowrd 10)" >> passwords.txt
|
|
done
|
|
fi
|
|
|
|
# Create users
|
|
for line in $(cat passwords.txt) ; do
|
|
name="$(echo "$line" | cut -d "$separator" -f 1)"
|
|
pass="$(echo "$line" | cut -d "$separator" -f 2)"
|
|
echo "$pass\n$pass" | useradd --home-dir "$HOME_BASE/$name" --create-home --no-user-group -G eleve "$name"
|
|
done
|
|
|
|
# Nginx
|
|
nginx -c '/etc/nginx/nginx.conf'
|
|
|
|
# SSH server
|
|
/usr/sbin/sshd
|
|
|
|
# Start watever the container should be doing
|
|
/bin/sh -c "$*"
|