From d92f7b11775f18c1da9df0d8045eff2acd7bace3 Mon Sep 17 00:00:00 2001 From: Masco Skray Date: Mon, 15 Jul 2019 16:32:05 +0800 Subject: [PATCH] fix(install): mend bundle installation scripts With thesedays' modify, installation scripts are not working properly. Now do some modify, and set the default workdir to /opt. --- install/bundle/Dockerfile | 13 ++++++----- install/bundle/install.sh | 48 +++++++++++---------------------------- 2 files changed, 20 insertions(+), 41 deletions(-) diff --git a/install/bundle/Dockerfile b/install/bundle/Dockerfile index 6032e4b..3dac1e1 100644 --- a/install/bundle/Dockerfile +++ b/install/bundle/Dockerfile @@ -2,23 +2,24 @@ FROM ubuntu:18.04 MAINTAINER MascoSkray ARG CLONE_ADDFLAG +WORKDIR /opt #Update apt and install git RUN apt-get update && apt-get install -y git #Clone the latest UOJ Community verison to local -RUN cd ~ && 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} #Install environment and set startup script -RUN cd ~/UOJ-System/install/bundle && sh install.sh -p && echo "\ +RUN cd UOJ-System/install/bundle && sh install.sh -p && echo "\ #!/bin/sh\n\ chown -R mysql:mysql /var/lib/mysql /var/run/mysqld\n\ -if [ ! -f \"/var/svn/.UOJSetupDone\" ]; then\n\ - cd ~/UOJ-System/install/bundle && sh install.sh -i\n\ +if [ ! -f \"/var/uoj_data/.UOJSetupDone\" ]; then\n\ + cd /opt/UOJ-System/install/bundle && sh install.sh -i\n\ fi\n\ service ntp start\n\ service mysql start\n\ service apache2 start\n\ su local_main_judger -c \"/opt/UOJ-System/judger/judge_client start\"\n\ -exec bash\n" >/root/up && chmod +x /root/up +exec bash\n" >/opt/up && chmod +x /opt/up ENV LANG=C.UTF-8 TZ=Asia/Shanghai EXPOSE 80 3690 -CMD /root/up +CMD /opt/up diff --git a/install/bundle/install.sh b/install/bundle/install.sh index c52f311..9b6c81e 100644 --- a/install/bundle/install.sh +++ b/install/bundle/install.sh @@ -16,30 +16,11 @@ getAptPackage(){ #Update apt sources and install dpkg -s gnupg 2>/dev/null || (apt-get update && apt-get install -y gnupg) echo "deb http://ppa.launchpad.net/stesie/libv8/ubuntu bionic main" | tee /etc/apt/sources.list.d/stesie-libv8.list && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D858A0DF - apt-get update && apt-get install -y vim ntp zip unzip curl wget apache2 libapache2-mod-xsendfile libapache2-mod-php php php-dev php-pear php-zip php-mysql php-mbstring mysql-server cmake fp-compiler re2c libv8-7.5-dev libyaml-dev python python3 python3-requests + apt-get update && apt-get install -y vim ntp zip unzip curl wget apache2 libapache2-mod-xsendfile libapache2-mod-php php php-dev php-pear php-zip php-mysql php-mbstring mysql-server cmake fp-compiler re2c libv8-7.5-dev libyaml-dev python python3 python3-requests openjdk-8-jdk openjdk-11-jdk #Install PHP extensions printf "/opt/libv8-7.5\n\n" | pecl install v8js yaml } -getOracleJDK(){ - printf "\n\n==> Getting JDK runtime files\n" - #Add judger user - useradd -m local_main_judger && usermod -a -G www-data local_main_judger - #Set Oracle JDK do not track usage - mkdir -p /etc/oracle/java/ && echo 'com.oracle.usagetracker.track.last.usage=false' >/etc/oracle/java/usagetracker.properties - #Get newest jdk dist file - JDK_MIRROR_LINK=https://build.funtoo.org/distfiles/oracle-java/ - curl -s ${JDK_MIRROR_LINK} | grep -oP '>jdk-[7,8].*-linux-x64.tar' | sed -e 's/[\",>]//g' -e 's/-linux-x64.tar//g' >jdkdist.list - wget --progress=dot:giga ${JDK_MIRROR_LINK}$(sed -n '1p' jdkdist.list)-linux-x64.tar.gz ${JDK_MIRROR_LINK}$(sed -n '$p' jdkdist.list)-linux-x64.tar.gz - #Change compiler version to faq.php - sed -i -e 's/Ubuntu Linux 14.04 LTS x64/Ubuntu Linux 18.04 LTS x64/' \ - -e 's/g++ 4.8.4/g++ 7.3.0/' -e 's/gcc 4.8.4/gcc 7.3.0/' -e 's/fpc 2.6.2/fpc 3.0.4/' -e 's/Python 2.7和3.4/Python 2.7和3.6/' \ - -e "s/jdk-7u76/$(sed -n '1p' jdkdist.list)/g" -e "s/jdk-8u31/$(sed -n '$p' jdkdist.list)/g" ../../uoj/1/app/controllers/faq.php - #Move jdk file to judger user root - chown local_main_judger jdkdist.list jdk-*-linux-x64.tar.gz - mv jdkdist.list jdk-*-linux-x64.tar.gz /home/local_main_judger/ -} - setLAMPConf(){ printf "\n\n==> Setting LAMP configs\n" #Set Apache UOJ site conf @@ -84,7 +65,7 @@ UOJEOF setWebConf(){ printf "\n\n==> Setting web files\n" #Set webroot path - cp -r ../../uoj/1 /var/www/uoj + ln -sf /opt/UOJ-System/web /var/www/uoj chown -R www-data /var/www/uoj/app/storage #Set web config file php -a < Setting judge_client files\n" + printf "\n\n==> Setting judger files\n" + #Add local_main_judger user + useradd -m local_main_judger && usermod -a -G www-data local_main_judger #Set uoj_data path - mkdir /var/uoj_data - mkdir /var/uoj_data/prepare + mkdir /var/uoj_data && mkdir /var/uoj_data/upload chown -R www-data /var/uoj_data && chgrp -R www-data /var/uoj_data - #Compile judge_client 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 su local_main_judger <uoj_judger/include/uoj_work_path.h <uoj_judger/include/uoj_work_path.h </opt/UOJ-System/judger/.conf.json <../../judger/.conf.json <