init.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. set -e
  3. # 更新系统并安装一些常用软件和依赖
  4. sudo yum update -y && sudo yum install -y vim curl git openssl openssl-devel
  5. # 安装Nginx(安装后启动、设置为开机自启动)
  6. yum install -y nginx
  7. sudo systemctl start nginx.service
  8. sudo systemctl enable nginx.service
  9. # 设置防火墙规则并重启防火墙
  10. sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
  11. sudo firewall-cmd --zone=public --add-port=9000/udp --permanent
  12. sudo firewall-cmd --reload
  13. # 安装Golang编译环境
  14. if [ ! -d "/usr/local/go/bin/" ]; then
  15. wget https://studygolang.com/dl/golang/go1.19.4.linux-amd64.tar.gz
  16. tar -C /usr/local -xzf go1.19.4.linux-amd64.tar.gz
  17. sudo sh -c 'echo "export PATH=/usr/local/go/bin:$PATH" >> /etc/profile'
  18. # shellcheck disable=SC2039
  19. # shellcheck disable=SC1090
  20. source /etc/profile && source ~/.bashrc
  21. sudo rm -rf go1.19.4.linux-amd64.tar.gz
  22. fi
  23. # 安装Redis、MySQL数据库
  24. if [ ! -d "/data/mysql" ]; then
  25. wget -c http://mirrors.oneinstack.com/oneinstack-full.tar.gz && tar xzf oneinstack-full.tar.gz && ./oneinstack/install.sh --db_option 2 --dbinstallmethod 1 --dbrootpwd 88888888 --redis
  26. sudo rm -rf oneinstack*
  27. fi