Skip to content

Commit

Permalink
修复一些细节问题
Browse files Browse the repository at this point in the history
  • Loading branch information
firemakergk committed Apr 28, 2024
1 parent b71c754 commit 380339b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
1 change: 0 additions & 1 deletion details/pve虚拟机设置及独显直通.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ CPU设置下:

## 显卡直通

0.如果你有两张显卡,那么检查你的物理机BIOS,将主CPU设置成不打算直通的那个。

1.进入pve节点的shell,执行`vi /etc/default/grub` ,在大概第8行的位置找到

Expand Down
21 changes: 21 additions & 0 deletions details/开机IP自检及更新脚本.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@
2.将[ipupdater.py](../files/ipupdater.py)拷贝至`/root/`目录下
在/root目录下使用rz工具或者使用vi/vim创建文件并复制脚本文本。

3.使用`awk '{print $1}' /etc/hostname`命令查看你的pve使用的hostname。然后用这个名称替换掉脚本的第85行以及第89行的“pve”字样。
``` python
def updateHosts(ip):
shutil.copy(HOSTS_PATH, HOSTS_PATH + '.bak')
targetFile = open(HOSTS_PATH, "r+")
configText = targetFile.read()
splitRes = re.split("\n.+ pve\n", configText) # 这一行的“pve”换成你自己查到的hoatname
print(splitRes)
prepart = splitRes[0]
postpart = splitRes[1]
updateConfig = "\n%s pve\n" % ip # 这一行的“pve”换成你自己查到的hoatname
print("----host updateConfig----\n %s" % updateConfig)
newConifg = prepart + updateConfig+ postpart
print("----host newConifg----\n%s" % newConifg)

targetFile.seek(0)
targetFile.write(newConifg)
targetFile.truncate()
targetFile.close()
```

3.将[ipupdater.service](../files/ipupdater.service)拷贝至`/lib/systemd/system/`目录下

4.执行`systemctl daemon-reload`重载系统服务。
Expand Down
21 changes: 3 additions & 18 deletions files/ipupdater.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@
# WantedBy=multi-user.target


# import netifaces as ni
# import os
# import getopt
import socket
import shutil
import re
# from ipaddress import IPv4Network
# import time

NTERFACE_PATH = '/etc/network/interfaces'
HOSTS_PATH = '/etc/hosts'
Expand Down Expand Up @@ -87,11 +82,11 @@ def updateHosts(ip):
shutil.copy(HOSTS_PATH, HOSTS_PATH + '.bak')
targetFile = open(HOSTS_PATH, "r+")
configText = targetFile.read()
splitRes = re.split("\n.+ pve\n", configText)
splitRes = re.split("\n.+ ${pve_host}\n", configText)
print(splitRes)
prepart = splitRes[0]
postpart = splitRes[1]
updateConfig = "\n%s pve\n" % ip
updateConfig = "\n%s ${pve_host}\n" % ip
print("----host updateConfig----\n %s" % updateConfig)
newConifg = prepart + updateConfig+ postpart
print("----host newConifg----\n%s" % newConifg)
Expand Down Expand Up @@ -124,14 +119,4 @@ def updateIssue(ip):
ip = getRealNetInfo()
print("ip:%s" % ip)
updateHosts(ip)
updateIssue(ip)
# if checkIfIpChanged(ip, defaultGateWay):
# print('ipupdater find ip adress has changed, trying to update ip config.')
# updateInterfaces(ip, defaultGateWay, maskBits)
# updateHosts(ip)
# updateIssue(ip)
# print('ipupdater update ip config successfully. system will reboot after 120 seconds.')
# time.sleep(120)
# os.system("reboot")
# else:
# print('ipupdater is no need to do anything.')
updateIssue(ip)

0 comments on commit 380339b

Please sign in to comment.