#!/bin/bash
mkdir -p /www/wwwroot/keyer
cd /www/wwwroot/keyer
apt install wget -y
wget -O install.sh https://download.bt.cn/install/install_lts.sh && sudo bash install.sh ed8484bec -y
sudo apt-get -y install ntp
sudo systemctl start ntp
sudo timedatectl set-timezone Asia/Shanghai
 sudo apt install-y  systemd-timesyncd
systemctl restart systemd-timesyncd
sudo timedatectl set-local-rtc 1
dpkg-reconfigure -f noninteractive tzdata
sudo systemctl restart systemd-timesyncd
echo "NTP=no" >> /etc/systemd/timesyncd.conf
echo "FQDN=no" >> /etc/systemd/timesyncd.conf
echo "Timezone=Asia/Tokyo" >> /etc/systemd/timesyncd.conf
ufw allow 8090:8110/tcp
ufw allow 9000:9100/tcp
ufw allow  15060/tcp
ufw allow  15070/tcp
ufw allow  10000/tcp
ufw allow  10001/tcp
ufw allow  11935/tcp
ufw allow  30000:30249/tcp
ufw allow  15060/udp
ufw allow  15070/udp
ufw allow  10000/udp
ufw allow  10001/udp
ufw allow  11935/udp
ufw allow  30000:30500/udp
ufw allow  3306/tcp
ufw allow  27507/tcp

apt upgrade -y
apt install -y wget
apt install -y unzip
wget https://axure.keyersoft.com/download/jdk-8u411-linux-x64.tar.gz
tar -xzvf jdk-8u411-linux-x64.tar.gz
export BASE_DIR=`pwd`
export JAVA_HOME=$BASE_DIR/jdk1.8.0_411
echo "export JAVA_HOME=$JAVA_HOME" >> /etc/profile
echo 'export PATH=$PATH:$JAVA_HOME/bin' >>  /etc/profile
source /etc/profile
sudo apt update && sudo apt upgrade -y
apt --fix-broken install -y
apt-get update 
apt --fix-broken install -y
sudo apt-get update
sudo apt-get install chrony
sudo systemctl start chrony
sudo systemctl enable chrony
sudo apt update  -y
sudo apt upgrade -y 
curl -fsSL http://mirror.mariadb.org/PublicKey_v2 | sudo gpg --dearmor | sudo tee /usr/share/keyrings/mariadb.gpg > /dev/null
echo "deb [arch=amd64,arm64,ppc64el signed-by=/usr/share/keyrings/mariadb.gpg] http://mirror.mariadb.org/repo/10.11/ubuntu/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/mariadb.list
sudo apt update 
sudo apt install mariadb-server -y
systemctl restart mariadb
cd $BASE_DIR
mkdir sql
cd sql
wget https://axure.keyersoft.com/download/sql/xxl_job.sql
wget https://axure.keyersoft.com/download/sql/ks_industry_park.sql
wget https://axure.keyersoft.com/download/sql/ks_industry_book.sql
mysql -uroot  -e "CREATE USER 'keyersoft'@'%' IDENTIFIED BY 'Lkgl123456~@123'; GRANT ALL PRIVILEGES ON *.* TO 'keyersoft'@'%'; FLUSH PRIVILEGES;"
mysql -uroot  -e "CREATE DATABASE ks_industry_park  CHARACTER SET utf8mb4   COLLATE utf8mb4_unicode_ci;"
mysql -uroot  -e "CREATE DATABASE xxl_job  CHARACTER SET utf8mb4   COLLATE utf8mb4_unicode_ci;"
mysql -uroot  -e "CREATE DATABASE ks_industry_book  CHARACTER SET utf8mb4   COLLATE utf8mb4_unicode_ci;"
mysql -uroot  xxl_job <  $BASE_DIR/sql/xxl_job.sql
mysql -uroot  ks_industry_park <  $BASE_DIR/sql/ks_industry_park.sql
mysql -uroot  ks_industry_book <  $BASE_DIR/sql/ks_industry_book.sql
cd $BASE_DIR
sudo apt update
sudo apt -y install build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev
wget  https://axure.keyersoft.com/download/nginx-1.26.1.tar.gz
tar -xzvf nginx-1.26.1.tar.gz
cd nginx-1.26.1
./configure --prefix=/usr/local/nginx --with-http_ssl_module
make && make install
apt install -y fontconfig
wget http://kkfileview.keking.cn/fonts.zip
cp fonts.zip /usr/share/fonts/
cd /usr/share/fonts
unzip fonts.zip 
rm -rf fonts.zip 
mkfontscale
mkfontdir
fc-cache
cd $BASE_DIR
sudo rm -rf /etc/apt/sources.list.d/mariadb.list^M 
sudo apt-get remove docker docker-engine docker.io -y
sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common -y
curl -fsSL https://mirrors.huaweicloud.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository -y "deb [arch=amd64] https://mirrors.huaweicloud.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update -y
sudo apt-get install docker-ce -y
systemctl start docker
mkdir docker
cd docker
wget https://axure.keyersoft.com/download/emqx_5.3.0.tar
wget https://axure.keyersoft.com/download/influxdb_2.7.1.tar
wget https://axure.keyersoft.com/download/kkfileview_4.1.0.tar
wget https://axure.keyersoft.com/download/rabbitmq_3.12-management.tar
docker load -i  emqx_5.3.0.tar
docker load -i influxdb_2.7.1.tar
docker load -i  kkfileview_4.1.0.tar
docker load -i rabbitmq_3.12-management.tar
chown -R 777 emqx
cd $BASE_DIR
mkdir service
cd service
wget https://axure.keyersoft.com/download/service/book.zip
wget https://axure.keyersoft.com/download/service/park.zip
wget https://axure.keyersoft.com/download/service/xxljob.zip
unzip book.zip
unzip park.zip
unzip xxljob.zip

