#!/bin/bash

#DESC Creates a systemd service that will run after first reboot only. (After network starts.)
# create post install script
cat > /usr/bin/post_install.sh <<EOF
#!/bin/bash

yum -y reinstall perl
/usr/bin/updateos install_ostools-1.16
/usr/bin/updateos install_tcc
/usr/bin/updateos email_results
/usr/bin/updateos conf_firewall
systemctl enable iptables
systemctl start iptables
systemctl disable post_install
update-crypto-policies --set LEGACY
rm -f /etc/systemd/system/post_install.service
reboot
EOF

# add post install service file to run after network starts.
cat > /etc/systemd/system/post_install.service <<EOF
[Unit]
Description=Post install script for staging.
After=network-online.target

[Service]
Type=idle
ExecStart=/usr/bin/post_install.sh

[Install]
WantedBy=network-online.target
EOF

chmod +x /usr/bin/post_install.sh
systemctl enable post_install
