RSS订阅优然探索
你的位置:首页 » Linux相关 » 正文

kiop.setup.sh

选择字号: 超大 标准 发布时间:2024-3-29 16:33:6 | 作者:admin | 0个评论 | 人浏览

#!/bin/bash

cd ~

#ubuntu22.04,debian12.0,openkylin1.0 统一用这个安装包进行安装

export PATH=$PATH:/sbin/

export PATH=/bin:/usr/bin:/usr/sbin:$PATH


function kiop_log(){

echo "####:$1"

}

function kiop_slog(){

echo "#################### $1"

}

user_opr_system=""

function kiop_check_system() {

  if [[ -n $(find /etc -name "redhat-release") ]] || grep </proc/version -q -i "centos"; then

    # 检测系统版本号

    centosVersion=$(rpm -q centos-release | awk -F "[-]" '{print $3}' | awk -F "[.]" '{print $1}')

    if [[ -z "${centosVersion}" ]] && grep </etc/centos-release "release 8"; then

      centosVersion=8

    fi

    release="centos"


  elif grep </etc/issue -q -i "debian" && [[ -f "/etc/issue" ]] || grep </etc/issue -q -i "debian" && [[ -f "/proc/version" ]]; then

    if grep </etc/issue -i "8"; then

      debianVersion=8

    fi

    release="debian"


  elif grep </etc/issue -q -i "ubuntu" && [[ -f "/etc/issue" ]] || grep </etc/issue -q -i "ubuntu" && [[ -f "/proc/version" ]]; then

    release="ubuntu"

  fi


  if [[ -z ${release} ]]; then

   release ="other"

  else

   echo "user opr system:$release"

  fi

  user_opr_system="$release"

}



supervisorused="0"

kiop_slog "start"

#0.打包日期

set_date="2024-03-22"

set_version="5.2.24.0322"

kiopfile="ksetup.$set_version.tar.gz"

dotnetzipfile="dotnet-sdk-8.0.100-linux-x64.tar.gz"

logfile="/root/kiop.log"

nullfile="/root/null.log"

#kiop_log ------------------------

setupchk=""


function kiop_log_init(){

logdate=$(date "+%y%m%d-%H%M%S")

logfile="/root/kiop.$logdate.log"

kiop_log "$logfile"

}

kiop_log_init

#kiop_log $1

function kiop_setup_check(){

#kiop_log "您确实要安装KIOP系统吗?"

kiop_log "Are you sure you want to install KIOP for dotnet8.0"

kiop_log "KIOP Version:$set_version Date:$set_date"

read -p "yes setup no exit;please input [y/n]:" setupchk

if [ -z $setupchk ] 

then 

kiop_log "not input exit;please input y/n"

exit

elif [ $setupchk = "y" -o $setupchk = "yes" ] 

then 

kiop_log "welcome start setup kiop"

else

kiop_log "not input [y] setup exit"

exit

fi

}


#kiop_log ------------------------

kiopbase="https://wise-software.oss-cn-beijing.aliyuncs.com/iop/kiop/ksetup/"

kiopdownloadpage=${kiopbase}${kiopfile}

savetmpfolder="/usr/coretmp"

dotnetfolder="/usr/lib/dotnet8.0"

#kiop_log $kiopdownloadpage

#1.建立文件

savefolder="/usr/core"

kiopfolder="/usr/core/kiop"

function kiop_setup_mkdir(){

if [ ! -d "$savefolder" ]; then

mkdir $savefolder -p

kiop_log "create folder $savefolder"

fi

if [ ! -d "$kiopfolder" ]; then

mkdir $kiopfolder -p

kiop_log "create folder $kiopfolder"

fi

if [ ! -d "$savetmpfolder" ]; then

mkdir $savetmpfolder -p

kiop_log "create folder $savetmpfolder"

fi

}


#2.下载文件


function kiop_setup_download(){

cd  $savetmpfolder

if [  -f "$kiopfile" ]; then

kiop_log "file exist,not download"

else

  kiop_log "start download file $kiopdownloadpage"

  wget -O $kiopfile $kiopdownloadpage

fi

if [  -f "$kiopfile" ]; then

kiop_log "download finish"

else

kiop_log "download error;not find:$kiopdownloadpage"

kiop_log "setup error"

kiop_log "system exit"

exit

fi

}


function kiop_setup_init(){

#3.更新系统

kiop_log "apt-get update"

apt-get update 

kiop_log "apt install -y libgdiplus"

apt install -y libgdiplus 

kiop_log "apt -y install net-tools"

apt -y install net-tools 

#4.解压文件

kiop_log "tar file $kiopfile"

tar -zxvf $kiopfile -C $kiopfolder >> $logfile 

kiop_log "cd /usr/core/kiop/setup"

cd $kiopfolder/setup

}


#5.开始安装




#1.安装supervisor

function kiop_supervisor(){

kiop_slog '1.supervisor setup start'

apt -y install supervisor 

supervisorused="1"

kiop_slog '1.supervisor setup end'

}


