设为首页 收藏本站
查看: 933|回复: 0

[经验分享] gitlab rpm包直接安装

[复制链接]

尚未签到

发表于 2018-9-19 10:12:07 | 显示全部楼层 |阅读模式
#!/bin/bashunknown_os ()  
{  echo "Unfortunately, your operating system distribution and version are not supported by this script."
  
  echo
  
  echo "You can override the OS detection by setting os= and dist= prior to running this script."
  
  echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
  
  echo
  
  echo "For example, to force CentOS 6: os=el dist=6 ./script.sh"
  
  echo
  
  echo "Please email support@packagecloud.io and let us know if you run into any issues."
  
  exit 1
  
}curl_check ()
  
{  echo "Checking for curl..."
  
  if command -v curl > /dev/null; then
  
    echo "Detected curl..."
  
  else
  
    echo "Installing curl..."
  
    yum install -d0 -e0 -y curl  fi}detect_os ()
  
{  if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then
  
    if [ -e /etc/os-release ]; then
  
      . /etc/os-release
  
      dist=`echo ${VERSION_ID} | awk -F '.' '{ print $1 }'`
  
      os=${ID}
  

  
    elif [ `which lsb_release 2>/dev/null` ]; then
  
      # get major version (e.g. '5' or '6')
  
      dist=`lsb_release -r | cut -f2 | awk -F '.' '{ print $1 }'`      # get os (e.g. 'centos', 'redhatenterpriseserver', etc)
  
      os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'`    elif [ -e /etc/oracle-release ]; then
  
      dist=`cut -f5 --delimiter=' ' /etc/oracle-release | awk -F '.' '{ print $1 }'`
  
      os='ol'
  

  
    elif [ -e /etc/fedora-release ]; then
  
      dist=`cut -f3 --delimiter=' ' /etc/fedora-release`
  
      os='fedora'
  

  
    elif [ -e /etc/redhat-release ]; then
  
      os_hint=`cat /etc/redhat-release  | awk '{ print tolower($1) }'`      if [ "${os_hint}" = "centos" ]; then
  
        dist=`cat /etc/redhat-release | awk '{ print $3 }' | awk -F '.' '{ print $1 }'`
  
        os='centos'
  
      elif [ "${os_hint}" = "scientific" ]; then
  
        dist=`cat /etc/redhat-release | awk '{ print $4 }' | awk -F '.' '{ print $1 }'`
  
        os='scientific'
  
      else
  
        dist=`cat /etc/redhat-release  | awk '{ print tolower($7) }' | cut -f1 --delimiter='.'`
  
        os='redhatenterpriseserver'
  
      fi
  

  
    else
  
      aws=`grep -q Amazon /etc/issue`      if [ "$?" = "0" ]; then
  
        dist='6'
  
        os='aws'
  
      else
  
        unknown_os      fi
  
    fi
  
  fi
  

  
  if [[ ( -z "${os}" ) || ( -z "${dist}" ) || ( "${os}" = "opensuse" ) ]]; then
  
    unknown_os  fi
  

  
  # remove whitespace from OS and dist name
  
  os="${os// /}"
  
  dist="${dist// /}"
  

  
  echo "Detected operating system as ${os}/${dist}."}main ()
  
{
  
  detect_os
  
  curl_check
  

  

  
  yum_repo_config_url="https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.repo?os=${os}&dist=${dist}&source=script"
  

  
  yum_repo_path=/etc/yum.repos.d/gitlab_gitlab-ce.repo  echo "Downloading repository file: ${yum_repo_config_url}"
  

  
  curl -sSf "${yum_repo_config_url}" > $yum_repo_path
  
  curl_exit_code=$?  if [ "$curl_exit_code" = "22" ]; then
  
    echo
  
    echo
  
    echo -n "Unable to download repo config from: "
  
    echo "${yum_repo_config_url}"
  
    echo
  
    echo "This usually happens if your operating system is not supported by "
  
    echo "packagecloud.io, or this script's OS detection failed."
  
    echo
  
    echo "You can override the OS detection by setting os= and dist= prior to running this script."
  
    echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
  
    echo
  
    echo "For example, to force CentOS 6: os=el dist=6 ./script.sh"
  
    echo
  
    echo "If you are running a supported OS, please email support@packagecloud.io and report this."
  
    [ -e $yum_repo_path ] && rm $yum_repo_path
  
    exit 1  elif [ "$curl_exit_code" = "35" ]; then
  
    echo
  
    echo "curl is unable to connect to packagecloud.io over TLS when running: "
  
    echo "    curl ${yum_repo_config_url}"
  
    echo
  
    echo "This is usually due to one of two things:"
  
    echo
  
    echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)"
  
    echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version"
  
    echo
  
    echo "Contact support@packagecloud.io with information about your system for help."
  
    [ -e $yum_repo_path ] && rm $yum_repo_path
  
    exit 1  elif [ "$curl_exit_code" -gt "0" ]; then
  
    echo
  
    echo "Unable to run: "
  
    echo "    curl ${yum_repo_config_url}"
  
    echo
  
    echo "Double check your curl installation and try again."
  
    [ -e $yum_repo_path ] && rm $yum_repo_path
  
    exit 1  else
  
    echo "done."
  
  fi
  

  
  echo "Installing pygpgme to verify GPG signatures..."
  
  yum install -y pygpgme --disablerepo='gitlab_gitlab-ce'
  
  pypgpme_check=`rpm -qa | grep -qw pygpgme`  if [ "$?" != "0" ]; then
  
    echo
  
    echo "WARNING: "
  
    echo "The pygpgme package could not be installed. This means GPG verification is not possible for any RPM installed on your system. "
  
    echo "To fix this, add a repository with pygpgme. Usualy, the EPEL repository for your system will have this. "
  
    echo "More information: https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F"
  
    echo
  

  
    # set the repo_gpgcheck option to 0
  
    sed -i'' 's/repo_gpgcheck=1/repo_gpgcheck=0/' /etc/yum.repos.d/gitlab_gitlab-ce.repo  fi
  

  
  echo "Installing yum-utils..."
  
  yum install -y yum-utils --disablerepo='gitlab_gitlab-ce'
  
  yum_utils_check=`rpm -qa | grep -qw yum-utils`  if [ "$?" != "0" ]; then
  
    echo
  
    echo "WARNING: "
  
    echo "The yum-utils package could not be installed. This means you may not be able to install source RPMs or use other yum features."
  
    echo
  
  fi
  

  
  echo "Generating yum cache for gitlab_gitlab-ce..."
  
  yum -q makecache -y --disablerepo='*' --enablerepo='gitlab_gitlab-ce'
  

  
  echo
  
  echo "The repository is setup! You can now install packages."}
  

  
main



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-594132-1-1.html 上篇帖子: Centos编译安装gitlab版本控制系统 下篇帖子: CentOS 下gitlab-8.5安装配置
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表