]> mj.ucw.cz Git - eval.git/commitdiff
mo-create-logins - generates logins and passwords for eval and users
authorMilan Straka <fox@ucw.cz>
Sat, 5 Jun 2004 16:27:09 +0000 (16:27 +0000)
committerMilan Straka <fox@ucw.cz>
Sat, 5 Jun 2004 16:27:09 +0000 (16:27 +0000)
mo-install - uses new mo-create-public

rest - changed /etc/passwd traversing by `mo-get-users`

bin/mo-create-contestants
bin/mo-create-logins [new file with mode: 0755]
bin/mo-create-packages
bin/mo-install

index 28f6415889c73a79a0fabbe69452a3e53dd5ff68..5a101b9a806ef85f480958bc08c4e5d1791dbae9 100755 (executable)
@@ -10,7 +10,7 @@ rm -rf users
 mkdir users
 cd users
 
-for a in `awk </etc/passwd -F: '{ if ($3 >= '$CT_UID_MIN' && $3 <= '$CT_UID_MAX') print $1; }'` ; do
+for a in `cd $H && bin/mo-get-users` ; do
        echo "Creating $a"
        mkdir $a $a/$a
        chown root.$a $a
diff --git a/bin/mo-create-logins b/bin/mo-create-logins
new file mode 100755 (executable)
index 0000000..3dfa530
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+[ -f config ] || { echo "Missing config file, check cwd." ; exit 1 ; }
+set -e
+. config
+
+mode=$1
+
+case "$mode" in
+  eval) uid=$EVAL_UID_MIN;;
+  users) uid=$CT_UID_MIN;;
+  *) echo "Usage: $0 [eval|users]!"; exit 1;;
+esac
+
+>etcshadow >etcpasswd >etcgroup
+
+case $mode in
+  eval)
+    echo -n Zadejte heslo pro mo-eval:
+    read passwd
+    passwd=`echo $passwd | bin/md5crypt`
+    echo $EVAL_USER:x:$uid:$uid:MO Evaluator:$MO_ROOT/eval/$EVAL_USER:/bin/bash >> etcpasswd
+    echo $EVAL_GROUP:x:$uid:                                                   >> etcgroup
+    echo $EVAL_USER:$passwd:$((`date +%s` / 86400 - 1)):0:99999:7:::           >> etcshadow
+    tuid=$(($uid + 1))
+
+    for tester in $TEST_USERS; do
+      echo $tester:x:$tuid:$uid:MO Tester `expr $tuid - $uid`:$MO_ROOT/eval/$tester:/bin/bash  >> etcpasswd
+      echo $tester:$passwd:$((`date +%s` / 86400 - 1)):0:99999:7:::                            >> etcshadow
+      tuid=$(($tuid + 1))
+    done
+  ;;
+
+  users)
+#   if [ -f logins.tex ]; then echo "File logins.tex exists! Bailing out!"; exit 1; fi
+    cat > logins.tex <<- EOF
+       \\nopagenumbers
+       \\font\\next=cstt17\\next
+       \\raggedright
+       \\parindent=0pt
+       \\def\\user#1#2{\\vbox to 3cm{\\hsize=5cm \\vss#1\\vss#2\\vss}}
+       \\leavevmode
+       EOF
+    
+    bin/mo-get-users --full | while read user name; do
+      passwd=`apg -n1 -m6 -Mncl | cut -d" " -f1 | tr l1O0 '@*?-' `
+      passwd_md5=`echo $passwd | bin/md5crypt`
+      echo $user:x:$uid:$uid:$name:$MO_ROOT/users/$user/$user:/bin/bash                        >> etcpasswd
+      echo $user:x:$uid:                                                               >> etcgroup
+      echo $user:$passwd_md5:`expr \`date +%s\` / 86400 - 1`:0:99999:7:::              >> etcshadow
+      echo "\\user{$user}{$passwd}"                                                    >> logins.tex
+      uid=$(($uid + 1))
+    done
+
+    cat >> logins.tex <<- EOF
+       \\vfil
+       \\bye
+       EOF
+  ;;
+esac
index 4a163c1346957e16860559c3acaf1d5cb3383086..bad77cd84d922f69ec783efbc74b412f287ee79a 100755 (executable)
@@ -11,7 +11,7 @@ rm -rf users2
 mkdir users2
 cd users2
 
-for a in `awk </etc/passwd -F: '{ if ($3 >= '$CT_UID_MIN' && $3 <= '$CT_UID_MAX') print $1; }'` ; do
+for a in `cd $H && bin/mo-get-users` ; do
        echo "Creating $a"
        mkdir $a $a/$a
        chown root.$a $a
index 8df71599790eb119a21a0b460cf07e46132432e5..38ef18e450020cdce9de83caffe69267bc104fd0 100755 (executable)
@@ -25,16 +25,11 @@ chmod 700 $EVAL_USER
 
 ( cd $EVAL_USER ; bin/mo-create-testusers )
 
-# common
+# create public
 cd $MO_ROOT
 echo "Creating public"
 rm -rf public
 mkdir public
-cd public
-cp -a $H/bin $H/config .
-mkdir problems
-cp -a $H/public/* bin/
-chmod +x bin/*
-cd ..
-chown -R $EVAL_USER.$EVAL_GROUP public
-chmod 755 public
+
+# populate public
+( cd $EVAL_USER ; bin/mo-create-public )