Unterschiede zwischen den Revisionen 1 und 4 (über 3 Versionen hinweg)
Revision 1 vom 2014-08-19 11:34:39
Größe: 532
Kommentar:
Revision 4 vom 2014-08-19 12:09:48
Größe: 1240
Kommentar:
Gelöschter Text ist auf diese Art markiert. Hinzugefügter Text ist auf diese Art markiert.
Zeile 4: Zeile 4:
cat students.csv | while read line; do #!/bin/bash
Zeile 6: Zeile 6:
        NACHNAME=$(echo $line | cut -d";" -f1);
        VORNAME=$(echo $line| cut -d";" -f2);
ZWISCHENERGEBNIS=`tempfile`
Zeile 9: Zeile 8:
        NACHNAME_KURZ=${NACHNAME:0:3}
        VORNAME_KURZ=${VORNAME:0:3}
cat students.csv | while read line; do
Zeile 12: Zeile 10:
        LOGIN=$(echo ${NACHNAME_KURZ}${VORNAME_KURZ} | iconv -f UTF-8 -t ASCII//TRANSLIT | tr A-Z a-z);         ALREADY_EXISTS="START"
Zeile 14: Zeile 12:
        ALREADY_EXISTS=$(getent passwd $LOGIN 1>/dev/null && echo ALREADY_EXISTS);         NACHNAME=$(echo $line | cut -d";" -f1 | cut -d " " -f1 | cut -d "-" -f1);
        VORNAME=$(echo $line| cut -d";" -f2 | cut -d " " -f1 | cut -d "-" -f1);
Zeile 16: Zeile 15:
        echo "$line;$LOGIN;`pwgen -v 8 1` !!! $ALREADY_EXISTS !!!";
done
        i=3;
        while [ ! -z "$ALREADY_EXISTS" ]; do
                NACHNAME_KURZ=${NACHNAME:0:3}
                VORNAME_KURZ=${VORNAME:0:$i}

                LOGIN=$(echo ${NACHNAME_KURZ}${VORNAME_KURZ} | iconv -f UTF-8 -t ASCII//TRANSLIT | tr A-Z a-z);

                ALREADY_EXISTS=$(getent passwd $LOGIN 1>/dev/null && echo "!!! ALREADY_EXISTS !!!");
                i=$(($i+1));
        done

        echo "$line;$LOGIN;`pwgen -v 8 1` $ALREADY_EXISTS";
done | tee $ZWISCHENERGEBNIS


DUPLICATES=`cat $ZWISCHENERGEBNIS | while read line; do

        LOGIN=$(echo $line | cut -d";" -f7);
        grep -v "$line" $ZWISCHENERGEBNIS | grep "$LOGIN" 1>/dev/null && echo $LOGIN;

done | uniq | sort`

if [ ! -z "$DUPLICATES" ]; then
        echo
        echo "Doppelte Logins innerhalb dieser Liste:"
        echo
        echo -e $DUPLICATES
fi

rm -f $ZWISCHENERGEBNIS

Benutzer-Import in GOsa²

ZWISCHENERGEBNIS=`tempfile`

cat students.csv | while read line; do

        ALREADY_EXISTS="START"

        NACHNAME=$(echo $line | cut -d";" -f1 | cut -d " " -f1 | cut -d "-" -f1);
        VORNAME=$(echo $line| cut -d";" -f2 | cut -d " " -f1 | cut -d "-" -f1);

        i=3;
        while [ ! -z "$ALREADY_EXISTS" ]; do
                NACHNAME_KURZ=${NACHNAME:0:3}
                VORNAME_KURZ=${VORNAME:0:$i}

                LOGIN=$(echo ${NACHNAME_KURZ}${VORNAME_KURZ} | iconv -f UTF-8 -t ASCII//TRANSLIT | tr A-Z a-z);

                ALREADY_EXISTS=$(getent passwd $LOGIN 1>/dev/null && echo "!!! ALREADY_EXISTS !!!");
                i=$(($i+1));
        done

        echo "$line;$LOGIN;`pwgen -v 8 1`   $ALREADY_EXISTS";
done | tee $ZWISCHENERGEBNIS


DUPLICATES=`cat $ZWISCHENERGEBNIS | while read line; do

        LOGIN=$(echo $line | cut -d";" -f7);
        grep -v "$line" $ZWISCHENERGEBNIS | grep "$LOGIN" 1>/dev/null && echo $LOGIN;

done | uniq | sort`

if [ ! -z "$DUPLICATES" ]; then
        echo
        echo "Doppelte Logins innerhalb dieser Liste:"
        echo
        echo -e $DUPLICATES
fi

rm -f $ZWISCHENERGEBNIS

IT-Zukunft Schule: Technik/Nutzungshinweise/BenutzerImport (zuletzt geändert am 2023-08-29 20:39:10 durch MikeGabriel)