From: Martin Mares Date: Sun, 10 Jun 2007 14:20:51 +0000 (+0200) Subject: Reworked the installation machinery. X-Git-Tag: python-dummy-working~371 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=9306a593e097b30b55196f0fb7dd7c189389a0d3;p=moe.git Reworked the installation machinery. --- diff --git a/TODO b/TODO index 59d7b63..b9039fd 100644 --- a/TODO +++ b/TODO @@ -9,6 +9,10 @@ Environment ~~~~~~~~~~~ fpc: add switch -gl (runtime errors write line#) +Installer: +- mo-install: reduce what gets copied to mo-eval home +- update group permissions + New submitter: - Checking of contest time (and per-contestant exceptions) - Keeping history and pruning status files diff --git a/bin/mo-create-contestants b/bin/mo-create-contestants index 5a101b9..f2dd8d2 100755 --- a/bin/mo-create-contestants +++ b/bin/mo-create-contestants @@ -16,6 +16,16 @@ for a in `cd $H && bin/mo-get-users` ; do chown root.$a $a chmod 750 $a cp -a `find $H/template -type f -name ".*"` $a/$a/ + + if [ -n "$REMOTE_SUBMIT" ] ; then + M=$a/$a/.mo + mkdir $M + cp $H/certs/$a-cert.pem $M/cert.pem + cp $H/certs/$a-key.pem $M/key.pem + chmod 600 $M/key.pem + cp $H/certs/ca-cert.pem $M/ + fi + chown $a.$a $a/$a -R chmod 700 $a/$a done diff --git a/bin/mo-create-logins b/bin/mo-create-logins index 765c565..461b796 100755 --- a/bin/mo-create-logins +++ b/bin/mo-create-logins @@ -13,20 +13,32 @@ case "$mode" in esac >>etcshadow >>etcpasswd >>etcgroup +expire=$((`date +%s` / 86400 - 1)) case $mode in eval) - echo -n Enter password for mo-eval: + echo -n Enter password for evaluation users: 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)) + gid=$uid + tgid=$(($gid+1)) + rgid=$(($gid+2)) + echo $EVAL_USER:x:$uid:$gid:MO Evaluator:$MO_ROOT/eval/eval:/bin/bash >> etcpasswd + echo $EVAL_USER:$passwd:$expire:0:99999:7::: >> etcshadow + echo $EVAL_GROUP:x:$gid: >> etcgroup + echo $TEST_GROUP:x:$tgid:$EVAL_USER >> etcgroup + + if [ -n "$REMOTE_SUBMIT" ] ; then + uid=$(($uid + 1)) + echo $REMOTE_SUBMIT_USER:x:$uid:$rgid:MO Submitter:$MO_ROOT/eval/submit:/bin/bash >> etcpasswd + echo $REMOTE_SUBMIT_USER:$passwd:$expire:0:99999:7::: >> etcshadow + echo $REMOTE_SUBMIT_GROUP:x:$rgid: >> etcgroup + fi + 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 + echo $tester:x:$tuid:$tgid:MO Tester `expr $tuid - $uid`:$MO_ROOT/eval/$tester:/bin/bash >> etcpasswd + echo $tester:$passwd:$expire:0:99999:7::: >> etcshadow tuid=$(($tuid + 1)) done ;; diff --git a/bin/mo-create-public b/bin/mo-create-public index 24766fd..ff91f92 100755 --- a/bin/mo-create-public +++ b/bin/mo-create-public @@ -7,7 +7,7 @@ set -e echo "Populating $MO_ROOT/public" H=`pwd` cd $MO_ROOT/public -rm -rf bin +rm -rf bin submit sed 's/^TEST_USER=/#TEST_USER=/' <$H/config >config @@ -17,6 +17,14 @@ for a in `cat $H/public/COPY` ; do cp -a $H/$a bin/ done +if [ -n "$REMOTE_SUBMIT" ] ; then + mkdir -p submit + cp $H/submit/{contest,remote-submit,remote-status} submit/ + mkdir -p submit/lib/perl5/{MO,Sherlock} + cp $H/submit/MO/*.pm submit/lib/perl5/MO/ + cp $H/submit/lib/perl5/Sherlock/Object.pm submit/lib/perl5/Sherlock/ +fi + mkdir -p problems if [ `id -u` == 0 ] ; then diff --git a/bin/mo-create-submit b/bin/mo-create-submit new file mode 100755 index 0000000..d274815 --- /dev/null +++ b/bin/mo-create-submit @@ -0,0 +1,29 @@ +#!/bin/bash + +[ -f config ] || { echo "Missing config file, check cwd." ; exit 1 ; } +set -e +. config +[ -n "$REMOTE_SUBMIT" ] || { echo "Remote submit not enabled." ; exit 1 ; } +make + +echo "Creating submit directory" + +H=`pwd` +cd $MO_ROOT/eval/submit +mkdir -p certs +cp $H/certs/server* certs/ +cp $H/certs/ca-cert.pem certs/ + +rm -rf submit +mkdir -p submit +cp $H/submit/submitd submit/ +cp $H/submit/config submit/ + +mkdir -p solutions +for a in `cd $H && bin/mo-get-users` ; do + mkdir -p solutions/$a +done + +mkdir tmp + +chown -R $REMOTE_SUBMIT_USER.$REMOTE_SUBMIT_GROUP $MO_ROOT/eval/submit diff --git a/bin/mo-create-testusers b/bin/mo-create-testusers index 0ff2c8c..7b32a6a 100755 --- a/bin/mo-create-testusers +++ b/bin/mo-create-testusers @@ -13,9 +13,9 @@ for u in $TEST_USERS ; do echo "Creating $u" rm -rf ./$u mkdir $u - chown $u.$EVAL_GROUP $u + chown $u.$TEST_GROUP $u chmod 770 $u - cp $EVAL_USER/bin/box $EVAL_USER/bin/box-$u - chown $u.$EVAL_GROUP $EVAL_USER/bin/box-$u - chmod 4550 $EVAL_USER/bin/box-$u - done + cp eval/bin/box eval/bin/box-$u + chown $u.$EVAL_GROUP eval/bin/box-$u + chmod 4550 eval/bin/box-$u +done diff --git a/bin/mo-install b/bin/mo-install index f580d69..8d7556c 100755 --- a/bin/mo-install +++ b/bin/mo-install @@ -7,23 +7,34 @@ make H=`pwd` -# mo-eval home +# The eval directory cd $MO_ROOT rm -rf eval mkdir eval chgrp $EVAL_GROUP eval -chmod 550 eval +chmod 755 eval cd eval + +# mo-eval home echo "Creating $EVAL_USER" -mkdir $EVAL_USER -cd $EVAL_USER +mkdir eval +cd eval cp -a $H/* . chmod +x bin/* +if [ -d ~/.ssh ] ; then echo "Copying SSH configuration from ~/.ssh" ; cp -a ~/.ssh . ; fi cd .. -chown -R $EVAL_USER.$EVAL_GROUP $EVAL_USER -chmod 700 $EVAL_USER +chown -R $EVAL_USER.$EVAL_GROUP eval +chmod 750 eval + +# testusers +( cd eval && bin/mo-create-testusers ) -( cd $EVAL_USER ; bin/mo-create-testusers ) +# mo-submit home +if [ -n "$REMOTE_SUBMIT" ] ; then + mkdir submit + if [ -d ~/.ssh ] ; then echo "Copying SSH configuration from ~/.ssh" ; cp -a ~/.ssh submit/ ; fi + ( cd $H && bin/mo-create-submit ) +fi # create public cd $MO_ROOT @@ -32,4 +43,4 @@ rm -rf public mkdir public # populate public -( cd eval/$EVAL_USER ; bin/mo-create-public ) +( cd eval/eval ; bin/mo-create-public ) diff --git a/config b/config index ba37efc..83cdd06 100644 --- a/config +++ b/config @@ -3,7 +3,7 @@ # The root of the whole directory hierarchy if [ -z "$MO_ROOT" ] ; then - MO_ROOT=/aux/mo + MO_ROOT=/mo fi # User and group used by the evaluator itself @@ -16,8 +16,10 @@ EVAL_GROUP=mo-eval # with EVAL_USER privileges, but beware, this is INSECURE. #TEST_USER=${TEST_USER:-mo-test1} TEST_USERS="mo-test1 mo-test2" +TEST_GROUP=mo-test -# These values are used when creating logins for eval and contestanst. +# These values are used when creating logins for eval and contestants +# (group id's are from the same range) EVAL_UID_MIN=65000 CT_UID_MIN=65100 CT_UID_MAX=65199 @@ -28,6 +30,11 @@ CT_UID_MAX=65199 # or (if undefined) scans /etc/passwd for users with UID between CT_UID_MIN and CT_UID_MAX. CT_USER_LIST=userlist +# (optional) Use remote submitting +REMOTE_SUBMIT=1 +REMOTE_SUBMIT_USER=mo-submit +REMOTE_SUBMIT_GROUP=mo-submit + ### Per-task configuration variables (default values, override in per-task config) ## Compiler settings: diff --git a/template/.profile b/template/.profile index 19b6f66..78e70b2 100644 --- a/template/.profile +++ b/template/.profile @@ -1,2 +1,2 @@ -export MO_ROOT=/aux/mo/public +export MO_ROOT=/mo/public PATH=$PATH:$MO_ROOT/bin