release判断系统

#!/bin/bash
# Name: Atomic Archive configuration script
# Copyright Atomicorp, 2002-2018
# License: AGPL
# Credits
# 	Scott R. Shinn (atomicorp)
#	Andy Gredler  (rackspace)
#

export LANG=C
ATOMIC_VER="4.0.1"
VERSION="1.0-21"
SERVER=updates.atomicorp.com
ARCH=`uname -i`

# Input validation function
# check_input <msg> <valid responses regex> <default>
# if <default> is passed on as null, then there is no default
# Example: check_input  "Some question (yes/no) " "yes|no"  "yes"
check_input () {
  message=$1
  validate=$2
  default=$3

  while [ $? -ne 1 ]; do
    echo -n "$message "
    read INPUTTEXT < /dev/tty
    if [ "$INPUTTEXT" == "" -a "$default" != "" ]; then
      INPUTTEXT=$default
      return 1
    fi
    echo $INPUTTEXT | egrep -q "$validate" && return 1
    echo "Invalid input"
  done

}

echo
echo "Atomic Free Unsupported Archive installer, version $ATOMIC_VER"
echo
echo "BY INSTALLING THIS SOFTWARE AND BY USING ANY AND ALL SOFTWARE"
echo "PROVIDED BY ATOMICORP LIMITED YOU ACKNOWLEDGE AND AGREE:"
echo
echo "THIS SOFTWARE AND ALL SOFTWARE PROVIDED IN THIS REPOSITORY IS "
echo "PROVIDED BY ATOMICORP LIMITED AS IS, IS UNSUPPORTED AND ANY"
echo "EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE"
echo "IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR"
echo "PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ATOMICORP LIMITED, THE"
echo "COPYRIGHT OWNER OR ANY CONTRIBUTOR TO ANY AND ALL SOFTWARE PROVIDED"
echo "BY OR PUBLISHED IN THIS REPOSITORY BE LIABLE FOR ANY DIRECT,"
echo "INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES"
echo "(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS"
echo "OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)"
echo "HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,"
echo "STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)"
echo "ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED"
echo "OF THE POSSIBILITY OF SUCH DAMAGE."
echo
echo "For supported software packages please contact us at: "
echo
echo "  [email protected]"
echo

if [ ! $NON_INT ]; then
	check_input "Do you agree to these terms? (yes/no) [Default: yes]" "yes|no" "yes"
	query=$INPUTTEXT
fi

if [ "$query" == "no" ]; then
  echo "Exiting"
  echo
  exit 1
fi

echo
echo "Configuring the [atomic] repo archive for this system "
echo

# Detect release type
if [ -f /etc/redhat-release ]; then
        RELEASE=/etc/redhat-release
elif [ -f /etc/os-release ]; then
        RELEASE=/etc/os-release
elif [ -f /etc/openvz-release ]; then
        RELEASE=/etc/openvz-release
elif [ -f /etc/SuSE-release ]; then
        RELEASE=/etc/SuSE-release
elif [ -f /etc/os-release ]; then
        RELEASE=/etc/os-release
elif [ -f /etc/lsb-release ]; then
        RELEASE=/etc/lsb-release
elif [ -f /etc/debian_version ]; then
        RELEASE=/etc/debian_version
elif [ -f /etc/openvz-release ]; then
	RELEASE=/etc/openvz-release
elif [ -f /etc/virtuozzo-release ]; then
	RELEASE=/etc/virtuozzo-release
else
        echo "Error: unable to identify operating system"
        exit 1
fi

PKG=rpm

if grep -q "Red Hat Linux release 9  " $RELEASE ; then
  DIST="rh9"
  DIR=redhat/9
  echo
  echo "$RELEASE is no longer supported."
  echo
  exit 1
elif grep -q "Fedora Core release 2 " $RELEASE ; then
  DIST="fc2"
  DIR=fedora/2
  echo
  echo "$RELEASE is no longer supported."
  echo
  exit 1
elif grep -q "Fedora Core release 3 " $RELEASE ; then
  DIST="fc3"
  DIR=fedora/3
  echo
  echo "$RELEASE is no longer supported."
  echo
  exit 1
  #YUMDEPS="fedora-release python-elementtree python-sqlite python-urlgrabber yum"
elif grep -q "Fedora Core release 4 " $RELEASE ; then
  DIST="fc4"
  DIR=fedora/4
  echo "$RELEASE is no longer supported."
  echo
  exit 1
