[步骤] PXE 新系统模板的添加

步骤一:准备安装镜像

1.1 从官网上下载安装镜像

(步骤略)

1.2 挂载安装镜像

1.2.1 创建用于挂载安装镜像的目录
# mkdir <directory for mounting the image>
1.2.2 挂载安装镜像
# mount -t iso9660 <image> <directory for mounting the image>

步骤二:准备用于进行 PXE 安装的数据

2.1 准备系统安装数据

2.1.1 创建用于存放系统安装数据的目录
# mkdir <directory of data for installing the system>

(注意:用于存放系统安装数据的目录必须要放在能够实现 PXE 安装时网络共享的目录里(例如:通过 httpd 服务进行网络共享))

2.1.2 拷贝安装镜像里的数据到用于存放系统安装数据的目录
2.1.2.1 拷贝安装镜像里的普通数据到用于存放系统安装数据的目录
# cp -rp <directory for mounting the image>/* <directory of data for installing the system>
2.1.2.2 拷贝安装镜像里的 .treeinfo 文件到用于存放系统安装数据的目录
# cp -rp <directory for mounting the image>/.treeinfo <directory of data for installing the system>

2.2 准备安装引导文件

2.2.1 创建用于存放安装引导文件的目录
2.2.1.1 创建用于存放 BIOS 安装引导文件的目录
# mkdir <directory of BIOS boot file for installing the system>

(注意:用于存放 BIOS 安装引导文件的目录必须要放在能够实现 TFPT 网络共享的目录里)

2.2.1.2 创建用于存放 EFI 安装引导文件的目录
# mkdir <directory of EFI boot file for installing the system>

(注意:用于存放 EFI 安装引导文件的目录必须要放在能够实现 TFPT 网络共享的目录里)

2.2.2 拷贝安装镜像里的安装引导文件到存放安装引导文件的目录
2.2.2.1 拷贝安装镜像里的 BIOS 安装引导文件到存放 BIOS 安装引导文件的目录

如果是 Rocky Linux & RHEL 则拷贝 initrd.img 文件、TRANS.TBL 文件和 vmlinuz 文件:

# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/images/pxeboot/initrd.img -O <directory of BIOS boot file for installing the system>/initrd.img
# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/images/pxeboot/TRANS.TBL -O <directory of BIOS boot file for installing the system>/TRANS.TBL
# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/images/pxeboot/vmlinuz -O <directory of BIOS boot file for installing the system>/vmlinuz

如果是 openSUSE & SLE 则拷贝 linux 文件和 initrd 文件:

# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/boot/x86_64/loader/linux -O <directory of BIOS boot file for installing the system>/linux
# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/boot/x86_64/loader/initrd -O <directory of BIOS boot file for installing the system>/initrd
2.2.2.2 拷贝安装镜像里的 EFI 安装引导文件到存放 EFI 安装引导文件的目录

如果是 Rocky Linux & RHEL 则拷贝 initrd.img 文件、TRANS.TBL 文件和 vmlinuz 文件:

# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/images/pxeboot/initrd.img -O <directory of EFI boot file for installing the system>/initrd.img
# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/images/pxeboot/TRANS.TBL -O <directory of EFI boot file for installing the system>/TRANS.TBL
# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/images/pxeboot/vmlinuz -O <directory of EFI boot file for installing the system>/vmlinuz

如果是 openSUSE & SLE 则拷贝 linux 文件和 initrd 文件:

# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/boot/x86_64/loader/linux -O <directory of EFI boot file for installing the system>/linux
# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/boot/x86_64/loader/initrd -O <directory of EFI boot file for installing the system>/initrd

2.3 准备系统安装配置文件

2.3.1 进入到用于存放系统安装配置文件的目录
# cd <directory of profile for installing the system>

(注意:进入到用于存放系统安装配置文件的目录必须要放在能够实现 PXE 安装时网络共享的目录里(例如:通过 httpd 服务进行网络共享))

2.3.2 创建系统安装配置文件
2.3.2.1 创建 BIOS 系统安装配置文件

如果是 Rocky Linux & RHEL 的话

# vim <BIOS system installation profile>

(步骤略)


补充:
1) 如果是 Rocky Linux & RHEL 的话系统安装配置文件是 CFG 文件,文件名最好以 .cfg 后缀结尾
2) 如果是 openSUSE & SLE 的话系统安装配置文件是 XML 文件,文件名最好以 .xml 后缀结尾

2.3.2.2 创建 EFI 系统安装配置文件
# vim <EFI system installation profile>

(步骤略)


补充:
1) 如果是 Rocky Linux & RHEL 的话系统安装配置文件是 CFG 文件,文件名最好以 .cfg 后缀结尾
2) 如果是 openSUSE & SLE 的话系统安装配置文件是 XML 文件,文件名最好以 .xml 后缀结尾

