123456789101112131415161718192021222324252627282930 |
- package main
- import (
- "fmt"
- "strings"
- )
- func main() {
- // 原始脚本内容
- script := `#!ipxe
- dhcp net2
- set base-url centos-7.9.2009/image #请替换为镜像所在的HTTP文件服务器地址
- set ks-url centos-7.9.2009 # 替换为你的 Kickstart 文件所在的 HTTP 服务器地址
- set ks-file centos-7.9.2009.cfg
- kernel ${base-url}/images/pxeboot/vmlinuz initrd=initrd.img inst.repo=${base-url} ip=dhcp ks=${ks-url}/${ks-file} # 指定 Kickstart 文件的位置和参数
- initrd ${base-url}/images/pxeboot/initrd.img
- boot`
- // 新的base-url和ks-url
- newBaseURL := "http://192.168.16.121:8000/images/centos-7.9.2009/image/"
- newKSURL := "http://192.168.16.121:8000/images/centos-7.9.2009/"
- // 替换原始脚本中的set base-url和set ks-url
- script = strings.Replace(script, "set base-url ", fmt.Sprintf("set base-url %s", newBaseURL), 1)
- script = strings.Replace(script, "set ks-url ", fmt.Sprintf("set ks-url %s", newKSURL), 1)
- fmt.Println(script)
- }
|