#1.安装nginx

function kiop_nginx_setup(){

kiop_slog '2.nginx setup start'

apt -y install nginx  

systemctl start nginx 

kiop_slog '2.nginx setup end'

}


#3.安装rabbitmq

function kiop_rabbitmq(){

kiop_slog '3.rabbitmq setup start'

apt -y install rabbitmq-server  

rabbitmq-plugins enable rabbitmq_management 

rabbitmq-plugins enable rabbitmq_mqtt 

rabbitmq-plugins enable rabbitmq_web_mqtt 


#超级管理员

rabbitmqctl add_user admin kiopb2v9d7d1b_com  

rabbitmqctl set_user_tags admin administrator 

rabbitmqctl set_permissions -p /  admin '.*' '.*' '.*' 


#流媒体管理员

rabbitmqctl add_user wisevideo wise123.com  

rabbitmqctl set_user_tags wisevideo administrator 

rabbitmqctl set_permissions -p /  wisevideo '.*' '.*' '.*' 

rabbitmqctl set_topic_permissions -p /  wisevideo 'amq.topic' 'iopwisevideo.*' 'iopwisevideo.*'


#前台用户查看用

rabbitmqctl add_user wisekiop kiopb8v9f6d1_com  

rabbitmqctl set_user_tags wisekiop impersonator 

rabbitmqctl set_permissions -p /  wisekiop '.*' '.*' '.*' 

rabbitmqctl set_topic_permissions -p /  wisekiop 'amq.topic' 'iopmsglist.*' 'iopmsglist.*'


#液晶面板用户

rabbitmqctl add_user wisepad kioppad9f6d1_com  

rabbitmqctl set_user_tags wisepad administrator 

rabbitmqctl set_permissions -p /  wisepad '.*' '.*' '.*' 

rabbitmqctl set_topic_permissions -p /  wisepad 'amq.topic' 'wise.pad.toserver.*' '.*'



kiop_slog '3.rabbitmq setup end'


#删除配置文件 20230608

rm -f /etc/rabbitmq/rabbitmq.config

cp -r $kiopfolder/setup/cnf/rabbitmq.config /etc/rabbitmq

systemctl restart rabbitmq-server  

}



function kiop_mosquitto(){

kiop_slog '4.mosquitto setup start'

#mosquitto 安装

apt -y install mosquitto  

#删除配置文件 20230608

rm -f /etc/mosquitto/conf.d/mosquitto.conf

cp -r /usr/core/kiop/setup/cnf/mosquitto.conf /etc/mosquitto/conf.d

systemctl stop mosquitto 

systemctl start mosquitto 

kiop_slog '4.mosquitto setup end'

}



function kiop_dotnet(){

kiop_slog '5.dotnet setup start'

#4.安装dotnet

if [ ! -d "$dotnetfolder" ]; then

mkdir $dotnetfolder

kiop_log "create folder $dotnetfolder"

fi

tar -zxvf $kiopfolder/setup/$dotnetzipfile -C $dotnetfolder  >>  $logfile 

mv /etc/profile /etc/profile.kiop.bak

cp $kiopfolder/setup/cnf/profile /etc

source /etc/profile

kiop_slog '5.dotnet setup end'

}

 


#6.安装kiopweb

function kiop_web(){

kiop_slog '6.kiopweb setup start'

tar -zxvf $kiopfolder/setup/kiop.web.tar.gz -C $kiopfolder/wwwroot >>  $logfile 

if [ $supervisorused = "1" ]; then

rm -f /etc/supervisor/conf.d/kiopweb.conf

cp -r $kiopfolder/setup/cnf/kiopweb.conf /etc/supervisor/conf.d

fi

kiop_slog '6.kiopweb setup end'

}



#7.安装kiopmmu

function kiop_mmu(){

kiop_slog '7.kiopmmu setup start'

tar -zxvf $kiopfolder/setup/kiop.mmu.tar.gz -C $kiopfolder/kmmu  >>  $logfile 

if [ $supervisorused = "1" ]; then

rm -f /etc/supervisor/conf.d/kiopmmu.conf

cp -r $kiopfolder/setup/cnf/kiopmmu.conf /etc/supervisor/conf.d

fi

kiop_slog '7.kiopmmu setup end'

}



#5.安装mysql

function kiop_mysql(){

kiop_slog '8.mysql setup start'

#debian安装需要

kiop_log "user system $user_opr_system"

if [ $user_opr_system = "debian" ]; then

apt -y install gnupg  

#apt -y install libssl

mysql_version="mysql-apt-config_0.8.25-1_all.deb"

wget -O $mysql_version https://dev.mysql.com/get/mysql-apt-config_0.8.25-1_all.deb

dpkg -i $mysql_version

apt update

apt -y install mysql-server  

else

apt -y install mysql-server  

fi


#systemctl status mysql

kiop_log 'back mysql conf'

mv /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf.bak

kiop_log 'copy mysql conf'

cp -r $kiopfolder/setup/cnf/mysqld.cnf /etc/mysql/mysql.conf.d

#先重新启动一下在安装

systemctl restart mysql 


#systemctl status mysql

kiop_log 'mysql info create dbinfo'

$dotnetfolder/dotnet $kiopfolder/wwwroot/kiop.dbinit.dll $kiopfolder/setup/db  

kiop_log 'mysql info create finish'

netstat -tap | grep mysql  

kiop_slog '8.mysql setup end'

}


