1 Star 0 Fork 268

小马/DTCloud

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dtcloud4.0.sh 4.17 KB
一键复制 编辑 原始数据 按行查看 历史
sugar 提交于 2024-07-10 09:43 . feat: DTCloud4。18分支提交
# !/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"
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mawenb/dtcloud.git
git@gitee.com:mawenb/dtcloud.git
mawenb
dtcloud
DTCloud
DTCloud-4.18

搜索帮助