]> mj.ucw.cz Git - moe.git/commitdiff
Reworked the installation machinery.
authorMartin Mares <mj@ucw.cz>
Sun, 10 Jun 2007 14:20:51 +0000 (16:20 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 10 Jun 2007 14:20:51 +0000 (16:20 +0200)
TODO
bin/mo-create-contestants
bin/mo-create-logins
bin/mo-create-public
bin/mo-create-submit [new file with mode: 0755]
bin/mo-create-testusers
bin/mo-install
config
template/.profile

diff --git a/TODO b/TODO
index 59d7b63cc285d7cc18615afc01ac4f25da060d1a..b9039fdc4b688910f94d362226bb67e43c8469b6 100644 (file)
--- 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
index 5a101b9a806ef85f480958bc08c4e5d1791dbae9..f2dd8d27357c70612c7caa840f02450231c48779 100755 (executable)
@@ -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
index 765c5653c5cd9dcb4d0500aa88356ca4caec56d0..461b796d03a3160ad1075732bd39e81c201bcb1d 100755 (executable)
@@ -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
   ;;
index 24766fd2cf295cdc04a4092681cf3ccd7641b63b..ff91f92ee1b4f69c82c99e934d35a4a03905225c 100755 (executable)
@@ -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 (executable)
index 0000000..d274815
--- /dev/null
@@ -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
index 0ff2c8c90ba09d51d1ca09a9fd1e5ead136cee79..7b32a6a2135b1cb4b10d0419ef501009ef5e045f 100755 (executable)
@@ -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
index f580d69e8962c1689b84056e57b22c7124d6cd92..8d7556c016678e80332946f2746a0b4e2a671568 100755 (executable)
@@ -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 ba37efce143a516dfd047f20dd7aca70bb91446d..83cdd0643ae6d7e863302c8e1735e40d25a90851 100644 (file)
--- 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:
index 19b6f66ee563957c57734c0e75842ec92d9dda2d..78e70b2cbf146cc21e7a2b5df0f73d1efc46fbc3 100644 (file)
@@ -1,2 +1,2 @@
-export MO_ROOT=/aux/mo/public
+export MO_ROOT=/mo/public
 PATH=$PATH:$MO_ROOT/bin