elif grep -q "Fedora Core release 5 " $RELEASE ; then
  DIST="fc5"
  DIR=fedora/5
  echo "$RELEASE is no longer supported."
  echo
  exit 1
elif grep -q "Fedora Core release 6 " $RELEASE ; then
  DIST="fc6"
  DIR=fedora/6
elif grep -q "Fedora release 7 " $RELEASE ; then
  DIST="fc7"
  DIR=fedora/7
elif grep -q "Fedora release 8 " $RELEASE ; then
  DIST="fc8"
  DIR=fedora/8
elif grep -q "Fedora release 9 " $RELEASE ; then
  DIST="fc9"
  DIR=fedora/9
elif grep -q "Fedora release 10 " $RELEASE ; then
  DIST="fc10"
  DIR=fedora/10
elif grep -q "Fedora release 11 " $RELEASE ; then
  DIST="fc11"
  DIR=fedora/11
elif grep -q "Fedora release 12 " $RELEASE ; then
  DIST="fc12"
  DIR=fedora/12
elif grep -q "Fedora release 13 " $RELEASE ; then
  DIST="fc13"
  DIR=fedora/13
elif grep -q "Fedora release 14 " $RELEASE ; then
  DIST="fc14"
  DIR=fedora/14
elif grep -q "Fedora release 15 " $RELEASE ; then
  DIST="fc15"
  DIR=fedora/15
elif grep -q "Fedora release 16 " $RELEASE ; then
  DIST="fc16"
  DIR=fedora/16
elif grep -q "Fedora release 17 " $RELEASE ; then
  DIST="fc17"
  DIR=fedora/17
elif grep -q "Fedora release 18 " $RELEASE ; then
  DIST="fc18"
  DIR=fedora/18
elif grep -q "Fedora release 19 " $RELEASE ; then
  DIST="fc19"
  DIR=fedora/19
elif grep -q "Fedora release 20 " $RELEASE ; then
  DIST="fc20"
  DIR=fedora/20
elif grep -q "Fedora release 21 " $RELEASE ; then
  DIST="fc21"
  DIR=fedora/21
elif grep -q "Fedora release 22 " $RELEASE ; then
  DIST="fc22"
  DIR=fedora/22
elif grep -q "Fedora release 23 " $RELEASE ; then
  DIST="fc23"
  DIR=fedora/23
elif grep -q "Fedora release 24 " $RELEASE ; then
  DIST="fc24"
  DIR=fedora/24
elif grep -q "Fedora release 25 " $RELEASE ; then
  DIST="fc25"
  DIR=fedora/25
elif grep -q "Fedora release 26 " $RELEASE ; then
  DIST="fc26"
  DIR=fedora/26
elif grep -q "Fedora release 27 " $RELEASE ; then
  DIST="fc27"
  DIR=fedora/27
elif grep -q "Fedora release 28 " $RELEASE ; then
  DIST="fc28"
  DIR=fedora/28
elif grep -q "Fedora release 29 " $RELEASE ; then
  DIST="fc29"
  DIR=fedora/29

elif egrep -q "Red Hat Enterprise Linux (A|E)S release 3 " $RELEASE ; then
  DIST="el3"
  DIR=redhat/3
  echo
  echo "$RELEASE is not supported at this time, you will need to configure yum manually:"
  echo "see http://$SERVER/channels for instructions"
  echo
  exit 1
elif grep -q "CentOS release 3" $RELEASE ; then
  DIST="el3"
  DIR=centos/3
  echo
  echo "$RELEASE is not supported at this time, you will need to configure yum manually:"
  echo "see http://$SERVER/channels for instructions"
  echo
  exit 1
elif egrep -q "Red Hat Enterprise Linux (A|E|W)S release 4" $RELEASE ; then
  DIST="el4"
  DIR=redhat/4
  echo "$RELEASE is not supported at this time, you will need to configure yum manually:"
  echo "see http://$SERVER/channels for instructions"
  echo
  exit 1
elif egrep -q "Red Hat Enterprise Linux.*release 5" $RELEASE ; then
  DIST="el5"
  DIR=redhat/5
elif egrep -q "Red Hat Enterprise Linux.*release 6" $RELEASE ; then
  DIST="el6"
  DIR=redhat/6