2.3.3 设置系统安装配置文件的权限
2.3.3.1 设置 BIOS 系统安装配置文件的权限
# chmod 755 <BIOS system installation profile>
2.3.3.2 设置 EFI 系统安装配置文件的权限
# chmod 755 <EFI system installation profile>

2.4 修改系统安装菜单文件 pxelinux.cfg

2.4.1 修改 BIOS 系统安装菜单文件 pxelinux.cfg
# vim <directory of file for BIOS system installation menu>/pxelinux.cfg

如果是 Rocky Linux & RHEL 的话,添加以下内容:

......
label Rocky Linux or RHEL
  menu label ^Installation Rocky Linux or RHEL
  kernel <relative directory of pxelinux.cfg of BIOS boot file for installing the system>/vmlinuz
  append initrd=/<relative directory of pxelinux.cfg of BIOS boot file for installing the system>/initrd.img ks=<The URL of the network share when PXE installing>/<BIOS system installation profile>

(注意:这里的 vmlinuz 文件和 initrd.im 文件的位置要写 pxelinux.cfg 文件的相对路径)

如果是 openSUSE & SLE 的话,添加以下内容:

......
label openSUSE or SLE
  menu label ^Installation openSUSE or SLE
  kernel <relative directory of pxelinux.cfg of BIOS boot file for installing the system>/linux
  append initrd=<relative directory of pxelinux.cfg of BIOS boot file for installing the system>/initrd splash=silent showopts install=<The URL of the network share when PXE installing>/<directory of data for installing the system>/ autoyast=<The URL of the network share when PXE installing>/<BIOS system installation profile>

(注意:这里的 linux 文件和 initrd 文件的位置要写 pxelinux.cfg 文件的相对路径)

(注意:用于存放 BIOS 系统安装菜单文件的目录必须要放在能够实现 TFPT 网络共享的目录里)

2.4.2 修改 EFI 系统安装菜单文件 grub.cfg
# vim <directory of file for EFI system installation menu>/grub.cfg

如果是 Rocky Linux & RHEL 的话,添加以下内容:

......
label Rocky Linux or RHEL
  menu label ^Installation Rocky Linux or RHEL
  kernel <relative directory of pxelinux.cfg of EFI boot file for installing the system>/vmlinuz
  append initrd=/<relative directory of pxelinux.cfg of EFI boot file for installing the system>/initrd.img ks=<The URL of the network share when PXE installing>/<EFI system installation profile>

(注意:这里的 vmlinuz 文件和 initrd.im 文件的位置要写 pxelinux.cfg 文件的相对路径)

如果是 openSUSE & SLE 的话,添加以下内容:

......
label openSUSE or SLE
  menu label ^Installation openSUSE or SLE
  kernel <relative directory of pxelinux.cfg of EFI boot file for installing the system>/linux
  append initrd=<relative directory of pxelinux.cfg of EFI boot file for installing the system>/initrd splash=silent showopts install=<The URL of the network share when PXE installing>/<directory of data for installing the system>/ autoyast=<The URL of the network share when PXE installing>/<EFI system installation profile>

(注意:这里的 linux 文件和 initrd 文件的位置要写 pxelinux.cfg 文件的相对路径)

(注意:用于存放 EFI 系统安装菜单文件的目录必须要放在能够实现 TFPT 网络共享的目录里)

步骤三:取消挂载安装镜像

# umount <directory for mounting the image>

[STEP] Red Hat Satellite client register

Step One: Add domain name resolution into /etc/hosts

# vim /etc/hosts

Add the following:

......
<Redhat Satellite IP address> <Redhat Satellite Server FQDN>

Step Two: Install katello-ca-consumer-latest.noarch.rpm

2.1 Download katello-ca-consumer-latest.noarch.rpm

# curl --insecure --output katello-ca-consumer-latest.noarch.rpm https://<Redhat Satellite Server FQDN>/pub/katello-ca-consumer-latest.noarch.rpm

2.2 Install katello-ca-consumer-latest.noarch.rpm

# yum -y localinstall katello-ca-consumer-latest.noarch.rpm

Step Three: Register to Red Hat Satellite Server

# subscription-manager register --org="<organization>" --activationkey="<activation key>"

Step Four: Install katello-host-tools, katello-host-tools-tracer and katello-agent

4.1 Enable rhel-*-satellite-tools-*-rpms repo or satellite-tools-*-rhel-*-rpms

RHEL 7:

# subscription-manager repos --enable=rhel-\*-satellite-tools-\*-rpms

RHEL 8:

# subscription-manager repos --enable=satellite-tools-\*-rhel-\*-rpms
# subscription-manager repos --disable=satellite-tools-\*-rhel-\*-eus-rpms

4.2 Install katello-host-tools, katello-host-tools-tracer and katello-agent

# yum -y install katello-host-tools; yum -y install katello-host-tools-tracer; yum -y install katello-agent

Step Five: Check

5.1 Check registration information

# subscription-manager identity

5.2 Check license

# subscription-manager list --consumed

[步骤] GitHub 代码的更新 (令牌版)

