style(web,install): set repo clone dir as work dir

Clone repository files to /opt, and make this as work dir.
Can save disk space, make folder tidy, and easy to access.
This commit is contained in:
Masco Skray 2019-07-16 10:43:02 +08:00
parent fb6cae057c
commit 28cd4ef8b8
4 changed files with 14 additions and 14 deletions

View File

@ -6,18 +6,18 @@ WORKDIR /opt
#Update apt and install git #Update apt and install git
RUN apt-get update && apt-get install -y git RUN apt-get update && apt-get install -y git
#Clone the latest UOJ Community verison to local #Clone the latest UOJ Community verison to local
RUN git clone https://github.com/UniversalOJ/UOJ-System.git --depth 1 --single-branch ${CLONE_ADDFLAG} RUN git clone https://github.com/UniversalOJ/UOJ-System.git --depth 1 --single-branch ${CLONE_ADDFLAG} uoj
#Install environment and set startup script #Install environment and set startup script
RUN cd UOJ-System/install/bundle && sh install.sh -p && echo "\ RUN cd uoj/install/bundle && sh install.sh -p && echo "\
#!/bin/sh\n\ #!/bin/sh\n\
chown -R mysql:mysql /var/lib/mysql /var/run/mysqld\n\ chown -R mysql:mysql /var/lib/mysql /var/run/mysqld\n\
if [ ! -f \"/var/uoj_data/.UOJSetupDone\" ]; then\n\ if [ ! -f \"/var/uoj_data/.UOJSetupDone\" ]; then\n\
cd /opt/UOJ-System/install/bundle && sh install.sh -i\n\ cd /opt/uoj/install/bundle && sh install.sh -i\n\
fi\n\ fi\n\
service ntp start\n\ service ntp start\n\
service mysql start\n\ service mysql start\n\
service apache2 start\n\ service apache2 start\n\
su local_main_judger -c \"/opt/UOJ-System/judger/judge_client start\"\n\ su local_main_judger -c \"/opt/uoj/judger/judge_client start\"\n\
exec bash\n" >/opt/up && chmod +x /opt/up exec bash\n" >/opt/up && chmod +x /opt/up
ENV LANG=C.UTF-8 TZ=Asia/Shanghai ENV LANG=C.UTF-8 TZ=Asia/Shanghai

View File

@ -39,7 +39,7 @@ setLAMPConf(){
XSendFile On XSendFile On
XSendFilePath /var/uoj_data XSendFilePath /var/uoj_data
XSendFilePath /var/www/uoj/app/storage XSendFilePath /var/www/uoj/app/storage
XSendFilePath /opt/UOJ-System/judger/uoj_judger/include XSendFilePath /opt/uoj/judger/uoj_judger/include
</VirtualHost> </VirtualHost>
UOJEOF UOJEOF
#Enable modules and make UOJ site conf enabled #Enable modules and make UOJ site conf enabled
@ -65,7 +65,7 @@ UOJEOF
setWebConf(){ setWebConf(){
printf "\n\n==> Setting web files\n" printf "\n\n==> Setting web files\n"
#Set webroot path #Set webroot path
ln -sf /opt/UOJ-System/web /var/www/uoj ln -sf /opt/uoj/web /var/www/uoj
chown -R www-data /var/www/uoj/app/storage chown -R www-data /var/www/uoj/app/storage
#Set web config file #Set web config file
php -a <<UOJEOF php -a <<UOJEOF
@ -87,12 +87,12 @@ setJudgeConf(){
mkdir /var/uoj_data && mkdir /var/uoj_data/upload mkdir /var/uoj_data && mkdir /var/uoj_data/upload
chown -R www-data /var/uoj_data && chgrp -R www-data /var/uoj_data chown -R www-data /var/uoj_data && chgrp -R www-data /var/uoj_data
#Compile uoj_judger and set runtime #Compile uoj_judger and set runtime
chown -R local_main_judger /opt/UOJ-System/judger && chgrp -R local_main_judger /opt/UOJ-System/judger chown -R local_main_judger /opt/uoj/judger && chgrp -R local_main_judger /opt/uoj/judger
su local_main_judger <<EOD su local_main_judger <<EOD
ln -s /var/uoj_data /opt/UOJ-System/judger/uoj_judger/data ln -s /var/uoj_data /opt/uoj/judger/uoj_judger/data
cd /opt/UOJ-System/judger && chmod +x judge_client cd /opt/uoj/judger && chmod +x judge_client
cat >uoj_judger/include/uoj_work_path.h <<UOJEOF cat >uoj_judger/include/uoj_work_path.h <<UOJEOF
#define UOJ_WORK_PATH "/opt/UOJ-System/judger/uoj_judger" #define UOJ_WORK_PATH "/opt/uoj/judger/uoj_judger"
#define UOJ_JUDGER_BASESYSTEM_UBUNTU1804 #define UOJ_JUDGER_BASESYSTEM_UBUNTU1804
#define UOJ_JUDGER_PYTHON3_VERSION "3.6" #define UOJ_JUDGER_PYTHON3_VERSION "3.6"
#define UOJ_JUDGER_FPC_VERSION "3.0.4" #define UOJ_JUDGER_FPC_VERSION "3.0.4"
@ -116,7 +116,7 @@ UOJEOF
initProgress(){ initProgress(){
printf "\n\n==> Doing initial config and start service\n" printf "\n\n==> Doing initial config and start service\n"
#Replace password placeholders #Replace password placeholders
sed -i -e "s/_main_judger_password_/$_main_judger_password_/g" -e "s/_judger_socket_password_/$_judger_socket_password_/g" /opt/UOJ-System/judger/.conf.json sed -i -e "s/_main_judger_password_/$_main_judger_password_/g" -e "s/_judger_socket_password_/$_judger_socket_password_/g" /opt/uoj/judger/.conf.json
sed -i -e "s/salt0/$(genRandStr 32)/g" -e "s/salt1/$(genRandStr 16)/g" -e "s/salt2/$(genRandStr 16)/g" -e "s/salt3/$(genRandStr 16)/g" -e "s/_judger_socket_password_/$_judger_socket_password_/g" /var/www/uoj/app/.config.php sed -i -e "s/salt0/$(genRandStr 32)/g" -e "s/salt1/$(genRandStr 16)/g" -e "s/salt2/$(genRandStr 16)/g" -e "s/salt3/$(genRandStr 16)/g" -e "s/_judger_socket_password_/$_judger_socket_password_/g" /var/www/uoj/app/.config.php
#Import judge_client to MySQL database #Import judge_client to MySQL database
service mysql start service mysql start
@ -127,7 +127,7 @@ initProgress(){
service ntp restart service ntp restart
service mysql restart service mysql restart
service apache2 restart service apache2 restart
su local_main_judger -c '/opt/UOJ-System/judger/judge_client start' su local_main_judger -c '/opt/uoj/judger/judge_client start'
#Touch SetupDone flag file #Touch SetupDone flag file
touch /var/uoj_data/.UOJSetupDone touch /var/uoj_data/.UOJSetupDone
printf "\n\n***Installation complete. Enjoy!***\n" printf "\n\n***Installation complete. Enjoy!***\n"

View File

@ -27,7 +27,7 @@
$download_name = "problem_$id.zip"; $download_name = "problem_$id.zip";
break; break;
case 'testlib.h': case 'testlib.h':
$file_name = "/opt/UOJ-System/judger/uoj_judger/include/testlib.h"; $file_name = "/opt/uoj/judger/uoj_judger/include/testlib.h";
$download_name = "testlib.h"; $download_name = "testlib.h";
break; break;
default: default:

View File

@ -1,7 +1,7 @@
<?php <?php
global $uojSupportedLanguages, $uojMainJudgerWorkPath; global $uojSupportedLanguages, $uojMainJudgerWorkPath;
$uojSupportedLanguages = array('C', 'C++', 'C++11', 'Java8', 'Java11', 'Pascal', 'Python2', 'Python3'); $uojSupportedLanguages = array('C', 'C++', 'C++11', 'Java8', 'Java11', 'Pascal', 'Python2', 'Python3');
$uojMainJudgerWorkPath = "/opt/UOJ-System/judger/uoj_judger"; $uojMainJudgerWorkPath = "/opt/uoj/judger/uoj_judger";
function authenticateJudger() { function authenticateJudger() {
if (!is_string($_POST['judger_name']) || !is_string($_POST['password'])) { if (!is_string($_POST['judger_name']) || !is_string($_POST['password'])) {