Files
hustoj/install/fixing.sh
2024-10-10 12:56:56 +08:00

44 lines
1.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
DATE=`date +%Y%m%d%H%M`
USER=`cat /etc/mysql/debian.cnf |grep user|head -1|awk '{print $3}'`
PASSWORD=`cat /etc/mysql/debian.cnf |grep password|head -1|awk '{print $3}'`
WWW=`grep www /etc/passwd|awk -F: '{print $1}'`
if [ `whoami` = "root" ];then
cd /home/judge/
chsh judge -s /sbin/nologin
mkdir new
cd new
wget -O hustoj.tar.gz http://dl.hustoj.com/hustoj.tar.gz
tar xzf hustoj.tar.gz
mv src/* ./
cd ..
chmod +x new/install/*.sh
if test -e /home/judge/src/web/include/db_info.inc.php ;then
echo 'db_info.inc.php exists !';
new/install/merge.sh src/web/include/db_info.inc.php new/web/include/db_info.inc.php
else
echo 'db_info.inc.php not found';
sed -i "s/DB_USER[[:space:]]*=[[:space:]]*\"root\"/DB_USER=\"$USER\"/g" new/web/include/db_info.inc.php
sed -i "s/DB_PASS[[:space:]]*=[[:space:]]*\"root\"/DB_PASS=\"$PASSWORD\"/g" new/web/include/db_info.inc.php
fi
cp -a src/web/upload/* new/web/upload/
mv src "old.$DATE"
echo "Your old files are moved to old.$DATE , find them if you need ."
mv new src
chmod +x src/install/*.sh
sed -i "s/OJ_INTERNAL_CLIENT=1/OJ_INTERNAL_CLIENT=0/g" /home/judge/etc/judge.conf
pkill -9 judged
cd src/core
bash make.sh
judged
cd /home/judge
#不要合并必须重新进入否则执行的update.sql是老版本没有更新
cd src/install
bash mysql.sh < update.sql
cd ../..
chown $WWW:$WWW -R src
else
echo "usage: sudo $0"
fi