From: Milan Straka Date: Sat, 5 Jun 2004 16:27:09 +0000 (+0000) Subject: mo-create-logins - generates logins and passwords for eval and users X-Git-Tag: python-dummy-working~449 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=3ee84a61340017dccf73f53194cd7ec4c7ec838b;p=moe.git mo-create-logins - generates logins and passwords for eval and users mo-install - uses new mo-create-public rest - changed /etc/passwd traversing by `mo-get-users` --- diff --git a/bin/mo-create-contestants b/bin/mo-create-contestants index 28f6415..5a101b9 100755 --- a/bin/mo-create-contestants +++ b/bin/mo-create-contestants @@ -10,7 +10,7 @@ rm -rf users mkdir users cd users -for a in `awk = '$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 index 0000000..3dfa530 --- /dev/null +++ b/bin/mo-create-logins @@ -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 diff --git a/bin/mo-create-packages b/bin/mo-create-packages index 4a163c1..bad77cd 100755 --- a/bin/mo-create-packages +++ b/bin/mo-create-packages @@ -11,7 +11,7 @@ rm -rf users2 mkdir users2 cd users2 -for a in `awk = '$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-install b/bin/mo-install index 8df7159..38ef18e 100755 --- a/bin/mo-install +++ b/bin/mo-install @@ -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 )