#8.配置nginx

zsfolder="/etc/nginx/zs"

nginxfile="/etc/nginx/sites-enabled/default"

nginxfile2="/etc/nginx/sites-available/default"

function kiop_nginx(){

kiop_slog '9.nginx config start'

if [ ! -d "$zsfolder" ]; then

mkdir $zsfolder -p

kiop_log "create folder $zsfolder"

fi

cp -r $kiopfolder/setup/cnf/webzs.key /etc/nginx/zs

cp -r $kiopfolder/setup/cnf/webzs.pem /etc/nginx/zs

cp -r $kiopfolder/setup/cnf/nginxkiop.conf /etc/nginx/conf.d

cp -r $kiopfolder/setup/cnf/nginxkiophttps.conf /etc/nginx/conf.d

if [ -f "$nginxfile" ]; then

  rm "$nginxfile"

  kiop_log "delete file $nginxfile"

fi

if [ -f "$nginxfile2" ]; then

  rm "$nginxfile2"

  kiop_log "delete file $nginxfile"

fi

nginx -s reload


kiop_slog '9.nginx config end'

}


function kiop_other(){

kiop_slog '10.https config start'

#证书问题处理一下

$dotnetfolder/dotnet dev-certs https --clean  >>$logfile 

$dotnetfolder/dotnet dev-certs https -t  >>$logfile 

$dotnetfolder/dotnet dev-certs https --check  >>$logfile 

if [ $supervisorused = "1" ]; then

#重启supervisor

systemctl restart supervisor

kiop_log 'systemctl restart supervisor'

kiop_log 'supervisorctl status'

fi

kiop_slog '10.https config end'

}


function kiop_systemd(){

kiop_slog '11.systemd config start'

cp -f $kiopfolder/setup/systemd/kiopweb.service /etc/systemd/system

cp -f $kiopfolder/setup/systemd/kiopmmu.service /etc/systemd/system


#cp -r /usr/core/kiop/setup/systemd/kiopweb.service /etc/systemd/system

#cp -r /usr/core/kiop/setup/systemd/kiopmmu.service /etc/systemd/system

systemctl daemon-reload

systemctl stop kiopweb

systemctl start kiopweb

systemctl stop kiopmmu

systemctl start kiopmmu


systemctl disable kiopweb

systemctl disable kiopmmu

systemctl enable kiopweb >>$logfile 2>$nullfile

systemctl enable kiopmmu >>$logfile 2>$nullfile

kiop_slog '11.systemd config end'


}



#防火墙操作

function kiop_port(){

kiop_slog '12.port config start'

apt install -y  ufw 

ufw allow 80  

ufw allow 443 

ufw allow 9100 

ufw allow 1883 

#mmu防火墙端口

ufw allow 6681 

ufw allow 7777 

ufw allow 7000 

ufw allow 6668 

ufw allow 6666 

ufw allow 30000 

ufw allow 22

ufw allow 9080 

ufw allow 9443

ufw deny 3306 

kiop_slog '12.port config end'

ufw enable

}


#NTP服务安装

function kiop_ntp_setup(){

kiop_log "if user have use tau control,please set up ntp Service"

read -p "ntp setup yes setup no exit;please input [y/n]:" setupchk

if [ -z $setupchk ] 

then 

kiop_log "not setup ntp"

elif [ $setupchk = "y" -o $setupchk = "yes" ] 

then 

kiop_log "welcome start install ntp"

kiop_log "apt install -y ntp"

apt install -y ntp

kiop_log " ufw allow 123"

ufw allow 123

kiop_log "systemctl restart ntp"

systemctl restart ntp

kiop_log "start install ntp finish"

else

kiop_log "not input [y] ntp not install"

fi

}


function kiop_ubuntu_init(){

kiop_check_system

kiop_setup_check

kiop_setup_mkdir

kiop_setup_download

kiop_setup_init


#kiop_supervisor

kiop_nginx_setup

kiop_rabbitmq

kiop_mosquitto

kiop_dotnet

kiop_web

kiop_mmu

kiop_mysql

kiop_nginx

kiop_other

kiop_systemd

kiop_port

kiop_ntp_setup

}


kiop_ubuntu_init

kiop_slog 'setup kiop finish'


标签:

猜你喜欢

发表评论

必填

选填

选填

必填,不填不让过哦,嘻嘻。

记住我,下次回复时不用重新输入个人信息

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。