runing in root. And more doc
This commit is contained in:
parent
2e5cf06f68
commit
1e396c0a09
@ -1,6 +1,6 @@
|
||||
FROM debian:10
|
||||
|
||||
WORKDIR /app
|
||||
WORKDIR /root
|
||||
|
||||
RUN addgroup eleve
|
||||
|
||||
|
@ -3,7 +3,7 @@ services:
|
||||
app:
|
||||
build: .
|
||||
volumes:
|
||||
- ./config:/app/config
|
||||
- ./config:/root/config
|
||||
- ./home_eleves:/home
|
||||
network_mode: "host"
|
||||
restart: "unless-stopped"
|
||||
|
@ -1,9 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
HOME_BASE="/home"
|
||||
USERS_LIST="/app/config/users.txt"
|
||||
PASSWD_LIST="/app/config/passwords.txt"
|
||||
CUSTOM_SCRIPT="/app/config/init.sh"
|
||||
USERS_LIST="./config/users.txt"
|
||||
PASSWD_LIST="./config/passwords.txt"
|
||||
|
||||
separator="=" # Must be ascii for cut
|
||||
forbidden_chars=". / : # = \ "
|
||||
@ -27,9 +26,19 @@ echo " Create users (and passwords if needed) as in $USERS_LIST"
|
||||
genPassowrd () {
|
||||
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
|
||||
touch "$PASSWD_LIST"
|
||||
fi
|
||||
|
||||
sanitizeFile "$PASSWD_LIST"
|
||||
sanitizeFile "$USERS_LIST"
|
||||
|
||||
for user in $(cat "$USERS_LIST") ; do
|
||||
if [ -z "$user" ] || [ -n "$(cat $PASSWD_LIST | grep "$user$separator")" ] ; then continue ; fi
|
||||
echo "$user$separator$(genPassowrd 6)" >> $PASSWD_LIST
|
||||
@ -38,7 +47,6 @@ done
|
||||
for line in $(cat $PASSWD_LIST) ; do
|
||||
name="$(echo "$line" | cut -d "$separator" -f 1)"
|
||||
pass="$(echo "$line" | cut -d "$separator" -f 2)"
|
||||
echo $name $pass
|
||||
if [ -z "$name" ] || [ -z "$pass" ] ; then echo "Malformed line skipped: '$line'" ; continue ; fi
|
||||
home="$HOME_BASE/$name"
|
||||
mkdir -p "$home"
|
||||
|
@ -33,3 +33,7 @@ Pour suivre la progression des élèves, on utilise le script suivant.
|
||||
```
|
||||
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