0

In my kickstart file I am trying to figure out how to copy over a long shell script to be excuted on the first boot of the system. What is the preferred approach, copying it in during the kickstart script in a %post section or writing a script that fetches another script to simulate cloud init on the first boot?

With kickstart and PXE how do I copy over a file from the kickstart server during the PXE boot in %post?

I was trying to understand how the following would apply...

%post --nochroot --log=/root/ks-post.log
cp <somebasepath>/myscript-init-script.sh /root/myscript-init-script.sh
%end

anaconda.ks

%post --log=/root/ks-post2.log
touch /etc/systemd/system/runonce.service
cat >> /etc/systemd/system/runonce.service << EOF
[Unit]
Description=Run once
Requires=network-online.target
After=network-online.target

[Service]
ExecStart=/root/runonce.sh

[Install]
WantedBy=multi-user.target
EOF

chmod 664 /etc/systemd/system/runonce.service
systemctl enable runonce

touch /root/runonce.sh
cat >> /root/runonce.sh << EOF
#!/bin/bash

if [ -e /tmp/runonce ]
then
rm /tmp/runonce
exec > /root/runonce.log 2>&1
/root/myscript-init-script.sh
fi

exit
EOF

chmod 744 /root/runonce.sh

%end

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.