• gitlab安装脚本


    [root@VM-4-4-centos ~]# cat install_gitlab.sh
    #!/bin/bash
    #

    #说明:安装GitLab 服务器内存建议至少4G,root密码至少8位

    GITLAB_VERSION=12.0.2
    #GITLAB_VERSION=14.1.7
    #GITLAB_VERSION=12.3.5
    . /etc/os-release

    UBUNTU_URL="https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu/pool/${UBUNTU_CODENAME}/main/g/gitlab-ce/gitlab-ce_${GITLAB_VERSION}-ce.0_amd64.deb"
    RHEL_URL=https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-${GITLAB_VERSION}-ce.0.el7.x86_64.rpm


    HOST=gitlab.zxk.org
    DOWNLOAD_DIR=/usr/local/src
    GITLAB_ROOT_PASSWORD=12345678
    SMTP_PASSWORD=XLGWWWGMCVZSPDDY
    #HOST=`hostname -I|awk '{print $1}'`


    color () {
    RES_COL=60
    MOVE_TO_COL="echo -en \\033[${RES_COL}G"
    SETCOLOR_SUCCESS="echo -en \\033[1;32m"
    SETCOLOR_FAILURE="echo -en \\033[1;31m"
    SETCOLOR_WARNING="echo -en \\033[1;33m"
    SETCOLOR_NORMAL="echo -en \E[0m"
    echo -n "$1" && $MOVE_TO_COL
    echo -n "["
    if [ $2 = "success" -o $2 = "0" ] ;then
    ${SETCOLOR_SUCCESS}
    echo -n $" OK "
    elif [ $2 = "failure" -o $2 = "1" ] ;then
    ${SETCOLOR_FAILURE}
    echo -n $"FAILED"
    else
    ${SETCOLOR_WARNING}
    echo -n $"WARNING"
    fi
    ${SETCOLOR_NORMAL}
    echo -n "]"
    echo
    }

    install_gitlab() {
    if [ $ID = "centos" -o $ID = "rocky" ];then
    PACK="${RHEL_URL##*/}"
    echo $PACK
    # [ ! -e $PACK ] && wget ${RHEL_URL} || { color "下载失败!" 1 ;exit ; }
    yum -y install $PACK
    elif [ $ID = "ubuntu" ];then
    PACK="${UBUNTU_URL##*/}"
    echo $PACK
    echo ${UBUNTU_URL}
    if [ ! -e $PACK ];then
    wget ${UBUNTU_URL} || { color "下载失败!" 1 ;exit ; }
    fi
    dpkg -i $PACK
    else
    color '不支持当前操作系统!' 1
    exit
    fi
    if [ $? -eq 0 ];then
    color "安装 GitLab完成!" 0
    else
    color "安装 GitLab失败!" 1
    exit
    fi
    }
    config_gitlab() {
    sed -i.bak "/^external_url.*/c external_url \'http://$HOST\'" /etc/gitlab/gitlab.rb
    cat >> /etc/gitlab/gitlab.rb <gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = "smtp.qq.com"
    gitlab_rails['smtp_port'] = 465
    gitlab_rails['smtp_user_name'] = "1043490960@qq.com"
    gitlab_rails['smtp_password'] = "$SMTP_PASSWORD"
    gitlab_rails['smtp_domain'] = "qq.com"
    gitlab_rails['smtp_authentication'] = "login"
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['smtp_tls'] = true
    gitlab_rails['gitlab_email_from'] = "1043490960@qq.com"
    gitlab_rails['initial_root_password'] = "$GITLAB_ROOT_PASSWORD"
    EOF
    gitlab-ctl reconfigure
    gitlab-ctl status
    if [ $? -eq 0 ];then
    echo
    color "Gitlab安装完成!" 0
    echo "-------------------------------------------------------------------"
    echo -e "请访问链接: \E[32;1mhttp://$HOST/\E[0m"
    echo -e "用户和密码: \E[32;1mroot/${GITLAB_ROOT_PASSWORD}\E[0m"
    else
    color "Gitlab安装失败!" 1
    exit
    fi
    }


    install_gitlab

    config_gitlab

     登录验证:

  • 相关阅读:
    linux下程序分析工具总结
    电脑经常弹出“不支持的硬件”解决办法
    云服务器如何选?腾讯云2核2G3M云服务器88元一年!
    数据库 设计规范数据库设计样例
    C++模板
    .NET WebAPI 自定义 NullableConverter 解决可为空类型字段入参“”空字符触发转换异常问题
    重磅首发!PaddleTS飞桨时序建模算法库,预测性维护、智慧能耗分析等一网打尽
    未来社区的人车房隐私数据权属确认方法
    前端第二课,HTML,alt,title,width/heigh,border,<a>超链接,target,tr,td,th
    从new File("")到jdk源码
  • 原文地址:https://blog.csdn.net/epmgy315/article/details/131119348