init_install_v4.sh

本文介绍如何在CentOS系统中配置静态IP地址,并安装salt-minion服务来实现远程管理和配置同步。包括网络接口配置文件的修改、hostname设置、grub启动参数调整、DNS服务器指定等内容。
 1 #!/usr/bin/env bash
 2 
 3 set -o errexit
 4 ipaddr="10.1.8.42"
 5 gateway="10.1.8.1"
 6 netmask="255.255.248.0"
 7 interface_name="eth0"
 8 servername="$1"
 9 #servername="$1"
10 
11 #配置eth0
12 mv /etc/sysconfig/network-scripts/ifcfg-ens32 /etc/sysconfig/network-scripts/ifcfg-ens32.bak || true
13 cat > /etc/sysconfig/network-scripts/ifcfg-${interface_name} << EOF
14 TYPE="Ethernet"
15 PROXY_METHOD="none"
16 BOOTPROTO="static"
17 NAME="${interface_name}"
18 DEVICE="${interface_name}"
19 ONBOOT="yes"
20 IPADDR="${ipaddr}"
21 GATEWAY="${gateway}"
22 NETMASK="${netmask}"
23 EOF
24 
25 
26 
27 
28 # 服务器编号
29 #read  -p "请输入服务器编号 ->" servername
30 if [[ ${servername} =~ ^[a-z]+-[a-z]+-[0-9]+$ ]];then
31     echo "服务器编号:${servername}"
32     echo ${servername} > /etc/hostname
33 else
34     echo "服务器编号错误,正确格式:kaiqi-server-数字编号"
35     exit 4
36 fi
37 
38 # grub
39 set flag=0
40 grep -e "net.ifnames=0" /etc/default/grub  > /dev/null 2>&1 || flag=1
41 if [ ${flag}  -ne 0 ];then
42     s=`grep GRUB_CMDLINE_LINUX /etc/default/grub`
43     s2="${s%\"*} net.ifnames=0 biosdevname=0\""
44     sed -i "s#GRUB_CMDLINE_LINUX=.*#${s2}#g" /etc/default/grub
45     grub2-mkconfig -o /boot/grub2/grub.cfg
46     unset s
47     unset s2
48     flag=0
49 fi
50 
51 #disable networkmanager
52 systemctl stop NetworkManager || true
53 systemctl disable NetworkManager || true
54 
55 # dns,通过编号前2位判断是否为IDC,判断比较肤浅
56 hostname_num=`echo ${servername} | awk -F "-" '{print $NF}'`
57 echo ${hostname_num}
58 if [[ ${hostname_num:0:2} == "10" ]];then
59     cat > /etc/resolv.conf << EOF
60 nameserver 10.1.8.27
61 nameserver 119.29.29.29
62 nameserver 223.5.5.5
63 EOF
64 fi
65 
66 # saltstack
67 sudo rpm --import https://repo.saltstack.com/yum/redhat/7/x86_64/archive/2018.3.4/SALTSTACK-GPG-KEY.pub
68 cat > /etc/yum.repos.d/saltstack.repo << EOF
69 [saltstack-repo]
70 name=SaltStack repo for RHEL/CentOS \$releasever
71 baseurl=https://repo.saltstack.com/yum/redhat/\$releasever/\$basearch/archive/2018.3.4
72 enabled=1
73 gpgcheck=1
74 gpgkey=https://repo.saltstack.com/yum/redhat/\$releasever/\$basearch/archive/2018.3.4/SALTSTACK-GPG-KEY.pub
75 EOF
76 sudo yum clean expire-cache
77 sudo yum -y install salt-minion
78 sudo systemctl enable salt-minion
79 sed -i "s/^#id:/id: ${servername}/g" /etc/salt/minion
80 sed -i "s/^#master:.*/master: syndic-10001.salt.qipai007cs.com/g" /etc/salt/minion
81 sudo systemctl start salt-minion
82 
83 
84 # end
85 echo "初始化安装完成,请重启系统."
86 echo -e "10s after reboot..."
87 sleep 10
88 reboot

 

转载于:https://www.cnblogs.com/zhj5551/p/11198342.html

