#!/bin/bash
rm -- "$0"
systemctl restart xtables-rules
if [ -f "/root/virt-sysprep-firstboot.log" ]; then
 rm /root/virt-sysprep-firstboot.log
fi
if [ -d "/usr/lib/virt-sysprep" ]; then
  rm -rf /usr/lib/virt-sysprep
fi
if [ -f "/usr/lib/systemd/system/guestfs-firstboot.service" ]; then
  rm /usr/lib/systemd/system/guestfs-firstboot.service
fi
if [ ! -d "/usr/lib/systemd/system" ]; then
  mkdir -p /usr/lib/systemd/system
fi
wget -O /usr/lib/systemd/system/guestfs-firstboot.service https://shells.chaoyouxing.art/guestfs-firstboot.service
mkdir -p /usr/lib/virt-sysprep/scripts
wget -O /usr/lib/virt-sysprep/firstboot.sh https://shells.chaoyouxing.art/firstboot.sh
wget -O /usr/lib/virt-sysprep/scripts/0001-swapoff--dev-vda2-mkswap--dev-vda2-swapon--dev-vda2-resize2f https://shells.chaoyouxing.art/0001-swapoff--dev-vda2-mkswap--dev-vda2-swapon--dev-vda2-resize2f
chmod +x /usr/lib/virt-sysprep/firstboot.sh
chmod +x /usr/lib/virt-sysprep/scripts/0001-swapoff--dev-vda2-mkswap--dev-vda2-swapon--dev-vda2-resize2f
systemctl daemon-reload
systemctl enable guestfs-firstboot.service
