diff --git a/dist/aliyuncs-install.sh b/dist/aliyuncs-install.sh new file mode 100755 index 0000000000000000000000000000000000000000..2162a53131dabd5f75ceb5fba427ecc0bbaa3e2e --- /dev/null +++ b/dist/aliyuncs-install.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +export MIRROR_SITE="http://mirrors.cloud.aliyuncs.com" +status_code=$(curl --write-out %{http_code} $MIRROR_SITE/anolis/migration/install.sh -o /tmp/install.sh) +[ "$status_code" -eq 200 ] || { + echo "failed to get install.sh" + exit 1 +} +bash /tmp/install.sh $@ +exit_code=$? +[ "$exit_code" -eq 0 ] || exit $exit_code + +if [ x"$1" = "x7to8" ] +then + echo 'epel-release' >> /etc/leapp/transaction/to_remove + echo 'epel-aliyuncs-release' >> /etc/leapp/transaction/to_install + leapp customrepo --seturl $MIRROR_SITE/anolis/8 +fi diff --git a/dist/install.sh b/dist/install.sh new file mode 100755 index 0000000000000000000000000000000000000000..89338f046ffb4643a7b4f0c760abf02fdef0d57c --- /dev/null +++ b/dist/install.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash + +[ "$EUID" -eq 0 ] || { + echo "Please run this script as a root user" + exit 1 +} + +mirror_site="${MIRROR_SITE:-https://mirrors.openanolis.cn}" + +check_if_centos_or_rhel() { + [ -f /etc/centos-release ] && return 0 + [ -f /etc/redhat-release ] && return 0 + echo "CANNOT find /etc/centos-release or /etc/redhat-release, WONT install migration tool" && exit 1 +} + +# config epel +epel_repo_config() { + rpm -q epel-release && return 0 + [ -f /etc/yum.repos.d/epel.repo ] && return 0 + # maybe using filename epel-7.repo since this guide https://developer.aliyun.com/mirror/epel + [ -f /etc/yum.repos.d/epel-7.repo ] && return 0 + [ -f /etc/yum.repos.d/CentOS-Linux-epel.repo ] && return 0 + + major_release=`rpm --eval '%{centos_ver}'` + [ "$?" -eq 0 ] || { + echo "failed to get os major release" + exit 1 + } + + yum install -y epel-release || { + echo "failed to install epel-release" + exit 1 + } + # set better mirror site + sed -i 's|^enabled=1|enabled=0|' /etc/yum.repos.d/epel* + if [ "$major_release" -eq 7 ] + then + cat << EOF > /etc/yum.repos.d/epel.repo +[epel] +name=Extra Packages for Enterprise Linux 7 - \$basearch +enabled=1 +failovermethod=priority +baseurl=https://mirrors.aliyun.com/epel/7/\$basearch + http://mirrors.cloud.aliyuncs.com/epel/7/\$basearch +gpgcheck=0 +EOF + fi + if [ "$major_release" -eq 8 ] + then + cat << EOF > /etc/yum.repos.d/epel.repo +[epel] +name=Extra Packages for Enterprise Linux 8 - \$basearch +baseurl=https://mirrors.aliyun.com/epel/8/Everything/\$basearch + http://mirrors.cloud.aliyuncs.com/epel/8/Everything/\$basearch +failovermethod=priority +enabled=1 +gpgcheck=0 +EOF + fi +} + +# config anolis migration repo +migration_repo_config() { + curl "$mirror_site/anolis/migration/anolis-migration.repo" -o /etc/yum.repos.d/anolis-migration.repo || { + echo "failed to get migration repo" + exit 1 + } + sed -i "s|https://mirrors.openanolis.cn|$mirror_site|" /etc/yum.repos.d/anolis-migration.repo +} + +install_same_version_migtool() { + yum -y install centos2anolis || { + echo "failed to install centos2anolis" + exit 1 + } +} + +install_7to8() { + yum install -y python-pip + yum remove -y python-requests python-urllib3 + /usr/bin/pip2 uninstall requests urllib3 -y 2>/dev/null + yum -y install leapp || { + echo "failed to install leapp" + exit 1 + } +} + +main() { + [ x"$1" = "x7to7" ] || [ x"$1" = "x7to8" ] || [ x"$1" = "x8to8" ] || { + echo "please run command: $0 7to7, $0 8to8, or $0 7to8" + exit 1 + } + check_if_centos_or_rhel + epel_repo_config + migration_repo_config + case $1 in + 7to7) install_same_version_migtool;; + 8to8) install_same_version_migtool;; + 7to8) install_7to8;; + esac +} + +main $@