update
This commit is contained in:
parent
c7cf872d9c
commit
853b0e0a7d
@ -1,2 +1,3 @@
|
|||||||
218-amine=TPA6eMfztS
|
218-amine=TPA6eMfztS
|
||||||
218-chems=osjMQQ8rXd
|
218-chems=osjMQQ8rXd
|
||||||
|
test=bRqy6jlnM6
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
218-amine
|
218-amine
|
||||||
218-chems
|
218-chems
|
||||||
|
test
|
||||||
|
@ -6,3 +6,4 @@ services:
|
|||||||
- ./config:/app/config
|
- ./config:/app/config
|
||||||
- ./production_eleves:/app/python_app/modules
|
- ./production_eleves:/app/python_app/modules
|
||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
|
restart: "unless-stopped"
|
||||||
|
@ -6,7 +6,7 @@ PASSWD_LIST="/app/config/passwords.txt"
|
|||||||
CUSTOM_SCRIPT="/app/config/init.sh"
|
CUSTOM_SCRIPT="/app/config/init.sh"
|
||||||
|
|
||||||
separator="=" # Must be ascii for cut
|
separator="=" # Must be ascii for cut
|
||||||
forbidden_chars=". /"
|
forbidden_chars=". / : # = \ "
|
||||||
|
|
||||||
# Check we got user list
|
# Check we got user list
|
||||||
if [ ! -f "$USERS_LIST" ] && [ ! -f "$PASSWD_LIST" ] ; then
|
if [ ! -f "$USERS_LIST" ] && [ ! -f "$PASSWD_LIST" ] ; then
|
||||||
@ -15,24 +15,20 @@ if [ ! -f "$USERS_LIST" ] && [ ! -f "$PASSWD_LIST" ] ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for c in $forbidden_chars ; do
|
for c in $forbidden_chars ; do
|
||||||
for file in "$USERS_LIST" "$PASSWD_LIST" ; do
|
if [ -n "$(cat "$USERS_LIST" | grep -F $c)" ] ; then
|
||||||
if [ -n "$(cat "$USERS_LIST" | grep -F $c)" ] ; then
|
echo "Le fichier « $USERS_LIST » ne doit pas contenir le caractère « $c » !"
|
||||||
echo "Le fichier « $file » ne doit pas contenir le caractère « $c » !"
|
exit 1
|
||||||
exit 1
|
fi
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Generate passwords if not done yet
|
# Generate passwords if not done yet
|
||||||
genPassowrd () {
|
genPassowrd () {
|
||||||
tr -dc A-Za-z0-9 </dev/urandom | head -c $1
|
tr -dc A-Za-z0-9 </dev/urandom | head -c $1
|
||||||
}
|
}
|
||||||
if [ ! -f $PASSWD_LIST ] ; then
|
for user in $(cat "$USERS_LIST") ; do
|
||||||
for user in $(cat "$USERS_LIST") ; do
|
if [ -z "$user" ] || [ -n "$(cat $PASSWD_LIST | grep "$user$separator")" ] ; then continue ; fi
|
||||||
if [ -z "$user" ] ; then continue ; fi
|
echo "$user$separator$(genPassowrd 10)" >> $PASSWD_LIST
|
||||||
echo "$user$separator$(genPassowrd 10)" >> $PASSWD_LIST
|
done
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create users, home dirs, change passwords and home owners
|
# Create users, home dirs, change passwords and home owners
|
||||||
for line in $(cat $PASSWD_LIST) ; do
|
for line in $(cat $PASSWD_LIST) ; do
|
||||||
@ -42,6 +38,11 @@ for line in $(cat $PASSWD_LIST) ; do
|
|||||||
home="$HOME_BASE/$name"
|
home="$HOME_BASE/$name"
|
||||||
mkdir -p "$home"
|
mkdir -p "$home"
|
||||||
useradd --home-dir "$home" --no-user-group -G eleve --shell /bin/bash "$name"
|
useradd --home-dir "$home" --no-user-group -G eleve --shell /bin/bash "$name"
|
||||||
|
$ret="$?"
|
||||||
|
if [ "$ret" -ne 0 ] && [ "$ret" -ne 9 ] ; then
|
||||||
|
echo "Can’t create user '$name'. Error '$ret'."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
echo "$pass\n$pass" | passwd "$name" &> /dev/null
|
echo "$pass\n$pass" | passwd "$name" &> /dev/null
|
||||||
chown "$name":eleve "$home"
|
chown "$name":eleve "$home"
|
||||||
done
|
done
|
||||||
@ -64,4 +65,8 @@ nginx -c '/etc/nginx/nginx.conf'
|
|||||||
/usr/sbin/sshd -E /dev/stderr
|
/usr/sbin/sshd -E /dev/stderr
|
||||||
|
|
||||||
# Start watever the container should be doing
|
# Start watever the container should be doing
|
||||||
/bin/sh -c "$*"
|
/bin/sh -c "$*" &
|
||||||
|
pid="$!"
|
||||||
|
trap "kill -INT $pid" INT
|
||||||
|
trap "kill -TERM $pid" TERM
|
||||||
|
wait "$pid"
|
||||||
|
Loading…
Reference in New Issue
Block a user