#!/bin/bash if [ "$#" -ne 1 && "$#" -ne 2 ] ; then echo -e "usage : $0 [USER]\n Generate the exercice for a class.\nFILE must be a list containing identifiers (names) and passwords for each student, separated by a '='.\n Ex:\n Jean-claude-dus=mot_de_passe\n Jean-dus-claude=passe_de_mot\n Claude-jean-dus=azerty\nIf a USER is provided, init will only be run for that user (useful to add a student mid-class, reset a session when something went horribly wrong, or if a student finished early and wants to start over.\n\nThis file must be executed from the same folder as the files gen_arbo.sh, gen_seed.sh and gen_enonces.sh.\nFolders will be created in this directory, containing the exercices, their correction and the grades of the students." exit 1; fi home=/home #Little debug option for one of the devs. If we forgot to remove it before deployment, feel free to erase this line. if [ $USER = karsaell ] ; then home=root ; fi names=$(cut -d '=' -f 1 $1) if [ "$#" -eq 2 ] ; then names=$(grep $2 $1 | cut -d '=' -f 1) if [ -z $names ] ; then echo "Error : no user named $2 found in $1" exit 1 fi fi for name in $names ; do ./gen_arbo.sh $home/$name $name ./gen_seed.sh $home/$name 4 0 5 1 $name seeds ./gen_enonces.sh seeds $name /dev/null $home/$name $1 done