-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,314 changed files
with
162,427 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,76 @@ | ||
# uoj | ||
Universal Online Judge | ||
# Universal Online Judge | ||
|
||
## Installation | ||
First please download [JDK7u76](http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jdk-7u76-oth-JPR) and [JDK8u31](http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html#jdk-8u31-oth-JPR), and put them to `docker/jdk-7u76-linux-x64.tar.gz` and `docker/jdk-8u31-linux-x64.tar.gz`. | ||
|
||
Next, you can run the following command in your terminal: | ||
```sh | ||
./install | ||
``` | ||
If everything goes well, you will see `Successfully built <image-id>` in the last line of the output. | ||
|
||
To start your UOJ main server, please run: | ||
```sh | ||
docker run -it -p 80:80 -p 3690:3690 <image-id> | ||
``` | ||
If you are using docker on Mac OS, you could possibly this alternative command: | ||
```sh | ||
docker run -it -p 80:80 -p 3690:3690 --cap-add SYS_PTRACE <image-id> | ||
``` | ||
|
||
The default hostname of UOJ is `local_uoj.ac`, so you need to modify your host file in your OS in order to map `127.0.0.1` to `local_uoj.ac`. (It is `/etc/hosts` on Linux.) After that, you can access UOJ in your web browser. | ||
|
||
If you need a super user, please register a user and change its `usergroup` to "<samp>S</samp>" in the table `user_info`. Run | ||
```sh | ||
mysql app_uoj233 -u root -p | ||
``` | ||
to login mysql in the terminal. | ||
|
||
Notice that if you want only one judge client, then everything is ok now. But if you want more judge clients, you need to set up them one by one. First run: | ||
```sh | ||
./config_judge_client | ||
``` | ||
and answer the questions. | ||
|
||
* uoj container id: the container id of the main server. | ||
* uoj ip: the ip address of the main server. | ||
* judger name: you can take a name you like, such as judger, judger\_2, very\_strong\_judger. (containing special characters may cause unforeseeable consequence.) | ||
|
||
After that, a sql command is given, we will talk about it later. | ||
|
||
Next, we need to run: | ||
```sh | ||
./install_judge_client | ||
``` | ||
to build the docker image. If you want to run judger at the same server, you just need to run | ||
```sh | ||
docker run -it <image-id> | ||
``` | ||
And, you need to complete the sql command given just now with the ip address of the judger docker, and modify the database. To someone who do not know how to get the ip address of a docker container, here is the answer: | ||
```sh | ||
docker inspect --format '{{ .NetworkSettings.IPAddress }}' <container-id> | ||
``` | ||
|
||
Or, if you want to run judger at different server, you need to copy the image to the other server, and run | ||
```sh | ||
docker run -p 2333 -it <image-id> | ||
``` | ||
Similarly, you need to complete the sql command and modify the database. This time, you need to fill with the ip address of the host machine of the judger docker. | ||
|
||
You may meet many difficulties during the installation. Good luck and have fun! | ||
|
||
## Notes | ||
|
||
mysql default password: root | ||
|
||
local\_main\_judger password: judger | ||
|
||
You can change the default hostname and something else in `/var/www/uoj/app/.config.php`. However, not all the config is here, haha. | ||
|
||
## More Documentation | ||
As you know, my Yingyu is not very hao. Suoyi only the README file is En(Chi)nglish for internationalization. | ||
|
||
More documentation is here: [https://vfleaking.github.io/uoj/](https://vfleaking.github.io/uoj/) | ||
|
||
## License | ||
MIT License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/python | ||
|
||
import sys, json, random, os | ||
|
||
def translate(filename, target, tab): | ||
with open(filename, 'r') as f: | ||
content = f.read() | ||
for k, v in tab.items(): | ||
content = content.replace('__' + k + '__', v) | ||
with open(target, 'w') as f: | ||
f.write(content) | ||
|
||
cid = raw_input('uoj container id: ') | ||
ip = raw_input('uoj ip: ') | ||
name = raw_input('judger name: ') | ||
|
||
os.system("docker cp " + cid + ":/home/local_main_judger/judge_client/.conf.json docker/judge_client/conf.json") | ||
|
||
with open('docker/judge_client/conf.json', 'r') as f: | ||
conf = json.load(f) | ||
|
||
conf['uoj_host'] = ip | ||
conf['judger_name'] = name | ||
conf['judger_password'] = ''.join(random.choice('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') for i in range(32)) | ||
|
||
with open('docker/judge_client/conf.json', 'w') as f: | ||
json.dump(conf, f, indent=4, separators=(',', ': ')) | ||
print >>f | ||
|
||
translate_table = { | ||
'svn_cert': '--username %s --password %s' % (conf['svn_username'], conf['svn_password']), | ||
'uoj_host': ip | ||
} | ||
|
||
translate('docker/judge_client/install', 'docker/judge_client/cur_install', translate_table) | ||
|
||
print "please modify the database after getting the judger server ready:" | ||
print "insert into judger_info (judger_name, password, ip) values ('%s', '%s', '__judger_ip_here__');" % (name, conf['judger_password']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM vfleaking/uoj | ||
MAINTAINER vfleaking vfleaking@163.com | ||
COPY docker/sources.list /etc/apt/sources.list | ||
COPY uoj/1 /root/uoj_1 | ||
COPY judge_client/1 /root/judge_client_1 | ||
|
||
COPY docker/new_problem.sh \ | ||
docker/post-commit.sh \ | ||
docker/uoj-passwd \ | ||
docker/uoj-post-commit \ | ||
docker/gen-uoj-config.php \ | ||
docker/app_uoj233.sql \ | ||
/root/ | ||
|
||
COPY docker/jdk-7u76-linux-x64.tar.gz \ | ||
docker/jdk-8u31-linux-x64.tar.gz \ | ||
/home/local_main_judger/ | ||
|
||
COPY docker/install /root/install | ||
|
||
RUN cd /root && php gen-uoj-config.php && chmod +x install | ||
RUN cd /root && ./install && rm * -rf | ||
|
||
COPY docker/up /root/up | ||
|
||
RUN chmod +x /root/up | ||
|
||
EXPOSE 80 3690 | ||
|
||
CMD /root/up |
Oops, something went wrong.