diff --git a/Terraform/outputs.tf b/Terraform/outputs.tf deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/Terraform/serverJenkins.sh b/Terraform/serverJenkins.sh index 70318d237fac453977a73c9efd9977a9be070b7a..22b69674f407a71058728ad57f145b135557a63f 100644 --- a/Terraform/serverJenkins.sh +++ b/Terraform/serverJenkins.sh @@ -1,38 +1,53 @@ #!/usr/bin/bash +echo "update logging configuration..." +sudo sh -c "echo '*.info;mail.none;authpriv.none;cron.none /dev/ttyS0' >> /etc/rsyslog.conf" +sudo systemctl restart rsyslog -su centos -cd /home/centos -whoami echo logged in as $USER. echo in directory $PWD -# 安装常用工具 -sudo yum install wget -y -sudo yum install unzip -y -echo "installing git..." -sudo yum install git -y -# 安装 OpenSSH -echo "Installing OpenSSH..." -sudo yum install -y openssh-server +echo "installing MariaDB..." +# sudo yum install mysql -y +sudo dnf install mariadb-server -y +sudo systemctl start mariadb +sudo systemctl status mariadb +sudo systemctl enable mariadb + + +echo "creating mysql_secure_installation.txt..." +touch mysql_secure_installation.txt +cat << `EOF` >> mysql_secure_installation.txt + +n +Y +comsc +comsc +Y +Y +Y +Y +Y +`EOF` -# 启动并启用 OpenSSH -echo "Starting and enabling OpenSSH..." -sudo systemctl start sshd -sudo systemctl enable sshd +echo "running mysql_secure_installation..." +sudo mysql_secure_installation < mysql_secure_installation.txt -# 检查 OpenSSH 服务状态 -sudo systemctl status sshd -# 配置 GitLab 服务器 SSH 密钥 -echo "installing gitlab server key..." -sudo touch ~/.ssh/known_hosts -sudo ssh-keyscan gitlab.cs.cf.ac.uk >> ~/.ssh/known_hosts -sudo chmod 644 ~/.ssh/known_hosts +sudo yum install git -y +# new 2025 - Git install messes up the ssh even if you do an update at the beginning we need to re install ssh after git. +sudo dnf update openssh-server openssh-client -y + +echo "needs to be in root account" +cd root + +touch .ssh/known_hosts +ssh-keyscan git.cardiff.ac.uk >> .ssh/known_hosts +chmod 644 .ssh/known_hosts + +echo "now needs to be in rocky user directory" +cd /home/rocky -# 配置用户 SSH 密钥 -echo "installing gitlab deployment key..." -touch matrix_keypair.key cat << `EOF` >> matrix_keypair.key b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn NhAAAAAwEAAQAAAYEAz/OKny0EL3KyQHOupJl7CybJMUptteLalnyN4F63YUQwRQaG9h28 @@ -71,105 +86,24 @@ J86qKWdJxgpoIY8zLp0kOcBzHOKU0+tfzIvAYIFZ0sTNdpdLTmaLO1L986IqRjpExMw+Go TBXGOnjcHM0kCN4cQcT7YgnEtrt1SEt/yVK590Z+hSkaJIgPxUlDrm3UCkHFrKxdT+UCDL /sHf7dEAE5USKzAAAAHElEK2MyMjEyMjE5MkBEU0E4Q0U5RUU2MEFCRjgBAgMEBQY= `EOF` - chmod 400 matrix_keypair.key -# 通过 SSH 密钥克隆一个 Git 仓库 -echo "cloning repository..." -echo $PWD ssh-agent bash -c 'ssh-add matrix_keypair.key; git clone git@git.cardiff.ac.uk:c24020257/sports-league-application.git' -# 更新 rsyslog 配置以将日志输出到特定设备 -echo "update logging configuration..." -sudo sh -c "echo '*.info;mail.none;authpriv.none;cron.none /dev/ttyS0' >> /etc/rsyslog.conf" -sudo systemctl restart rsyslog +cd Team5 Sports League application/sports-league-application -# 确认当前的工作目录是否成功切换 -cd /home/rocky -echo in directory $PWD - -# 安装并配置 MariaDB 数据库 -echo "installing MariaDB..." -# sudo yum install mysql -y -sudo dnf install mariadb-server -y -sudo systemctl start mariadb -sudo systemctl status mariadb -sudo systemctl enable mariadb +mysql -uroot -pcomsc < src/main/resources/sports.sql -echo "creating mysql_secure_installation.txt..." -touch mysql_secure_installation.txt -cat << `EOF` >> mysql_secure_installation.txt - -n -Y -comsc -comsc -Y -Y -Y -Y -Y -`EOF` - -echo "running mysql_secure_installation..." -sudo mysql_secure_installation < mysql_secure_installation.txt +sudo yum install java-17-openjdk -y sudo yum install wget -y -sudo yum install unzip -y -sudo yum install git -y - -# 安装 Java 17 -echo "Installing Java 17..." -sudo yum install java-17-openjdk-devel -q -y -echo java --version - -# 安装 Jenkins -echo "install Jenkins" -# https://pkg.jenkins.io/redhat-stable/ -curl --silent --location http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo | sudo tee /etc/yum.repos.d/jenkins.repo -sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key -sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io-2023.key -sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y -sudo yum install jenkins -y - -# 配置 Jenkins 的 SSH known_hosts 文件 -echo "installing gitlab server key... has to be added to the jenkins user home (~) dir " -mkdir /var/lib/jenkins/.ssh -sudo touch /var/lib/jenkins/.ssh/known_hosts -sudo ssh-keyscan git.cardiff.ac.uk >> /var/lib/jenkins/.ssh/known_hosts -sudo chmod 644 /var/lib/jenkins/.ssh/known_hosts - - -# If you want jenkins on port 8081 so you can run your app on 8080 then change the default jenkins port. -#(look up linux sed - it is really cool) -# sudo sed -i 's/JENKINS_PORT="8080"/JENKINS_PORT="8081"/g' /etc/sysconfig/jenkins -sudo systemctl start jenkins -systemctl status jenkins -sudo systemctl enable jenkins - -# echo "Installing Java 10..." -# curl -O https://download.java.net/java/GA/jdk10/10.0.2/19aef61b38124481863b1413dce1855f/13/GPL/openjdk-10.0.2_linux-x64_bin.tar.gz -# tar zxvf openjdk-10.0.2_linux-x64_bin.tar.gz -# sudo mv jdk-10.0.2 /usr/local/ -# export JAVA_HOME=/usr/local/jdk-10.0.2 -# export PATH=$PATH:$JAVA_HOME/bin -# java --version -# sudo ln -s /usr/local/jdk-10.0.2/bin/java /usr/bin/java - -# 安装 Gradle 7.6 -echo "Installing gradle..." -# wget https://services.gradle.org/distributions/gradle-6.7.1-bin.zip wget https://services.gradle.org/distributions/gradle-7.6-bin.zip + +sudo yum install unzip -y sudo mkdir /opt/gradle -sudo unzip -q -d /opt/gradle gradle-7.6-bin.zip +sudo unzip -d /opt/gradle gradle-7.6-bin.zip export PATH=$PATH:/opt/gradle/gradle-7.6/bin -echo gradle -v -gradle bootrun & -# 安装 Terraform 1.1.5 -echo "Installing terraform..." -cd /home/rocky -wget https://releases.hashicorp.com/terraform/1.1.5/terraform_1.1.5_linux_amd64.zip -unzip terraform_1.1.5_linux_amd64.zip -sudo mv terraform /usr/local/bin/ +gradle build +gradle bootrun \ No newline at end of file