elif egrep -q "Red Hat Enterprise Linux.* 7" $RELEASE ; then
  DIST="el7"
  DIR=redhat/7
elif grep -q "CentOS release 3" $RELEASE ; then
  DIST="el3"
  DIR=centos/3
  echo "$RELEASE is not supported at this time, you will need to configure yum manually:"
  echo "see http://$SERVER/channels for instructions"
  echo
elif grep -q "CentOS release 4" $RELEASE ; then
  DIST="el4"
  DIR=centos/4
  echo "$RELEASE is not supported at this time, you will need to configure yum manually:"
  echo "see http://$SERVER/channels for instructions"
  echo
elif egrep -q "(release 5|release 2011)" $RELEASE ; then
  DIST="el5"
  DIR=centos/5
elif egrep -q "(release 6|release 2012)" $RELEASE ; then
  DIST="el6"
  DIR=centos/6
elif egrep -q "(release 7|release 2014)" $RELEASE ; then
  DIST="el7"
  DIR=centos/7
elif egrep -q "(Amazon Linux AMI|Amazon).*LTS" $RELEASE ; then
  DIST="amazon-2"
  DIR=amazon/2
  PKG="amazon"
elif egrep -q "(Amazon Linux AMI|Amazon)" $RELEASE ; then
  DIST="amazon-1"
  DIR=amazon/1
  PKG="amazon"
elif egrep -q "openSUSE 12" $RELEASE ; then
  DIST="suse12"
  DIR=opensuse/12
elif egrep -q "openSUSE 13" $RELEASE ; then
  DIST="suse13"
  DIR=opensuse/13
elif egrep -q "^6.0" $RELEASE ; then
  DIST="debian"
  DIR="squeeze"
  PKG=deb
elif egrep -q "wheezy" $RELEASE ; then
  DIST="debian"
  DIR="wheezy"
  PKG=deb
elif egrep -q "jessie" $RELEASE ; then
  DIST="debian"
  DIR="jessie"
  PKG=deb
elif egrep -q "stretch" $RELEASE ; then
  DIST="debian"
  DIR="stretch"
  PKG=deb
elif egrep -q "lucid" $RELEASE ; then
  DIST="ubuntu"
  DIR="lucid"
  PKG=deb
elif egrep -q "precise" $RELEASE ; then
  DIST="ubuntu"
  DIR="precise"
  PKG=deb
elif egrep -q "Raring Ringtail" $RELEASE ; then
  DIST="ubuntu"
  DIR="raring"
  PKG=deb
elif egrep -q "Trusty Tahr" $RELEASE ; then
  DIST="ubuntu"
  DIR="trusty"
  PKG=deb
elif egrep -q "Xenial|Mint" $RELEASE ; then
  DIST="ubuntu"
  DIR="xenial"
  PKG=deb
elif egrep -qi "artful" $RELEASE ; then
  DIST="ubuntu"
  DIR="artful"
  PKG=deb
elif egrep -qi "bionic" $RELEASE ; then
  DIST="ubuntu"
  DIR="bionic"
  PKG=deb
elif egrep -qi "kali" $RELEASE ; then
  DIST="kali"
  DIR="kali"
  PKG=deb
else
  echo "Error: Unable to determine distribution type. Please send the contents of $RELEASE to [email protected]"
  exit 1
fi

# Manual for amazon
amazon_install () {

	rpm -import RPM-GPG-KEY.atomicorp.txt >/dev/null 2>&1
	rpm -import RPM-GPG-KEY.art.txt >/dev/null 2>&1

	if [ ! -f /etc/pki/rpm-gpg/RPM-GPG-KEY.atomicorp.txt ]; then
		mv /root/RPM-GPG-KEY.atomicorp.txt /etc/pki/rpm-gpg/RPM-GPG-KEY.atomicorp.txt
	fi

	if [ -f /etc/yum.repos.d/atomic.repo ]; then
		rm -f /etc/yum.repos.d/atomic.repo
	fi

	cat  << EOF > /etc/yum.repos.d/atomic.repo
[atomic]
name=Atomicorp Amazon Linux - atomic
mirrorlist=https://updates.atomicorp.com/channels/mirrorlist/atomic/$DIST-x86_64
priority=1
enabled=1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY.atomicorp.txt
gpgcheck=1

[atomic-testing]
name=Atomicorp Amazon Linux - atomic-testing
mirrorlist=https://updates.atomicorp.com/channels/mirrorlist/atomic-testing/$DIST-x86_64
priority=1
enabled=0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY.atomicorp.txt
gpgcheck=1

EOF

}

