runing in root. And more doc
This commit is contained in:
parent
2e5cf06f68
commit
1e396c0a09
@ -1,6 +1,6 @@
|
|||||||
FROM debian:10
|
FROM debian:10
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /root
|
||||||
|
|
||||||
RUN addgroup eleve
|
RUN addgroup eleve
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ services:
|
|||||||
app:
|
app:
|
||||||
build: .
|
build: .
|
||||||
volumes:
|
volumes:
|
||||||
- ./config:/app/config
|
- ./config:/root/config
|
||||||
- ./home_eleves:/home
|
- ./home_eleves:/home
|
||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
restart: "unless-stopped"
|
restart: "unless-stopped"
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
HOME_BASE="/home"
|
HOME_BASE="/home"
|
||||||
USERS_LIST="/app/config/users.txt"
|
USERS_LIST="./config/users.txt"
|
||||||
PASSWD_LIST="/app/config/passwords.txt"
|
PASSWD_LIST="./config/passwords.txt"
|
||||||
CUSTOM_SCRIPT="/app/config/init.sh"
|
|
||||||
|
|
||||||
separator="=" # Must be ascii for cut
|
separator="=" # Must be ascii for cut
|
||||||
forbidden_chars=". / : # = \ "
|
forbidden_chars=". / : # = \ "
|
||||||
@ -27,9 +26,19 @@ echo " Create users (and passwords if needed) as in $USERS_LIST"
|
|||||||
genPassowrd () {
|
genPassowrd () {
|
||||||
tr -dc A-Za-z0-9 </dev/urandom | head -c $1
|
tr -dc A-Za-z0-9 </dev/urandom | head -c $1
|
||||||
}
|
}
|
||||||
|
sanitizeFile () {
|
||||||
|
tmp="$(mktemp)"
|
||||||
|
sed -e "s/\r//g" "$1" > "$tmp"
|
||||||
|
mv "$tmp" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
if [ ! -e "$PASSWD_LIST" ] ; then
|
if [ ! -e "$PASSWD_LIST" ] ; then
|
||||||
touch "$PASSWD_LIST"
|
touch "$PASSWD_LIST"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sanitizeFile "$PASSWD_LIST"
|
||||||
|
sanitizeFile "$USERS_LIST"
|
||||||
|
|
||||||
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" ] || [ -n "$(cat $PASSWD_LIST | grep "$user$separator")" ] ; then continue ; fi
|
||||||
echo "$user$separator$(genPassowrd 6)" >> $PASSWD_LIST
|
echo "$user$separator$(genPassowrd 6)" >> $PASSWD_LIST
|
||||||
@ -38,7 +47,6 @@ done
|
|||||||
for line in $(cat $PASSWD_LIST) ; do
|
for line in $(cat $PASSWD_LIST) ; do
|
||||||
name="$(echo "$line" | cut -d "$separator" -f 1)"
|
name="$(echo "$line" | cut -d "$separator" -f 1)"
|
||||||
pass="$(echo "$line" | cut -d "$separator" -f 2)"
|
pass="$(echo "$line" | cut -d "$separator" -f 2)"
|
||||||
echo $name $pass
|
|
||||||
if [ -z "$name" ] || [ -z "$pass" ] ; then echo "Malformed line skipped: '$line'" ; continue ; fi
|
if [ -z "$name" ] || [ -z "$pass" ] ; then echo "Malformed line skipped: '$line'" ; continue ; fi
|
||||||
home="$HOME_BASE/$name"
|
home="$HOME_BASE/$name"
|
||||||
mkdir -p "$home"
|
mkdir -p "$home"
|
||||||
|
@ -33,3 +33,7 @@ Pour suivre la progression des élèves, on utilise le script suivant.
|
|||||||
```
|
```
|
||||||
TODO
|
TODO
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Ajouter des élèves
|
||||||
|
Si l’activité est déjà lancée et que vous souhaitez ajouter des élèves, faites le IMPÉRATIVEMENT __en bas du fichier__ `config/users.txt` ou `config/passwords.txt`.
|
||||||
|
Sans quoi les comptes peuvent être recréés avec des UID différents au redémarrage du conteneur et les droits seront incohérents.
|
||||||
|
Loading…
Reference in New Issue
Block a user