VMware Cloud Community
dingding
Enthusiast
Enthusiast

kickstart install: self run-once script

in kickstart installation, when i want to configure esx network, install patch, usually i generate script in %post, and let it run once in /etc/rc.d/rc.local.

like below:

cat > /tmp/esxcfg.sh <<EOF
some esxcfg- command here.....
.....

EOF

\# Backup original rc.local file
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bak

\# Make esxcfg.sh run from rc.local and make rc.local reset itself
cat > /etc/rc.d/rc.local <<EOF
cd /tmp
/tmp/esxcfg.sh
mv -f /etc/rc.d/rc.local.bak /etc/rc.d/rc.local
EOF

we use cat > to generate a new file esxcfg.sh here, i don't like the cat method. every time i modify the esxcfg.sh, i should modify ks.cfg also. how about extract it out of ks.cfg, and place it in a http server just as ESX installation media. but if i have the esxcfg.sh in http server ready, how to copy it from http server to /tmp dir?

---- Idleness is not doing nothing. Idleness is being free to do anything.
Reply
0 Kudos
6 Replies
tsugliani
VMware Employee
VMware Employee

You can do it on the %post -nochroot section of your kickstart script.

In fact the installer image got wget, you could simply use it at this step to download your script, and then in the %post (chrooted) section copy it over where you want.

Hope this helps.

Reply
0 Kudos
dingding
Enthusiast
Enthusiast

are you sure the wget package is included in the boot kernel?

---- Idleness is not doing nothing. Idleness is being free to do anything.
Reply
0 Kudos
tsugliani
VMware Employee
VMware Employee

Yes it is available.

I use it to download a rhel wget rpm for %post chrooted section to download all my specific master post reboot configuration (network configuration, some rules, patch management)

Texiwill
Leadership
Leadership

Hello,

wget is not available in a default install of ESX. Nor is curl. However, lwp-download, lwp-request, lwp-rget do exist.

Your script should use one of the lwp- commands. You could use lwp-download to download then install wget, but why bother?

Best regards,

Edward

--
Edward L. Haletky
vExpert XIV: 2009-2023,
VMTN Community Moderator
vSphere Upgrade Saga: https://www.astroarch.com/blogs
GitHub Repo: https://github.com/Texiwill
dingding
Enthusiast
Enthusiast

wget is only available in nochroot mode.

another issue with wget is i must change my directory relative to /mnt/sysimage.

e.g.

/tmp -> /mnt/sysimage/tmp

i test your method, succeed.

---- Idleness is not doing nothing. Idleness is being free to do anything.
Reply
0 Kudos
dingding
Enthusiast
Enthusiast

wget is only available in nochroot mode, lwp-download is only available in default (chroot) %post mode.

the pros of lwp-download is i don't need to change my directory structure, the cons is it will append a .txt suffix to my remote file name. so i should specify a local name.

e.g. lwp-download http://x.x.x.x/esx3/esxcfg.sh esxcfg.sh

i test both method, all succeed. but for minimal modification of my script, i use the lwp-download method. thanks.

---- Idleness is not doing nothing. Idleness is being free to do anything.
Reply
0 Kudos