# RPM Distros
yum_install () {

	ATOMIC=atomic-release-$VERSION.$DIST.art.noarch.rpm

	if [ ! -f /usr/bin/yum ]; then
		echo
		echo "Error: Yum was not detected. Contact your provider for support." | tee -a $LOG
		echo
		exit 1
	fi

	if rpm -q atomic-release > /dev/null ; then
		if [ ! -f /etc/yum.repos.d/atomic.repo ]; then
			rpm -e atomic-release
		fi

	fi

	rpm -import RPM-GPG-KEY.art.txt >/dev/null 2>&1
	rpm -import RPM-GPG-KEY.atomicorp.txt >/dev/null 2>&1

    	echo -n "Downloading $ATOMIC: "
    	wget -q http://$SERVER/channels/atomic/$DIR/$ARCH/RPMS/$ATOMIC >/dev/null 2>&1
	if [ $? -ne 0 ]; then
		echo "Error: File $ATOMIC not found."
		echo
		exit
	fi

    	if [ -f $ATOMIC ]; then
      		rpm -Uvh $ATOMIC  || exit 1
      		rm -f $ATOMIC
    	else
      		echo "ERROR: $ATOMIC was not downloaded."
      		exit 1
    	fi

    	echo "OK"

	if [ ! -f /etc/yum.repos.d/atomic.repo ]; then
		echo "Error: /etc/yum.repos.d/atomic.repo was not detected."
		exit 1
	fi

	if [ ! $NON_INT ]; then
		echo
		check_input "Enable repo by default? (yes/no) [Default: yes]:" "yes|no" "yes"
		query=$INPUTTEXT
		if [ "$query" == "no" ]; then
			sed -i ‘s/enabled = 1/enabled = 0/‘ /etc/yum.repos.d/atomic.repo
		fi

	fi

}

# DEB Distros
apt_install () {

	cat RPM-GPG-KEY.atomicorp.txt | apt-key add - >/dev/null 2>&1

	if [ -d /etc/apt/sources.list.d/ ]; then
		APT_SOURCES="/etc/apt/sources.list.d/atomic.list"

		echo -n "Adding [atomic] to $APT_SOURCES: "
		if [ ! -f $APT_SOURCES ]; then
			echo "deb https://updates.atomicorp.com/channels/atomic/$DIST $DIR main" > $APT_SOURCES
			echo "OK"
		else
			echo "Already installed"
		fi

	else
		APT_SOURCES="/etc/apt/sources.list"
		echo -n "Adding [atomic] to $APT_SOURCES: "
		if ! grep -q "atomic/$DIST $DIR" $APT_SOURCES ; then
			echo "deb https://updates.atomicorp.com/channels/atomic/$DIST $DIR main" >> /etc/apt/sources.list
			echo "OK"
		else
			echo "Already installed"
		fi
	fi

}

# Installation

# GPG Keys
echo -n "Installing the Atomic GPG keys: "
if [ ! -f RPM-GPG-KEY.art.txt ]; then
  wget -q https://www.atomicorp.com/RPM-GPG-KEY.art.txt 1>/dev/null 2>&1
fi

if [ ! -f RPM-GPG-KEY.atomicorp.txt ]; then
  wget -q https://www.atomicorp.com/RPM-GPG-KEY.atomicorp.txt 1>/dev/null 2>&1
fi
echo "OK"
echo

if [ "$PKG" == "rpm" ]; then
	yum_install
elif [ "$PKG" == "deb" ]; then
	apt_install
elif [ "$PKG" == "amazon" ]; then
	amazon_install

fi

echo
echo
echo "The Atomic repo has now been installed and configured for your system"
echo "The following channels are available:"
echo "  atomic          - [ACTIVATED] - contains the stable tree of ART packages"
echo "  atomic-testing  - [DISABLED]  - contains the testing tree of ART packages"
echo "  atomic-bleeding - [DISABLED]  - contains the development tree of ART packages"
echo
echo

原文地址:https://www.cnblogs.com/xiaoyaoren/p/10119656.html

时间: 2024-10-22 03:11:17

release判断系统的相关文章

写程序判断系统是大端序还是小端序

