使用yum-config-manager启用或关闭指定repo:
yum install yum-utils
yum-config-manager --enable remi
yum-config-manager --disable remi
安装软件时指定repo或不使用指定repo:
yum --disablerepo=remi update
yum --enablerepo=remi update
发布时间:October 2, 2018 // 分类: // No Comments
使用yum-config-manager启用或关闭指定repo:
yum install yum-utils
yum-config-manager --enable remi
yum-config-manager --disable remi
安装软件时指定repo或不使用指定repo:
yum --disablerepo=remi update
yum --enablerepo=remi update
发布时间:September 30, 2018 // 分类: // No Comments
此脚本用于生成ubuntu和centos网络重装引导项,ks和pressed配置文件见前文,上传到http服务器并替换脚本中内容,在centos7和ubuntu18.04上测试安装centos7和ubuntu18.04通过。
#!/bin/bash
#set -x
install=ubuntu
network=static
stage2="nfs:nfsvers=4:www.haiyun.me:/"
cidr2mask () {
set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
[ $1 -gt 1 ] && shift $1 || shift
echo ${1-0}.${2-0}.${3-0}.${4-0}
}
function valid_ip() {
local ip=$1
local stat=1
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
IFS='.'; ip=($ip); IFS=$OIFS
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
stat=$?
fi
return $stat
}
which wget &> /dev/null && which ip &> /dev/null || {
echo '请先安装wget和ip'
exit;
}
if [ "$network" == 'static' ]; then
address=`ip -o -f inet addr show | awk '/scope global/ {print $4}'`
ip=`echo $address|awk -F'/' '{print $1}'`
cidr=`echo $address|awk -F'/' '{print $2}'`
rou=`ip rou|awk '/default via/ {print $3}'`
mask=`cidr2mask $cidr`
echo 'ip:' $ip
echo 'route:' $rou
echo 'netmask:' $mask
valid_ip "$ip" && valid_ip "$mask" && valid_ip "$rou" || {
echo '获取网络信息失败'
exit;
}
echo '请核对以上IP信息是否正确'
fi
if [ -f "/etc/redhat-release" ]; then
dist="centos"
grubfile=/boot/grub2/grub.cfg
grubcmd=grub2-mkconfig
else
grubfile=/boot/grub/grub.cfg
grubcmd=grub-mkconfig
dist="ubuntu"
fi
#root=`grep "set root" $grubfile|sed -e 's/^[ \t]*//'|head -n 1`
root=`grep 'set root' $grubfile |sed -e 's/^[ \t]*//'|sort|uniq -c|head -n 1|awk '{print $2,$3}'`
if mount|grep -q /boot; then
dir=/
else
dir=/boot/
fi
vmlinuzfile=${dir}vmlinuz
initrdfile=${dir}initrd.img
rm -rf /boot/vmlinuz
rm -rf /boot/initrd.img
if [ "$install" == 'centos' ]; then
mem=`free -m | grep Mem | awk '{print $2}'`
if [ ! $stage2 ] && (($mem < 1500)); then
echo '内存小于1.5G要通过网络安装centos7可能会失败'
exit;
fi
base=https://mirrors.aliyun.com/centos/7/os/x86_64
wget -q ${base}/isolinux/vmlinuz -O /boot/vmlinuz || exit;
wget -q ${base}/isolinux/initrd.img -O /boot/initrd.img || exit;
if [ "$network" == 'static' ]; then
linux16="$vmlinuzfile inst.ks=https://www.haiyun.me/centos7.cfg net.ifnames=0 biosdevname=0 inst.headless ip=${ip}::${rou}:${mask}::eth0:none nameserver=8.8.8.8"
else
linux16="$vmlinuzfile inst.ks=https://www.haiyun.me/centos7.cfg net.ifnames=0 biosdevname=0 inst.headless ip=dhcp"
fi
if [ $stage2 ]; then
linux16="$linux16 inst.stage2=$stage2"
fi
else
base=https://mirrors.aliyun.com/ubuntu/dists/bionic/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64
wget -q ${base}/linux -O /boot/vmlinuz || exit;
wget -q ${base}/initrd.gz -O /boot/initrd.img || exit;
if [ "$network" == 'static' ]; then
#linux16="$vmlinuzfile ks=https://www.haiyun.me/ubuntu-ks.cfg domain= hostname=ubuntu-server interface=auto netcfg/get_ipaddress=${ip} netcfg/get_netmask=${mask} netcfg/get_gateway=${rou} netcfg/get_nameservers=8.8.8.8 netcfg/disable_autoconfig=true"
linux16="$vmlinuzfile auto=true url=https://www.haiyun.me/ubuntu.cfg keymap=us domain= hostname=ubuntu-server interface=auto netcfg/get_ipaddress=${ip} netcfg/get_netmask=${mask} netcfg/get_gateway=${rou} netcfg/get_nameservers=8.8.8.8 netcfg/disable_autoconfig=true"
else
#linux16="$vmlinuzfile ks=https://www.haiyun.me/ubuntu-ks.cfg domain= hostname=ubuntu-server interface=auto"
linux16="$vmlinuzfile auto=true url=https://www.haiyun.me/ubuntu.cfg keymap=us domain= hostname=ubuntu-server interface=auto"
fi
fi
[[ -f /boot/vmlinuz ]] && [[ -f /boot/initrd.img ]] || {
echo '引导文件不存在'
exit;
}
cat > /etc/grub.d/40_custom <<EOF
#!/bin/sh
exec tail -n +3 \$0
menuentry 'netinstall' {
$root
linux16 $linux16
initrd16 $initrdfile
}
EOF
sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT="netinstall"/' /etc/default/grub
$grubcmd -o $grubfile
cat /etc/grub.d/40_custom
https://www.haiyun.me/archives/1246.html
https://www.haiyun.me/archives/1249.html
发布时间:September 30, 2018 // 分类: // No Comments
preseed安装ubuntu见:https://www.haiyun.me/archives/1246.html
启动参数:
ks=https://www.haiyun.me/ubuntu-ks.cfg domain= hostname=ubuntu-server interface=auto netcfg/get_ipaddress=${ip} netcfg/get_netmask=${mask} netcfg/get_gateway=${rou} netcfg/get_nameservers=8.8.8.8 netcfg/disable_autoconfig=true
配置文件,ks不支持部分ubuntu设置,可在ks文件中嵌入preseed命令:
install
url --url=http://mirrors.aliyun.com/ubuntu/
text
skipx
unsupported_hardware
eula --agreed
#rootpw --plaintext 123456
#echo 'import crypt,getpass; print crypt.crypt(getpass.getpass(), "$6$16_CHARACTER_SALT_HERE")' | python -
rootpw --iscrypted $6$16_CHARACTER_SAL$dvFZEFR66m38M3u3K4os2Yi4j88oTRaF9Q7XkKK4VFlMlwS9l17oTjXI043rfpNxDkB8/1ntrOiAFQGeYgwEZ.
authconfig --enableshadow --passalgo=sha512
preseed passwd/make-user boolean false
keyboard --vckeymap=us --xlayouts='us'
lang en_US.UTF-8
timezone Asia/Shanghai
firstboot --disable
firewall --disabled
selinux --disabled
reboot
#network --bootproto=static --device=eth0 --gateway=192.168.168.1 --ip=192.168.168.50 --nameserver=192.168.168.1 --netmask=255.255.255.0 --ipv6=auto --activate
#network --hostname=ubuntu-server
preseed partman-lvm/device_remove_lvm boolean true
preseed partman-md/device_remove_md boolean true
#preseed partman-lvm/confirm boolean true
#preseed partman-lvm/confirm_nooverwrite boolean true
zerombr
clearpart --all --drives=sda
ignoredisk --only-use=sda
bootloader --location=mbr --boot-drive=sda
#autopart
#part / --asprimary --fstype ext4 --size=5120
#part swap --asprimary --size=1024
#part /home --asprimary --fstype ext4 --size=5120 --grow
part /boot --fstype ext4 --size 200 --asprimary
part swap --size 1024 --asprimary
part pv.01 --size 1 --grow --asprimary
volgroup rootvg pv.01
logvol / --fstype ext4 --vgname=rootvg --size=1 --grow --name=rootlv
#preseed anna/choose_modules string network-console
#preseed network-console/password password 123456
#preseed network-console/password-again password 123456
preseed pkgsel/update-policy select none
preseed pkgsel/upgrade select none
#ubuntu-minimal
%packages
openssh-server
%post
sed -ri 's/^#?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
%end
参考:
https://help.ubuntu.com/community/KickstartCompatibility
https://help.ubuntu.com/lts/installation-guide/i386/ch04s06.html
发布时间:September 29, 2018 // 分类: // No Comments
cp /usr/share/doc/glibc-common-2.17/gai.conf /etc/
echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf
发布时间:September 29, 2018 // 分类: // No Comments
Protocol Encryption (PE):
Azureus与uTorrent共同制定的加密协议, 以绕过ISP封锁或干扰BT
禁用---传出不加密,但接受加密传入
启用---尝试传出加密,若连接失败,转为不加密传出
强制---尝试传出加密,若连接失败,仍保持加密传出
允许传入旧式连接---允许传入旧式的非加密连接,建议勾选,否则将拒绝所有未加密的传入连接
以下2种模式均接受加密的传入连接且为双向加密:
所有模式 (加密/非加密连接均接受, ut默认模式)
传出连接---〉启用
允许传入旧式连接---〉勾选
强制模式 (仅接受加密连接,拒绝所有未加密的连接申请,可增强反吸血保护)
传出连接---〉强制
允许传入旧式连接---〉不勾选
uTorrent 用户标识缩写含义:
了解对方用户标识缩写含义,知己知彼,有助于分析一些传输问题
D = 正在下载 (我方有意从对方下载且被接受)
d = 对方拒绝 (我方有意从对方下载但被拒绝)
U = 正在上传 (对方有意从我方下载且被接受)
u = 拒绝上传 (对方有意从我方下载但被拒绝)
K = 我方无意下载 (我方无意从对方下载虽对方未拒绝)
? = 对方无意下载 (对方无意从我方下载虽我方未拒绝)
F = 错误用户(对方曾传来散列校验失败的区块, 但还未达屏蔽对方的程度)
S = 静态用户(静态等待, 双方之间无活动达高级参数中设定的静态等待时限,但未屏蔽对方)
O = 宽容用户(在无其他更好的用户选择前,不拒绝对方连接,uT在用户接入优先级排序上有一套轮循optimistic unchoke规则 )
I = 已建立传入连接的用户
X = 通过用户交换(PEX)或IPv6/IPv4穿遂连接的用户
H = 通过DHT连接的用户
h = 通过UDP内网穿透(UDP Hole Punching)连接的用户
L = 通过本地用户发现连接的本地用户
P = 通过uTP连接的用户
E = 所有模式用户 (加密或非加密连接均接受)
e = 强制模式用户 (仅接受加密连接)
参考:
https://github.com/transmission/transmission/wiki/Peer-Status-Text