代码拉取完成,页面将自动刷新
同步操作将从 DTCloud开源社区/DTCloud 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# !/bin/bash
echo "中亿丰数字科技集团:一键安装dtcloud4.0"
echo -n "请输入服务器IP:"
read server_ip
echo -n "请输入数据库名称:"
read db_name
echo -n "请输入数据库密码:"
read db_password
echo -n "请输入dtcloud服务端口号:"
read xmlrpc_port
echo -n "请输入dtcloud超级管理员密码:"
read admin_passwd
echo -n "请输入安装目录名:"
read dtcloud_dir
# 准备工作
apt -y --force-yes update && apt -y --force-yes upgrade # 太大了,这个更新估计要很长时间
# 1.0 安装postgres
apt install postgresql -y
service postgresql start
sudo su - postgres -c "createuser -s dtcloud"
sudo -u postgres psql -c "alter role dtcloud with password '$db_password'"
# 1.1 替换两个关键性配置文件
sed -i "s/^listen_addresses =.*/listen_addresses = \'\*\'/" /etc/postgresql/14/main/postgresql.conf
sed -i "s/^#listen_addresses =.*/listen_addresses = \'\*\'/" /etc/postgresql/14/main/postgresql.conf
function get_line(){
sed -n -e '/IPv4 local connections/=' /etc/postgresql/14/main/pg_hba.conf
}
line_num=$(get_line)
line_num_real=$[ `expr $line_num + 1` ]
sed -i "${line_num_real}s/127.0.0.1\/32/0.0.0.0\/0/" /etc/postgresql/14/main/pg_hba.conf
# 1.2 重启
service postgresql restart
# 3.0 安装redis
sudo apt update
sudo apt install redis-server -y
sed -i "s/^supervised no/supervised systemd/" /etc/redis/redis.conf
sed -i -e "69 s/^/#/" /etc/redis/redis.conf
sed -i "s/^protected-mode yes/protected-mode no/" /etc/redis/redis.conf
sudo systemctl restart redis
# 5.0 安装supervisor
sudo apt install supervisor
# su dtcloud
sudo apt-get install git
mkdir -p /opt/dtcloud/$dtcloud_dir && cd /opt/dtcloud/$dtcloud_dir
git clone -b custom_DT4 https://1144921421%40qq.com:270966qianyU@gitee.com/intelligent-architecture-plus/smart-building-dtcloud.git
mv /opt/dtcloud/$dtcloud_dir/smart-building-dtcloud/* /opt/dtcloud/$dtcloud_dir/ && rm -rf /opt/dtcloud/$dtcloud_dir/smart-building-dtcloud
chmod -R 755 /opt/dtcloud/$dtcloud_dir
apt install python3-virtualenv
virtualenv /opt/dtcloud/$dtcloud_dir/env
/opt/dtcloud/$dtcloud_dir/env/bin/pip install -r /opt/dtcloud/$dtcloud_dir/requirements_ubuntu.txt
# 3.0 关于用户权限
sudo chown -R dtcloud /opt/dtcloud/$dtcloud_dir
if [ ! -d "/opt/dtcloud/$dtcloud_dir/data_dir" ]; then
mkdir -p /opt/dtcloud/$dtcloud_dir/data_dir
fi
sudo chown -R dtcloud /opt/dtcloud/$dtcloud_dir/data_dir
# 4.0 修改配置文件
sed -i '/^dev:/,/^\w\+:/{/^ admin_passwd:/s/:.*/: $admin_passwd/}' /opt/dtcloud/$dtcloud_dir/dtcloud.yaml
sed -i '/^dev:/,/^\w\+:/{/^ db_password:/s/:.*/: $db_password/}' /opt/dtcloud/$dtcloud_dir/dtcloud.yaml
sed -i '/^dev:/,/^\w\+:/{/^ xmlrpc_port:/s/:.*/: $xmlrpc_port/}' /opt/dtcloud/$dtcloud_dir/dtcloud.yaml
sed -i '/^dev:/,/^\w\+:/{/^ db_name:/s/:.*/: $db_name/}' /opt/dtcloud/$dtcloud_dir/dtcloud.yaml
# 6.0 创建dtcloud自动化服务
if [ -f "/etc/supervisor/conf.d/$dtcloud_dir.conf" ]
then
echo "服务文件是存在的,重新覆盖内容"
else
echo "服务文件不存在,现在创建"
touch /etc/supervisor/conf.d/$dtcloud_dir.conf
fi
cat <<EOF > /etc/supervisor/conf.d/$dtcloud_dir.conf
[inet_http_server]
port=*:9098
username=admin
password=admin
[program:dtcloud-service]
command= /opt/dtcloud/$dtcloud_dir/env/bin/python3 /opt/dtcloud/$dtcloud_dir/dtcloud.py -c /opt/dtcloud/$dtcloud_dir/dtcloud.yaml
autostart=true
autorestart=true
startretries=3
redirect_stderr=false
stdout_logfile=/var/log/dtcloud_service.info.log
stderr_logfile=/var/log/dtcloud_service.out.log
EOF
cat <<EOF > /etc/supervisor/conf.d/dtcloud_queue.conf
[program:dtcloud-queue]
command= /opt/dtcloud/$dtcloud_dir/env/bin/python3 /opt/dtcloud/$dtcloud_dir/dtcloud.py jobqueue -c /opt/dtcloud/$dtcloud_dir/dtcloud.yaml
autostart=true
autorestart=true
startretries=3
redirect_stderr=false
stdout_logfile=/var/log/dtcloud_queue_service.info.log
stderr_logfile=/var/log/dtcloud_queue_service.out.log
EOF
# 6.1 重启supervisor
sudo supervisorctl reread
sudo supervisorctl update
systemctl restart supervisor
# 6.2 开机自启动
sudo systemctl enable supervisor
# 重新加载配置文件
sudo systemctl daemon-reload
# 6.0 结束
echo "安装结束,请访问以下地址进入DTCloud:http://$server_ip:$xmlrpc_port"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。