Skip to content
Snippets Groups Projects
Select Git revision
  • 194efb0b9e9a0374939e4d5259cd39bd1e22cbf6
  • main default
  • xiemuqingxiao
  • YiboDevops
  • zhichengxu
  • sunhaoyu
  • afterTestgood
  • Xiemuqing-Xiao
  • 70-as-an-admin-i-want-to-through-a-table-to-update-new-user-so-that-admin-can-update-user
  • 73-as-a-user-i-want-ranking-can-be-update-by-match-so-that-i-can-see-the-ranking-for-real-time
  • 60-as-a-user-i-want-to-view-and-edit-my-personal-information-on-my-profile-page-so-that-i-can
  • 61-as-a-user-i-want-to-view-and-edit-my-personal-information-on-my-profile-page-so-that-i-can-2
  • 71-as-an-administrator-i-want-to-generate-the-matches-automatically-so-that-players-are-divided-by
  • 72-as-a-user-i-want-to-have-a-page-to-upload-and-share-photos-so-that-another-user-can-see-my
  • 64-as-an-admin-i-want-to-through-a-table-to-add-new-user-so-that-admin-can-give-user-a-new-account
  • 28-registration-feature
  • 71-user-management
  • 70-user-role
  • 71_Xiao
  • 64-as-an-admin-i-want-to-through-a-table-to-add-new-user-so-that-admin-can-give-user-a-new-account-2
  • revert-9d830250
21 results

serverJenkins.sh

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    serverJenkins.sh 5.76 KiB
    #!/usr/bin/bash
    
    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
    sudo yum install git -y
    
    # 安装 OpenSSH
    echo "Installing OpenSSH..."
    sudo yum install -y openssh-server
    
    # 启动并启用 OpenSSH
    echo "Starting and enabling OpenSSH..."
    sudo systemctl start sshd
    sudo systemctl enable sshd
    
    # 检查 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
    
    # 配置用户 SSH 密钥
    echo "installing gitlab deployment key..."
    touch matrix_keypair.key
    cat << `EOF` >> matrix_keypair.key
    -----BEGIN OPENSSH PRIVATE KEY-----
    b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
    NhAAAAAwEAAQAAAQEAy5v5OYLxRCKM05zZJlw4NLuO5d/Of8oMyZ+KeaSGKjTLV+4hg0y/
    qMbuYcTCxTYNFmJ5xk9BnG2I9jffnMovm0ZBnCMZkbtl6J3V+vbYnoAQuGPJWtpOk0Z7OK
    gSokJp8nIKtrhXvPTNpB+MG4xHheord2O6brw1yiAP2WQ2OqNE1Yw+fMzxMZQ3v4MjG5TL
    0qBdIxb1tQLgrnAlyB43w6u2q4eIk+s3rxIpnGnl+Nifq9Sd7MrW8gZtpdwOFNWtP+9fMj
    6wa+HXLsPsBQ+zM9JNCorzuVrLJgQM7+EqgpnhrA9ZNkTrvTV0sKqvCnLoIWdWfon/sZ33
    J+LrLqaz1QAAA9BK1huFStYbhQAAAAdzc2gtcnNhAAABAQDLm/k5gvFEIozTnNkmXDg0u4
    7l385/ygzJn4p5pIYqNMtX7iGDTL+oxu5hxMLFNg0WYnnGT0GcbYj2N9+cyi+bRkGcIxmR
    u2XondX69tiegBC4Y8la2k6TRns4qBKiQmnycgq2uFe89M2kH4wbjEeF6it3Y7puvDXKIA
    /ZZDY6o0TVjD58zPExlDe/gyMblMvSoF0jFvW1AuCucCXIHjfDq7arh4iT6zevEimcaeX4
    2J+r1J3sytbyBm2l3A4U1a0/718yPrBr4dcuw+wFD7Mz0k0KivO5WssmBAzv4SqCmeGsD1
    k2ROu9NXSwqq8KcughZ1Z+if+xnfcn4usuprPVAAAAAwEAAQAAAQEAmJIvJhZl3i2Zo3R0
    D9eo0nL9OGoF3iI0hN1FMbPESVo4SZKKkE3xjHJM7Pw5CvhexDhUkfKP8rztlbr2mBG1rL
    /vqCVxIo/vZGjpkF5qohLK9LDpkGfn21pEOYdQN0BXDbLBLnxiWpiChAqTvYzXh5Sar6MO
    b64fDHAMEFWUgUjCDeGgpFJu1ZSvtJjfZrzz3rJOrwP/lru8tGRw+xnSWMcvZ1Gf5WXEKv
    WNyxOk8zx15Ez9Lh+cOo7PuCfskDbeLUdqP7K2yGW6GwKUfPJ3hDlHk8fA87gJGChX116T
    pmVqVHyc0IRE/Pzw4A3XYujg2PmtddESI3v08QAguToFPQAAAIEAhBXHKo9Wilp3L6vAK3
    1mQpBRPLV/iXoKEAm7q+8uJ5NbN5m+i8gdBp+LUJKpQlW1zj2IpRgHH/Kb8NoNOgA8o9WV
    wOcJ4ZKPkpRo45R/BdhpYa5gIzLNTOVkT2wHmYJX3RtU28Kih9ufwmA1VA5PJ9kJBP6b1Z
    uJq3cigiO20jcAAACBAPNp9v7ao0wTXPse/m54yqbps/IIcLs0vnMSbK2EAmj+tYra0D9+
    qMr5m09ckVbQL+0Oy9JzjLAtpDqoTkUWxdY0AXH8beEoLrINvlcz980ph22m/9uqsJ4YiW
    bs6pt27dbY8go5dWhB+jGCnOoLV+iHlCd+1oCYmItAOOZujpF3AAAAgQDWIx7HEeU8QWEV
    nhINoJKCTk7jUSQwkma4tKjLdgSU+I0EBcx4NR4Cd16mfhSUkLId4rXkQ/qAeusGmP0SSk
    sBG9IHl5LAuaDgXfj7/3+vVR6Ru2ep0ALT0pI0n0kC0aL1J7mq7+XXzxt5k5ONCZJSpfPd
    vNfQn99+1/Zo5LdYEwAAABhJRCtzY21pbWNAV1JBODdFRUFCM0E0NkIB
    -----END OPENSSH PRIVATE KEY-----
    `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 /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
    
    
    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 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 mkdir /opt/gradle
    sudo unzip -q -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/