步骤一:在 GitHub 官网上生成令牌

1.1 在 https://github.com 上登录或注册 GitHub 用户

(步骤略)

1.2 在 GitHub 上创建仓库

右上角 + –> New repository –> 填写 Repository name –> 勾选 Public –> Create repository

(注意:只有当要使用的仓库还没有创建时才需要进行此步骤)

1.3 在 GitHub 官网上生成令牌

右上角的头像 –> Settings –> Developer settings –> Personal access tokens –> Generate new token –> 填写 Note –> 勾选需要的 scopes –> Generate token

1.4 复制生成的令牌

(步骤略)

步骤二:更新 GitHub 代码

2.1 进入有代码需要更新的目录

# cd github

(补充:这里以进入 github 目录为例)

2.2 初始化 Git 环境

# git init

2.3 添加需要更新的代码

# git add *

(补充:这里以添加当前目录下的所有文件为例)

2.4 提交刚刚的添加

# git commit -m "last commit"

(补充:这里以提交时添加 “last commit” 备注为例)

2.5 创建或选择代码库的分支

# git branch -M main

(补充:这里以创建或选择库里的 main 分支为例)

2.6 添加 GitHub 源

# git remote add origin git@github.com:eternalcenter-now/eternalcenter-now.github.io

(补充:这里以添加 GitHub 的 eternalcenter-now 用户的 eternalcenter-now.github.io 库为例)

(注意:这里的 eternalcenter-now 用户和 eternalcenter-now.github.io 库是指在 1.1、1.2 上创建的用户和库)

2.7 通过令牌设置 GitHub 源

# git remote set-url origin https://gafafhp_Nfaodfwiixma8hPpds4e6asdflim@github.com/eternalcenter-now/eternalcenter-now.github.io

(补充:这里以使用 GitHub 的 gafafhp_Nfaodfwiixma8hPpds4e6asdflim 令牌、eternalcenter-now 用户的 eternalcenter-now.github.io 库为例)

(注意:这里的 eternalcenter-now 用户、eternalcenter-now.github.io 库和 gafafhp_Nfaodfwiixma8hPpds4e6asdflim 令牌是指在 1.1、1.2、1.3 上创建的用户、库和生成的令牌)

2.8 将代码更新至 GitHub

# git push -u origin main

(补充:这里以将代码更新至 main 分支为例)

[工具] Shell 将同目录下最新的某个目录里的所有文件替换到 GitHub 库里 (Git LFS 版)

介绍

基本信息

作者:朱明宇
名称:将同目录下最新的某个目录里的所有文件替换到 GitHub 库里
作用:将同目录下最新的某个目录里的所有文件替换到 GitHub 库里

使用方法

1. 在此脚本的分割线内写入相应的内容
2. 给此脚本添加执行权限
3. 执行此脚本

脚本分割线里的变量

1. directory=download-eternalcenter #本地的缓冲目录
2. gituser=mingyuzhu #GitHub 用户
3. gitemail=mingyu.zhu@eternalcenter.com #GitHub 邮箱
4. gitrepository=download-eternalcenter #GitHub 库
5. gitbranch=’master’ #GitHub 库的分支
6. backupfile=all #备份后的文件
7. keyword=clone #同目录下要备份目录名称的关键字

注意

需要提前安装 git 和 git-lfs,注册 GitHub,创建相应的 GitHub 库,并且创建和设置了对应的 ssh 密钥

脚本

#!/bin/bash

####################### Separator ########################

directory=download-eternalcenter
gituser=mingyuzhu
gitemail=mingyu.zhu@eternalcenter.com
gitrepository=download-eternalcenter
gitbranch='master'
backupfile=all
keyword=clone

####################### Separator ########################

backupdirectory=`ls -rtlh | grep $keyword | awk '{print $NF}' | tail -1`

sqlfile=`ls $backupdirectory | grep sql`
tarfile=`ls $backupdirectory | grep tar`

rm -rf $directory
mkdir -p $directory &> /dev/null

echo $gituser
git config --global user.email "$gitemail"
git config --global user.name "$gituser"

rm -rf $directory
mkdir -p $directory &> /dev/null
cd $directory
git init
git lfs install
git remote add origin git@github.com:$gituser/$gitrepository
git pull --rebase origin $gitbranch -f
git lfs track *
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch *' --prune-empty --tag-name-filter cat -- --all
git commit -m 'cleapup'
git push -u origin $gitbranch -f
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now

cd ..

rm -rf $directory
mkdir -p $directory &> /dev/null
cd $directory
git init
git lfs install
git remote add origin git@github.com:$gituser/$gitrepository
git pull --rebase origin $gitbranch -f
git lfs track *
git rm *
git commit -m 'cleapup'

cd ../$backupdirectory/
tar -zcvf ../$directory/$backupfile.tar.gz *
cd ../$directory

git lfs track *
git add *
git status
git commit -m 'upload'
git push -u origin $gitbranch -f
cd ..