X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=clone%2Fvirt-sysprep.in;h=9e8f212b167ad8b113e3856af8135dce6a9ee1cb;hb=c4381dba737d5cb8aad8e1b2e2123b0fcaff1d1a;hp=02620155c76713e0f22001f8e0a1cf62a882bbac;hpb=dd73c50dc5439c3e16f1322dce69b1f17af485da;p=libguestfs.git diff --git a/clone/virt-sysprep.in b/clone/virt-sysprep.in index 0262015..9e8f212 100644 --- a/clone/virt-sysprep.in +++ b/clone/virt-sysprep.in @@ -15,7 +15,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. unset CDPATH program="virt-sysprep" @@ -131,43 +131,52 @@ done # enable all of these, although some of them are only done on certain # guest types (see details below). if [ -z "$enable" ]; then + cron_spool=yes dhcp_client_state=yes dhcp_server_state=yes hostname=yes logfiles=yes + mail_spool=yes net_hwaddr=yes random_seed=yes rhn_systemid=yes smolt_uuid=yes ssh_hostkeys=yes udev_persistent_net=yes + utmp=yes yum_uuid=yes elif [ "$enable" = "list" ]; then + echo "cron-spool" echo "dhcp-client-state" echo "dhcp-server-state" echo "hostname" echo "logfiles" + echo "mail-spool" echo "net-hwaddr" echo "random-seed" echo "rhn-systemid" echo "smolt-uuid" echo "ssh-hostkeys" echo "udev-persistent-net" + echo "utmp" echo "yum-uuid" exit 0 else for opt in $(echo "$enable" | sed 's/,/ /g'); do case "$opt" in + cron-spool) cron_spool=yes ;; dhcp-client-state) dhcp_client_state=yes ;; dhcp-server-state) dhcp_server_state=yes ;; hostname) hostname=yes ;; logfiles) logfiles=yes ;; + mail-spool) mail_spool=yes ;; net-hwaddr) net_hwaddr=yes ;; random-seed) random_seed=yes ;; rhn-systemid) rhn_systemid=yes ;; smolt-uuid) smolt_uuid=yes ;; ssh-hostkeys) ssh_hostkeys=yes ;; udev-persistent-net) udev_persistent_net=yes ;; + utmp) utmp=yes ;; yum-uuid) yum_uuid=yes ;; *) echo "error: unknown --enable feature: $opt" @@ -213,18 +222,18 @@ trap cleanup EXIT ERR # Run virt-inspector and grab inspection information about this guest. virt-inspector "${params[@]}" > $tmpdir/xml -xmlstarlet sel -t -c \ +virt-inspector --xpath \ "string(/operatingsystems/operatingsystem[position()=1]/name)" \ - $tmpdir/xml > $tmpdir/type -xmlstarlet sel -t -c \ + < $tmpdir/xml > $tmpdir/type +virt-inspector --xpath \ "string(/operatingsystems/operatingsystem[position()=1]/distro)" \ - $tmpdir/xml > $tmpdir/distro ||: -xmlstarlet sel -t -c \ + < $tmpdir/xml > $tmpdir/distro ||: +virt-inspector --xpath \ "string(/operatingsystems/operatingsystem[position()=1]/package_format)" \ - $tmpdir/xml > $tmpdir/package_format ||: -xmlstarlet sel -t -c \ + < $tmpdir/xml > $tmpdir/package_format ||: +virt-inspector --xpath \ "string(/operatingsystems/operatingsystem[position()=1]/package_management)" \ - $tmpdir/xml > $tmpdir/package_management ||: + < $tmpdir/xml > $tmpdir/package_management ||: type="$(cat $tmpdir/type)" distro="$(cat $tmpdir/distro)" @@ -240,6 +249,10 @@ mnt="$tmpdir/mnt" #---------------------------------------------------------------------- # The sysprep operations. +if [ "$cron_spool" = "yes" ]; then + rm -rf $mnt/var/spool/cron/* +fi + if [ "$dhcp_client_state" = "yes" ]; then case "$type" in linux) @@ -293,6 +306,11 @@ if [ "$logfiles" = "yes" ]; then esac fi +if [ "$mail_spool" = "yes" ]; then + rm -rf $mnt/var/spool/mail/* + rm -rf $mnt/var/mail/* +fi + if [ "$net_hwaddr" = "yes" ]; then case "$type/$distro" in linux/fedora) @@ -322,7 +340,7 @@ if [ "$random_seed" = "yes" -a "$type" = "linux" ]; then f=$mnt/var/lib/urandom/random-seed fi if [ -n "$f" ]; then - dd if=/dev/random of="$f" bs=8 count=1 conv=nocreat,notrunc 2>/dev/null + dd if=/dev/urandom of="$f" bs=8 count=1 conv=nocreat,notrunc 2>/dev/null fi fi @@ -344,6 +362,10 @@ if [ "$udev_persistent_net" = "yes" -a "$type" = "linux" ]; then rm -f $mnt/etc/udev/rules.d/70-persistent-net.rules fi +if [ "$utmp" = "yes" -a "$type" != "windows" ]; then + rm -f $mnt/var/run/utmp +fi + if [ "$yum_uuid" = "yes" -a "$package_management" = "yum" ]; then rm -f $mnt/var/lib/yum/uuid fi