mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-24 18:08:41 +00:00
style(install/bundle): make install script dash compatible
We wrote the script that can only be executed on bash. But Ubuntu sets dash as its default shell environment. One of the most difference is the POSIX standard echo, another is parameter of chown can't be put to the end. So we made some changes to let the script used widely. And you will not face the syntax error when open this.
This commit is contained in:
parent
fb3b0dad3c
commit
eff4c8ed9c
@ -6,11 +6,11 @@ RUN apt-get update && apt-get install -y git gnupg
|
|||||||
#Clone the latest UOJ Community verison to local
|
#Clone the latest UOJ Community verison to local
|
||||||
RUN cd ~ && git clone https://github.com/UniversalOJ/UOJ-System.git --depth 1
|
RUN cd ~ && git clone https://github.com/UniversalOJ/UOJ-System.git --depth 1
|
||||||
#Install environment and set startup script
|
#Install environment and set startup script
|
||||||
RUN cd ~/UOJ-System/install/bundle && bash install.sh -e && echo "\
|
RUN cd ~/UOJ-System/install/bundle && sh install.sh -e && echo "\
|
||||||
#!/bin/bash\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/svn/.UOJSetupDone\" ]; then\n\
|
if [ ! -f \"/var/svn/.UOJSetupDone\" ]; then\n\
|
||||||
cd ~/UOJ-System/install/bundle && bash install.sh -c\n\
|
cd ~/UOJ-System/install/bundle && sh install.sh -c\n\
|
||||||
fi\n\
|
fi\n\
|
||||||
service ntp start\n\
|
service ntp start\n\
|
||||||
service mysql start\n\
|
service mysql start\n\
|
||||||
|
@ -11,19 +11,19 @@ _svn_ourroot_password_=$(genRandStr 32)
|
|||||||
_svn_certroot_password_=$(genRandStr 32)
|
_svn_certroot_password_=$(genRandStr 32)
|
||||||
|
|
||||||
getAptPackage(){
|
getAptPackage(){
|
||||||
echo -e "\n\n==> Getting environment packages"
|
printf "\n\n==> Getting environment packages\n"
|
||||||
#Set MySQL root password
|
#Set MySQL root password
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
debconf-set-selections <<< "mysql-server mysql-server/root_password password $_database_password_" && debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $_database_password_"
|
(echo "mysql-server mysql-server/root_password password $_database_password_";echo "mysql-server mysql-server/root_password_again password $_database_password_") | debconf-set-selections
|
||||||
#Update apt sources and install
|
#Update apt sources and install
|
||||||
echo "deb http://ppa.launchpad.net/pinepain/libv8/ubuntu artful main" | tee -a /etc/apt/sources.list.d/pinepain-libv8.list && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 60C60AA4
|
echo "deb http://ppa.launchpad.net/pinepain/libv8/ubuntu artful main" | tee /etc/apt/sources.list.d/pinepain-libv8.list && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 60C60AA4
|
||||||
apt-get update && apt-get install -y vim ntp zip unzip curl wget subversion 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-6.6-dev libyaml-dev python python3 python-requests
|
apt-get update && apt-get install -y vim ntp zip unzip curl wget subversion 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-6.6-dev libyaml-dev python python3 python-requests
|
||||||
#Install PHP extensions
|
#Install PHP extensions
|
||||||
cp -a /opt/libv8*/* /usr && echo -e "\n\n" | pecl install v8js yaml
|
cp -a /opt/libv8*/* /usr && printf "\n\n" | pecl install v8js yaml
|
||||||
}
|
}
|
||||||
|
|
||||||
getOracleJDK(){
|
getOracleJDK(){
|
||||||
echo -e "\n\n==> Getting JDK runtime files"
|
printf "\n\n==> Getting JDK runtime files\n"
|
||||||
#Add judger user
|
#Add judger user
|
||||||
useradd -m local_main_judger && usermod -a -G www-data local_main_judger
|
useradd -m local_main_judger && usermod -a -G www-data local_main_judger
|
||||||
#Set Oracle JDK do not track usage
|
#Set Oracle JDK do not track usage
|
||||||
@ -43,7 +43,7 @@ getOracleJDK(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
setLAMPConf(){
|
setLAMPConf(){
|
||||||
echo -e "\n\n==> Setting LAMP configs"
|
printf "\n\n==> Setting LAMP configs\n"
|
||||||
#Set Apache UOJ site conf
|
#Set Apache UOJ site conf
|
||||||
cat >/etc/apache2/sites-available/000-uoj.conf <<UOJEOF
|
cat >/etc/apache2/sites-available/000-uoj.conf <<UOJEOF
|
||||||
<VirtualHost *:80>
|
<VirtualHost *:80>
|
||||||
@ -81,10 +81,10 @@ UOJEOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
setSVNServe(){
|
setSVNServe(){
|
||||||
echo -e "\n\n==> Setting SVN server"
|
printf "\n\n==> Setting SVN server\n"
|
||||||
#Make SVN work dir
|
#Make SVN work dir
|
||||||
mkdir /var/svn && svnserve -d -r /var/svn
|
mkdir /var/svn && svnserve -d -r /var/svn
|
||||||
mkdir /var/svn/problem && chown www-data /var/svn/problem -R
|
mkdir /var/svn/problem && chown -R www-data /var/svn/problem
|
||||||
svnadmin create /var/svn/uoj && svnadmin create /var/svn/judge_client
|
svnadmin create /var/svn/uoj && svnadmin create /var/svn/judge_client
|
||||||
#Set SVN server config file and password db
|
#Set SVN server config file and password db
|
||||||
sed -i -e 's/# store-plaintext-passwords = no/store-plaintext-passwords = yes/g' /etc/subversion/servers
|
sed -i -e 's/# store-plaintext-passwords = no/store-plaintext-passwords = yes/g' /etc/subversion/servers
|
||||||
@ -149,26 +149,26 @@ svnusr="our-root"
|
|||||||
svnpwd="$_svn_ourroot_password_"
|
svnpwd="$_svn_ourroot_password_"
|
||||||
cd /var/svn/problem/\$1/cur/\$1
|
cd /var/svn/problem/\$1/cur/\$1
|
||||||
svn update --username \$svnusr --password \$svnpwd
|
svn update --username \$svnusr --password \$svnpwd
|
||||||
chown www-data /var/svn/problem/\$1 -R
|
chown -R www-data /var/svn/problem/\$1
|
||||||
UOJEOF
|
UOJEOF
|
||||||
chmod +x /var/svn/problem/post-commit.sh
|
chmod +x /var/svn/problem/post-commit.sh
|
||||||
#Precheckout to cur folder
|
#Precheckout to cur folder
|
||||||
mkdir /var/svn/uoj/cur /var/svn/judge_client/cur
|
mkdir /var/svn/uoj/cur /var/svn/judge_client/cur
|
||||||
svn co svn://127.0.0.1/uoj --username root --password $_svn_certroot_password_ /var/svn/uoj/cur/uoj
|
svn co svn://127.0.0.1/uoj --username root --password $_svn_certroot_password_ /var/svn/uoj/cur/uoj
|
||||||
svn co svn://127.0.0.1/judge_client --username root --password $_svn_certroot_password_ /var/svn/judge_client/cur/judge_client
|
svn co svn://127.0.0.1/judge_client --username root --password $_svn_certroot_password_ /var/svn/judge_client/cur/judge_client
|
||||||
chown local_main_judger /var/svn/judge_client/cur/judge_client -R
|
chown -R local_main_judger /var/svn/judge_client/cur/judge_client
|
||||||
}
|
}
|
||||||
|
|
||||||
setWebConf(){
|
setWebConf(){
|
||||||
echo -e "\n\n==> Setting web files"
|
printf "\n\n==> Setting web files\n"
|
||||||
#Commit web source file
|
#Commit web source file
|
||||||
svn co svn://127.0.0.1/uoj --username root --password $_svn_certroot_password_
|
svn co svn://127.0.0.1/uoj --username root --password $_svn_certroot_password_
|
||||||
mv ../../uoj/1 uoj/1 && cd uoj
|
mv ../../uoj/1 uoj/1 && cd uoj
|
||||||
svn add 1 && svn ci -m "Installtion commit" --username root --password $_svn_certroot_password_
|
svn add 1 && svn ci -m "Installtion commit" --username root --password $_svn_certroot_password_
|
||||||
cd .. && rm uoj /var/www/uoj -r
|
cd .. && rm -r uoj /var/www/uoj
|
||||||
#Set webroot path
|
#Set webroot path
|
||||||
ln -s /var/svn/uoj/cur/uoj/1 /var/www/uoj
|
ln -s /var/svn/uoj/cur/uoj/1 /var/www/uoj
|
||||||
chown www-data /var/www/uoj/app/storage -R
|
chown -R www-data /var/www/uoj/app/storage
|
||||||
#Set web config file
|
#Set web config file
|
||||||
php -a <<UOJEOF
|
php -a <<UOJEOF
|
||||||
\$config = include '/var/www/uoj/app/.default-config.php';
|
\$config = include '/var/www/uoj/app/.default-config.php';
|
||||||
@ -186,15 +186,15 @@ UOJEOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
setJudgeConf(){
|
setJudgeConf(){
|
||||||
echo -e "\n\n==> Setting judge_client files"
|
printf "\n\n==> Setting judge_client files\n"
|
||||||
#Commit judge_client source file
|
#Commit judge_client source file
|
||||||
svn co svn://127.0.0.1/judge_client --username root --password $_svn_certroot_password_
|
svn co svn://127.0.0.1/judge_client --username root --password $_svn_certroot_password_
|
||||||
mv ../../judge_client/1 judge_client/1 && cd judge_client
|
mv ../../judge_client/1 judge_client/1 && cd judge_client
|
||||||
svn add 1 && svn ci -m "Installation commit" --username root --password $_svn_certroot_password_
|
svn add 1 && svn ci -m "Installation commit" --username root --password $_svn_certroot_password_
|
||||||
cd .. && rm judge_client -r
|
cd .. && rm -r judge_client
|
||||||
#Set uoj_data path
|
#Set uoj_data path
|
||||||
mkdir /var/uoj_data
|
mkdir /var/uoj_data
|
||||||
chown www-data /var/uoj_data -R && chgrp www-data /var/uoj_data -R
|
chown -R www-data /var/uoj_data && chgrp -R www-data /var/uoj_data
|
||||||
#Compile judge_client and set runtime
|
#Compile judge_client and set runtime
|
||||||
su local_main_judger <<EOD
|
su local_main_judger <<EOD
|
||||||
svn update /var/svn/judge_client/cur/judge_client --username root --password $_svn_certroot_password_
|
svn update /var/svn/judge_client/cur/judge_client --username root --password $_svn_certroot_password_
|
||||||
@ -233,7 +233,7 @@ UOJEOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
endUpProgress(){
|
endUpProgress(){
|
||||||
echo -e "\n\n==> Ending progress and start service"
|
printf "\n\n==> Ending progress and start service\n"
|
||||||
#Using cli upgrade to latest
|
#Using cli upgrade to latest
|
||||||
php /var/www/uoj/app/cli.php upgrade:latest
|
php /var/www/uoj/app/cli.php upgrade:latest
|
||||||
#Start services
|
#Start services
|
||||||
@ -243,7 +243,7 @@ endUpProgress(){
|
|||||||
su local_main_judger -c '~/judge_client/judge_client start'
|
su local_main_judger -c '~/judge_client/judge_client start'
|
||||||
#Set SetupDone flag file
|
#Set SetupDone flag file
|
||||||
echo 'Congratulations!' > /var/svn/.UOJSetupDone
|
echo 'Congratulations!' > /var/svn/.UOJSetupDone
|
||||||
echo -e "\n\n***Installation complete. Enjoy!***"
|
printf "\n\n***Installation complete. Enjoy!***\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ $# -le 0 ] ;then
|
if [ $# -le 0 ] ;then
|
||||||
@ -258,26 +258,20 @@ if [ $# -le 0 ] ;then
|
|||||||
fi
|
fi
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-e)
|
-e | --environment)
|
||||||
;&
|
|
||||||
--environment)
|
|
||||||
echo 'Setting UOJ System bundle environment...'
|
echo 'Setting UOJ System bundle environment...'
|
||||||
getAptPackage
|
getAptPackage
|
||||||
getOracleJDK
|
getOracleJDK
|
||||||
setLAMPConf
|
setLAMPConf
|
||||||
;;
|
;;
|
||||||
-c)
|
-c | --config)
|
||||||
;&
|
|
||||||
--config)
|
|
||||||
echo 'Configuring UOJ System bundle...'
|
echo 'Configuring UOJ System bundle...'
|
||||||
setSVNServe
|
setSVNServe
|
||||||
setWebConf
|
setWebConf
|
||||||
setJudgeConf
|
setJudgeConf
|
||||||
endUpProgress
|
endUpProgress
|
||||||
;;
|
;;
|
||||||
-?)
|
-? | --*)
|
||||||
;&
|
|
||||||
--*)
|
|
||||||
echo "Illegal option $1"
|
echo "Illegal option $1"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user