加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
install.sh 2.53 KB
一键复制 编辑 原始数据 按行查看 历史
魔神翼 提交于 2017-05-23 21:10 . add kotlin language
#!/usr/bin/env bash
set -e
if [ `id -u` -ne 0 ]; then
echo "You need root privileges to run this script"
exit 1
fi
CATALINA_HOME=/usr/share/tomcat8
JUDGE_USER=judge
JUDGE_GROUP=judge
JUDGE_HOME=/home/${JUDGE_USER}
DATA_DIR=${JUDGE_HOME}/data
WORK_DIR=${JUDGE_HOME}/temp
JAVA_POLICY_FILE=${JUDGE_HOME}/java.policy
function create_user() {
if ! id ${JUDGE_USER} >/dev/null 2>&1 ; then
echo "try to create user ${JUDGE_USER}."
useradd --system --home ${JUDGE_HOME} --create-home --user-group \
--comment "Power Judge" ${JUDGE_USER}
RET=$?
if [ ${RET} -ne 0 ]; then
echo "create user ${JUDGE_USER} failed!"
return ${RET}
fi
mkdir -p ${DATA_DIR}/
chown ${JUDGE_USER}:${JUDGE_GROUP} ${DATA_DIR}
mkdir -p ${WORK_DIR}/
chown ${JUDGE_USER}:${JUDGE_GROUP} ${WORK_DIR}
chmod 775 ${WORK_DIR}
echo "create user ${JUDGE_USER} completed."
else
echo "user ${JUDGE_USER} already exist."
fi
}
TOMCAT_USER=
TOMCAT_GROUP=
function find_tomcat() {
WEBAPPS=${CATALINA_HOME}/webapps
if [ ! -d "${WEBAPPS}" ]; then
echo -e "\x1b[31mcannot find tomcat, please set env CATALINA_HOME\x1b[0m" >&2
return 1
fi
TOMCAT_USER=`stat -c '%U' ${WEBAPPS}/`
TOMCAT_GROUP=`stat -c '%G' ${WEBAPPS}/`
return 0
}
create_user
if find_tomcat; then
echo "try to add user ${JUDGE_USER} to tomcat group ${TOMCAT_GROUP}"
adduser ${JUDGE_USER} ${TOMCAT_GROUP}
echo "try to add user ${TOMCAT_USER} to judge group ${JUDGE_GROUP}"
adduser ${TOMCAT_USER} ${JUDGE_GROUP}
if [ -d /var/log/nginx/ ]; then
USER=`stat -c '%U' /var/log/nginx/`
echo "try to add nginx user ${USER} to tomcat group ${TOMCAT_GROUP}"
usermod -a -G ${TOMCAT_GROUP} ${USER}
GROUP=`stat -c '%G' /var/log/nginx/`
echo "try to add tomcat user ${TOMCAT_USER} to nginx group ${GROUP}"
adduser ${TOMCAT_USER} ${GROUP}
fi
fi
cp config/judged /etc/init.d/judged && chmod a+x /etc/init.d/judged
update-rc.d judged defaults
[ -d /etc/logrotate.d/ ] && cp config/logrotate /etc/logrotate.d/judged
[ -d /etc/ufw/applications.d/ ] && cp config/ufw /etc/ufw/applications.d/judged
if [ ! -f /etc/judged.conf ]; then
cp -p config/judged.conf /etc/judged.conf
fi
if [ ! -f ${JAVA_POLICY_FILE} ]; then
cp config/java.policy ${JAVA_POLICY_FILE}
chmod 440 ${JAVA_POLICY_FILE}
chown ${JUDGE_USER}:${JUDGE_GROUP} ${JAVA_POLICY_FILE}
fi
service judged stop
make clean install
service judged start
service judged status
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化