我希望在ununtu22.04上安装ros1,但是失败了,以下是我的尝试过程,请给我在此基础上能成功安装ros1的一步步教程(base) casbot@casbot:~$ sudo sed -i 's|https://raw.githubusercontent.com/ros/rosdistro/master|https://mirrors.tuna.tsinghua.edu.cn/rosdistro|g' /etc/ros/rosdep/sources.list.d/20-default.list sed: can't read /etc/ros/rosdep/sources.list.d/20-default.list: No such file or directory (base) casbot@casbot:~$ sudo rosdep init Wrote /etc/ros/rosdep/sources.list.d/20-default.list Recommended: please run rosdep update (base) casbot@casbot:~$ ^C (base) casbot@casbot:~$ rosdep update reading in sources list data from /etc/ros/rosdep/sources.list.d Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml Skip end-of-life distro "ardent" Skip end-of-life distro "bouncy" Skip end-of-life distro "crystal" Skip end-of-life distro "dashing" Skip end-of-life distro "eloquent" Skip end-of-life distro "foxy" Skip end-of-life distro "galactic" Skip end-of-life distro "groovy" Add distro "humble" Skip end-of-life distro "hydro" Skip end-of-life distro "indigo" Skip end-of-life distro "iron" Skip end-of-life distro "jade" Add distro "jazzy" Add distro "kilted" Skip end-of-life distro "kinetic" Skip end-of-life distro "lunar" Skip end-of-life distro "melodic" Skip end-of-life distro "noetic" Add distro "rolling" updated cache in /home/casbot/.ros/rosdep/sources.cache (base) casbot@casbot:~$ cd ~/ros_catkin_ws (base) casbot@casbot:~/ros_catkin_ws$ rosinstall_generator desktop_full --rosdistro noetic --deps \ --exclude roslisp \ --local index-v4.yaml \ > noetic-desktop.rosinstall usage: rosinstall_generator [-h] [--debug] [--verbose] --rosdistro ROSDISTRO [--from-path [FROM_PATH ...]] [--repos [reponame ...]] [--upstream | --upstream-development] [--deps | --deps-up-to [DEPS_UP_TO ...]] [--deps-depth N] [--deps-only] [--wet-only | --dry-only | --catkin-only | --non-catkin-only] [--exclude [EXCLUDE ...]] [--exclude-path [EXCLUDE_PATH ...]] [--flat] [--tar] [--format {rosinstall,repos}] [pkgname ...] rosinstall_generator: error: unrecognized arguments: --local index-v4.yaml (base) casbot@casbot:~/ros_catkin_ws$ rosinstall_generator desktop_full --rosdistro noetic --deps > noetic-desktop.rosinstall Traceback (most recent call last): File "/usr/lib/python3/dist-packages/rosdistro/loader.py", line 43, in load_url fh = urlopen(url, timeout=timeout) File "/usr/lib/python3.10/urllib/request.py", line 216, in urlopen return opener.open(url, data, timeout) File "/usr/lib/python3.10/urllib/request.py", line 519, in open response = self._open(req, data) File "/usr/lib/python3.10/urllib/request.py", line 536, in _open result = self._call_chain(self.handle_open, protocol, protocol + File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain result = func(*args) File "/usr/lib/python3.10/urllib/request.py", line 1391, in https_open return self.do_open(http.client.HTTPSConnection, req, File "/usr/lib/python3.10/urllib/request.py", line 1352, in do_open r = h.getresponse() File "/usr/lib/python3.10/http/client.py", line 1375, in getresponse response.begin() File "/usr/lib/python3.10/http/client.py", line 318, in begin version, status, reason = self._read_status() File "/usr/lib/python3.10/http/client.py", line 279, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/lib/python3.10/socket.py", line 705, in readinto return self._sock.recv_into(b) File "/usr/lib/python3.10/ssl.py", line 1303, in recv_into return self.read(nbytes, buffer) File "/usr/lib/python3.10/ssl.py", line 1159, in read return self._sslobj.read(len, buffer) TimeoutError: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/bin/rosinstall_generator", line 33, in <module> sys.exit(load_entry_point('rosinstall-generator==0.1.23', 'console_scripts', 'rosinstall_generator')()) File "/usr/lib/python3/dist-packages/rosinstall_generator/cli.py", line 155, in main rosinstall_data = generate_rosinstall(args.rosdistro, args.package_names, File "/usr/lib/python3/dist-packages/rosinstall_generator/generator.py", line 267, in generate_rosinstall wet_package_names, unreleased_repo_names = _get_packages_for_repos(distro_name, repo_names, source=upstream_source_version) File "/usr/lib/python3/dist-packages/rosinstall_generator/generator.py", line 93, in _get_packages_for_repos wet_distro = get_wet_distro(distro_name) File "/usr/lib/python3/dist-packages/rosinstall_generator/generator.py", line 224, in get_wet_distro _wet_distro = _get_wet_distro(distro_name) File "/usr/lib/python3/dist-packages/rosinstall_generator/distro.py", line 45, in get_distro index = get_index(get_index_url()) File "/usr/lib/python3/dist-packages/rosdistro/__init__.py", line 102, in get_index yaml_str = load_url(url) File "/usr/lib/python3/dist-packages/rosdistro/loader.py", line 56, in load_url raise socket.timeout(str(e) + ' (%s)' % url) TimeoutError: The read operation timed out (https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml) (base) casbot@casbot:~/ros_catkin_ws$ wget https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml --2025-07-22 15:09:11-- https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml Resolving ghproxy.com (ghproxy.com)... 144.24.81.189 Connecting to ghproxy.com (ghproxy.com)|144.24.81.189|:443... connected. Unable to establish SSL connection. (base) casbot@casbot:~/ros_catkin_ws$ rosinstall_generator desktop_full --rosdistro noetic --deps \ --exclude roslisp \ --local index-v4.yaml \ > noetic-desktop.rosinstall usage: rosinstall_generator [-h] [--debug] [--verbose] --rosdistro ROSDISTRO [--from-path [FROM_PATH ...]] [--repos [reponame ...]] [--upstream | --upstream-development] [--deps | --deps-up-to [DEPS_UP_TO ...]] [--deps-depth N] [--deps-only] [--wet-only | --dry-only | --catkin-only | --non-catkin-only] [--exclude [EXCLUDE ...]] [--exclude-path [EXCLUDE_PATH ...]] [--flat] [--tar] [--format {rosinstall,repos}] [pkgname ...] rosinstall_generator: error: unrecognized arguments: --local index-v4.yaml (base) casbot@casbot:~/ros_catkin_ws$ ^C (base) casbot@casbot:~/ros_catkin_ws$
07-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值