大端是高位字节先存储(低地址) 小端是低位字节先存储(低地址) 网络字节序是大端的,也就是高位字节先传输 而int--char的强制转换,是将低地址的数值截断赋给char,利用这个准则可以判断系统是大端序还是小端序 #include <iostream> using namespace std; int main() { int a = 0x1234; char c = static_cast<char>(a); if (c == 0x12) cout << "

Linux判断CPU是32位还是64位,判断系统是32位还是64位

from:http://www.ipcpu.com/2010/08/linux-cpu-32-64/ 本文仅限于服务器CPU和Linux系统讨论,与台式电脑.笔记本无关. 32位.64位不能乱装,64的能装32位的,因为64位的CPU可以兼容32位,32位的装不了64位的.最近部署了MongoDB,系统是32位的提示会有最大文件2G的限制.还有最常见的问题32位系统不支持4G以上内存,即使打PAE效率也受影响. 1.判断CPU是32位还是64位 这个问题比较有意思,网上给出的办法都是判断了系统的

C语言判断系统数据大/小端存储方式

小端存储:数据的低位部分,存储于存储器的低地址空间里. 大端存储:数据的低位部分,存储于存储器的高地址空间里. 首先,一般PC数据存储方式是小端存储. 基本实现思想是:将存储器中所存的数据按字节以地址顺序输出,与存入数据的高低位进行比较,即得出结论. 实现方法一: 1 #include <stdio.h> 2 int main(void) 3 { 4 short int x; 5 char *arr; 6 7 x = 0x1122; 8 arr = (char *)&x; 9 10 i

判断系统是大端还是小端的两种方法

#include <iostream> #include <stdio.h> #include <malloc.h> #include <string.h> using namespace std; //判断系统是大端还是小端:通过将&int转换为char* int fun() { int num = 1; // *((char*)&num)获得num的最低字节,为0x00,说明是大端 为0x01,说明是小端 return *((char*)

C#判断系统是64位还是32位 支持.net4.0以前的版本

C#判断系统是64位还是32位的时候引用了一串代码,这个代码是从园子里面其他博文中转载过来的,引入自己的项目中发现无法使用,在引用了相应的命名空间之后还是提示: "未能找到类型或命名空间名称"ConnectionOptions"(是否缺少 using 指令或程序集引用?)": 除了使用 using System.Management; 还需要在解决方案的"引用"中引用才能够起作用,   private string Distinguish64or

Android底层开发之Linux输入子系统要不要判断系统休眠状态上报键值

Android底层开发之Linux输入子系统要不要判断系统休眠状态上报键值 题外话:一个问题研究到最后,那边记录文档的前半部分基本上都是无用的,甚至是错误的.重点在最后,前边仅仅是一些假想推测. http://blog.csdn.net/kangear/article/details/40072707 在调试一下红外遥控器input驱动时,直接采用的是一个半成品的驱动在上边实现的自己的设备的匹配,但同时遇到了一些关于input输入子系统的疑惑. 按键一般有「按下和抬起」两个状态一般使用0和1来分

判断系统版本

//判断系统版本:如果当前系统高于7.0版本, if ([[UIDevice currentDevice].systemVersion doubleValue]>=7.0) { }else{ //如果当前系统版本低于7.0版本 }

实现对UIAlertController和UIAlertView判断系统后的简单封装

iOS8之后用UIAlertController代替了UIAlertView,所以每次有需要弹窗的时候,都需要先判断系统,最近在做的项目中弹窗较多,如果每次都判断,真是太麻烦了,索性对UIAlertController和UIAlertView进行的封装了,封装在一个工具类中,在工具类中就对系统进行判断,然后在你需要弹窗的界面直接调用这个工具类的方法就可以了,减少了代码的耦合. 这个工具类其实也封装的特别简单,因为都是用的系统的,分享出来给大家参考下: 首先是.h文件 @interface UIA

如何判断系统是32位还是64位的linux系统

如何判断系统是32位还是64位的linux系统 某日,需要下载个安装包,忽然忘记了自己的系统是32位还是64位的系统了,一时想不起来怎么查看时32位还是64位,呵呵,随便百度下,就发现有好多方法,这里记录下,方便日后查询: 第一种: 12345 [root@CentOS62 ~]# uname -mi686 [root@436704 ~]# uname -mx86_64 第二种: 12345 [root@CentOS62 ~]# file /sbin/init/sbin/init: ELF 32