前提
安装jdk
yum install -y java-1.8.0-openjdk
安装python3.6+
yum 安装
yum -y install epel-release
yum -y install python3
或者自定义版本下载
首先安装依赖
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install gcc -y
安装包
wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz
tar -zxvf Python-3.8.11.tgz
mkdir /usr/local/python3
cd ./Python-3.8.11
./configure --prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
安装cci-agent
mkdir -p /usr/etc
cd /usr/etc
执行生成的配置
curl -sL https://coding-public-generic.pkg.coding.net/cci/release/cci-agent/install.sh | bash -s 284c23f451e71cfa62438674de004xxxxxxxxxx false default
创建开机启动服务
vim /etc/init.d/cciagent
编辑 cciAgent 填入以下内容
#!/bin/sh
# chkconfig: 2345 55 25
# description: CODING CCI AGENT
### BEGIN INIT INFO
# Provides: CODING CCI AGENT
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts CODING CCI AGENT
# Description: starts the CODING CCI AGENT
### END INIT INFO
NAME=CODING-CI
DAEMON=/usr/etc/cci-agent
RETVAL=0
check_running(){
PID=$(ps -ef | grep -v grep | grep -i "${DAEMON}" | awk '{print $2}')
if [ -n "$PID" ]; then
return 0
else
return 1
fi
}
do_start(){
check_running
if [ $? -eq 0 ]; then
echo "$NAME (pid $PID) is already running..."
exit 0
else
$DAEMON up -d > /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "Starting $NAME success"
else
echo "Starting $NAME failed"
fi
fi
}
do_stop(){
check_running
if [ $? -eq 0 ]; then
$DAEMON stop > /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "Stopping $NAME success"
else
echo "Stopping $NAME failed"
fi
else
echo "$NAME is stopped"
RETVAL=1
fi
}
do_status(){
check_running
if [ $? -eq 0 ]; then
echo "$NAME (pid $PID) is running..."
else
echo "$NAME is stopped"
RETVAL=1
fi
}
do_restart(){
do_stop
sleep 0.5
do_start
}
case "$1" in
start|stop|restart|status)
do_$1
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
RETVAL=1
;;
esac
exit $RETVAL
添加权限,添加到服务
chmod +x /etc/init.d/cciagent
chkconfig --add cciagent
chkconfig cciagent on
修改启动地址
vim /etc/systemd/system/multi-user.target.wants/cci-agent.service
修为为如下
[Unit]
Description=cci-agent
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/etc/cci-agent up -d
ExecStop=/usr/etc/cci-agent stop
[Install]
WantedBy=multi-user.target
设置开启自启动
systemctl enable cci-agent.service
systemctl daemon-reload
systemctl start cci-agent.service
网友评论