]> mj.ucw.cz Git - eval.git/blob - bin/mo-create-logins
Comment on obsolescence of this script.
[eval.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 expire=$((`date +%s` / 86400 - 1))
17
18 case $mode in
19   eval)
20     echo -n Enter password for evaluation users:
21     read passwd
22     passwd=`echo $passwd | bin/md5crypt`
23     gid=$uid
24     tgid=$(($gid+1))
25     rgid=$(($gid+2))
26     echo $EVAL_USER:x:$uid:$gid:MO Evaluator:$MO_ROOT/eval/eval:/bin/bash >> etcpasswd
27     echo $EVAL_USER:$passwd:$expire:0:99999:7:::                >> etcshadow
28     echo $EVAL_GROUP:x:$gid:                                    >> etcgroup
29     echo $TEST_GROUP:x:$tgid:$EVAL_USER                         >> etcgroup
30
31     if [ -n "$REMOTE_SUBMIT" ] ; then
32       uid=$(($uid + 1))
33       echo $REMOTE_SUBMIT_USER:x:$uid:$rgid:MO Submitter:$MO_ROOT/eval/submit:/bin/bash >> etcpasswd
34       echo $REMOTE_SUBMIT_USER:$passwd:$expire:0:99999:7:::                             >> etcshadow
35       echo $REMOTE_SUBMIT_GROUP:x:$rgid:                                                >> etcgroup
36     fi
37
38     tuid=$(($uid + 1))
39     for tester in $TEST_USERS; do
40       echo $tester:x:$tuid:$tgid:MO Tester `expr $tuid - $uid`:$MO_ROOT/eval/$tester:/bin/bash  >> etcpasswd
41       echo $tester:$passwd:$expire:0:99999:7:::                         >> etcshadow
42       tuid=$(($tuid + 1))
43     done
44   ;;
45
46   users)
47 #   if [ -f logins.tex ]; then echo "File logins.tex exists! Bailing out!"; exit 1; fi
48     cat > logins.tex <<- EOF
49         \\nopagenumbers
50         \\voffset=-1.5cm\\vsize=280mm\\hoffset=-0.75cm\\advance\\hsize by 3cm
51         \\raggedright\\parindent=0pt
52         \\font\next=cstt17\next
53         \\def\\user#1#2{\\vbox to 4.5cm{\\hsize=6cm\\vss\\vss{\\font\\next=csti17\\next Contest, day 1}\\vss\\vss#1\\vss#2\\vss\\vss}}
54         \\leavevmode
55         EOF
56     
57     bin/mo-get-users --full | while read user name; do
58       passwd=`apg -n1 -m6 -Mncl | cut -d" " -f1 | tr l1O0 '@*?-' `
59       passwd_md5=`echo $passwd | bin/md5crypt`
60       echo $user:x:$uid:$uid:$name:$MO_ROOT/users/$user/$user:/bin/bash                 >> etcpasswd
61       echo $user:x:$uid:                                                                >> etcgroup
62       echo $user:$passwd_md5:`expr \`date +%s\` / 86400 - 1`:0:99999:7:::               >> etcshadow
63       echo "\\user{$user}{$passwd}"                                                     >> logins.tex
64       uid=$(($uid + 1))
65     done
66
67     cat >> logins.tex <<- EOF
68         \\vfil
69         \\bye
70         EOF
71   ;;
72 esac