]> mj.ucw.cz Git - moe.git/blob - bin/mo-create-logins
Bug fixes.
[moe.git] / bin / mo-create-logins
1 #!/bin/bash
2
3 [ -f config ] || { echo "Missing config file, check cwd." ; exit 1 ; }
4 set -e
5 . config
6
7 mode=$1
8
9 case "$mode" in
10   eval) uid=$EVAL_UID_MIN;;
11   users) uid=$CT_UID_MIN;;
12   *) echo "Usage: $0 [eval|users]!"; exit 1;;
13 esac
14
15 >>etcshadow >>etcpasswd >>etcgroup
16
17 case $mode in
18   eval)
19     echo -n Enter password for mo-eval:
20     read passwd
21     passwd=`echo $passwd | bin/md5crypt`
22     echo $EVAL_USER:x:$uid:$uid:MO Evaluator:$MO_ROOT/eval/$EVAL_USER:/bin/bash >> etcpasswd
23     echo $EVAL_GROUP:x:$uid:                                                    >> etcgroup
24     echo $EVAL_USER:$passwd:$((`date +%s` / 86400 - 1)):0:99999:7:::            >> etcshadow
25     tuid=$(($uid + 1))
26
27     for tester in $TEST_USERS; do
28       echo $tester:x:$tuid:$uid:MO Tester `expr $tuid - $uid`:$MO_ROOT/eval/$tester:/bin/bash   >> etcpasswd
29       echo $tester:$passwd:$((`date +%s` / 86400 - 1)):0:99999:7:::                             >> etcshadow
30       tuid=$(($tuid + 1))
31     done
32   ;;
33
34   users)
35 #   if [ -f logins.tex ]; then echo "File logins.tex exists! Bailing out!"; exit 1; fi
36     cat > logins.tex <<- EOF
37         \\nopagenumbers
38         \\font\\next=cstt17\\next
39         \\raggedright
40         \\parindent=0pt
41         \\def\\user#1#2{\\vbox to 3cm{\\hsize=5cm \\vss#1\\vss#2\\vss}}
42         \\leavevmode
43         EOF
44     
45     bin/mo-get-users --full | while read user name; do
46       passwd=`apg -n1 -m6 -Mncl | cut -d" " -f1 | tr l1O0 '@*?-' `
47       passwd_md5=`echo $passwd | bin/md5crypt`
48       echo $user:x:$uid:$uid:$name:$MO_ROOT/users/$user/$user:/bin/bash                 >> etcpasswd
49       echo $user:x:$uid:                                                                >> etcgroup
50       echo $user:$passwd_md5:`expr \`date +%s\` / 86400 - 1`:0:99999:7:::               >> etcshadow
51       echo "\\user{$user}{$passwd}"                                                     >> logins.tex
52       uid=$(($uid + 1))
53     done
54
55     cat >> logins.tex <<- EOF
56         \\vfil
57         \\bye
58         EOF
59   ;;
60 esac