Commit c349d1b3 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Add more helper VM tasks

  * Make sure mount & umount are helper vm tasks themself
parent a93a31ee
......@@ -29,10 +29,11 @@
OUTPUT=/dev/ttyS0
RESULT=/dev/ttyS2
FLOPPY_DEV=/dev/fd0
# Programs
XMLSTARLET=xmlstarlet
RESIZE2FS=
RESIZE2FS=resize2fs
CLEANUP=( )
......
......@@ -31,33 +31,40 @@
. /usr/share/snf-image/common.sh
set -e
# terminate helper vm when the script exits
CLEANUP+=("telinit 0")
floppy=$(mktemp -d --tmpdir floppy.XXXXXXXX) || exit 1
if [ ! -b $FLOPPY_DEV ]; then
log_error "Floppy device is not present!"
fi
floppy=$(mktemp -d --tmpdir floppy.XXXXXXXX)
CLEANUP+=("rmdir $floppy")
if [ -e /dev/fd0 ]; then
mount /dev/fd0 $floppy
source $floppy
umount $floppy
mount $FLOPPY_DEV $floppy
CLEANUP+=("umount $floppy")
if [ -f $floppy/rules ]; then
source $floppy/rules
else
log_error "Floppy Device is not present!"
fi
log_error "Floppy does not contain \`rules\' file"
# Mount the instance's partition
# Image mount point...
target=$(mktemp -d --tmpdir target.XXXXXXXX) || exit 1
CLEANUP+=("rmdir $target")
mount /dev/sdb $target
CLEANUP+=("umount $target")
SNF_IMAGE_DEV=/dev/sdb
SNF_IMAGE_TARGET=$target
# Make sure all SNF_IMAGE_* variables are accessible by snf-image/tasks scripts
set | egrep ^SNF_IMAGE_\\w+= | cut -d= -f1 | while read line; do
export $line
done
RUN_PARTS=`which run-parts`
if [ -n "$RUN_PARTS" -a -n "/usr/lib/snf-image/tasks" ]; then
set | egrep ^SNF_IMAGE_\\w+= | cut -d= -f1 | while read line; do
export $line
done
$RUN_PARTS "/usr/lib/snf-image/tasks"
fi
......
#! /bin/sh
### BEGIN TASK INFO
# Provides: ResizeUnmounted
# RunBefore: MountImage
# Short-Description: Resize filesystem to use all the available space
### END TAST INFO
set -e
. /usr/share/snf-image/common.sh
if [ -z "$SNF_IMAGE_DEV" ]; then
log_error "Device file:\`$SNF_IMAGE_DEV\' is not a block device"
fi
if [ -z "$SNF_IMAGE_TYPE" ]; then
log_error "Image type does not exist"
fi
if [ "$SNF_IMAGE_TYPE" = "extdump" ]; then
$RESIZE2FS $SNF_IMAGE_DEV
fi
exit 0
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
#! /bin/sh
### BEGIN TASK INFO
# Provides: MountImage
# RunBefore: UmountImage
# Short-Description: Mount the partition that hosts the image
### END TAST INFO
set -e
. /usr/share/snf-image/common.sh
if [ -z "$SNF_IMAGE_TARGET" ]; then
log_error "Target dir:\`$SNF_IMAGE_TARGET\' is missing"
fi
if [ ! -b "$SNF_IMAGE_DEV"]; then
log_error "Device file:\`$SNF_IMAGE_DEV\' is not a block device"
fi
mount $SNF_IMAGE_DEV $SNF_IMAGE_TARGET
exit 0
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
......@@ -2,7 +2,7 @@
### BEGIN TASK INFO
# Provides: DeleteSSHKeys
# Requires:
# Requires: MountImage
# Short-Description: Remove ssh keys if present.
### END TAST INFO
......
......@@ -2,7 +2,8 @@
### BEGIN TASK INFO
# Provides: InstallUnattend
# Requires:
# RunBefore: UmountImage
# RunAfter: MountImage
# Short-Description: Installs Unattend.xml for unattended windows setup
### END TAST INFO
......
#! /bin/sh
### BEGIN TASK INFO
# Provides: ResizeMounted
# RunBefore: UmountImage
# RunAfter: MountImage
# Short-Description: Resize filesystem to use all the available space
### END TAST INFO
set -e
. /usr/share/snf-image/common.sh
if [ ! -d "$SNF_IMAGE_TARGET" ]; then
log_error "Target directory \`$SNF_IMAGE_TARGET\' is missing"
fi
# Write a diskpart script to %SystemDrive%\Windows\SnfScripts. Sysprep will
# try to execute this script during the specialize pass.
mkdir -p "$SNF_IMAGE_TARGET/Windows/SnfScripts"
cat > "$SNF_IMAGE_TARGET/Windows/SnfScripts/ExtendFilesystem" <<EOF
select disk 0
select volume 1
extend filesystem
exit
EOF
cleanup
trap - EXIT
exit 0
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
......@@ -2,7 +2,8 @@
### BEGIN TASK INFO
# Provides: SELinuxAutorelabel
# Requires:
# RunBefore: UmountImage
# RunAfter: MountImage
# Short-Description: Force the system to relabel at next boot
### END TAST INFO
......
......@@ -2,7 +2,8 @@
### BEGIN TASK INFO
# Provides: AssignHostname
# Requires: InstallUnattend
# RunBefore: UmountImage
# RunAfter: InstallUnattend
# Short-Description: Assign the Hostname of Computer Name in the instance
### END TAST INFO
......
......@@ -2,7 +2,8 @@
### BEGIN TASK INFO
# Provides: ChangePassword
# Requires: InstallUnattend
# RunBefore: UmountImage
# RunAfter: InstallUnattend
# Short-Description: Changes Password for specified users
### END TAST INFO
......
#! /bin/sh
### BEGIN TASK INFO
# Provides: UmountImage
# RunBefore:
# RunAfter: MountImage
# Short-Description: Umount the partition that hosts the image
### END TAST INFO
set -e
. /usr/share/snf-image/common.sh
if [ -z "$SNF_IMAGE_TARGET" ]; then
log_error "Target dir:\`$SNF_IMAGE_TARGET\' is missing"
fi
umount $SNF_IMAGE_TARGET
exit 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment