Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
snf-image
Commits
c349d1b3
Commit
c349d1b3
authored
Sep 28, 2011
by
Nikos Skalkotos
Browse files
Add more helper VM tasks
* Make sure mount & umount are helper vm tasks themself
parent
a93a31ee
Changes
11
Hide whitespace changes
Inline
Side-by-side
helper/common.sh
View file @
c349d1b3
...
...
@@ -29,10 +29,11 @@
OUTPUT
=
/dev/ttyS0
RESULT
=
/dev/ttyS2
FLOPPY_DEV
=
/dev/fd0
# Programs
XMLSTARLET
=
xmlstarlet
RESIZE2FS
=
RESIZE2FS
=
resize2fs
CLEANUP
=(
)
...
...
helper/rc.local
View file @
c349d1b3
...
...
@@ -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
...
...
helper/tasks/10ResizeUnmounted.sh
0 → 100644
View file @
c349d1b3
#! /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 :
helper/tasks/30MountImage.sh
0 → 100644
View file @
c349d1b3
#! /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 :
helper/tasks/40DeleteSSHKeys.sh
View file @
c349d1b3
...
...
@@ -2,7 +2,7 @@
### BEGIN TASK INFO
# Provides: DeleteSSHKeys
# Requires:
# Requires:
MountImage
# Short-Description: Remove ssh keys if present.
### END TAST INFO
...
...
helper/tasks/
0
0InstallUnattend.sh
→
helper/tasks/
4
0InstallUnattend.sh
View file @
c349d1b3
...
...
@@ -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
...
...
helper/tasks/40ResizeMounted.sh
0 → 100644
View file @
c349d1b3
#! /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 :
helper/tasks/
9
0SELinuxAutorelabel.sh
→
helper/tasks/
4
0SELinuxAutorelabel.sh
View file @
c349d1b3
...
...
@@ -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
...
...
helper/tasks/
4
0AssignHostname.sh
→
helper/tasks/
5
0AssignHostname.sh
View file @
c349d1b3
...
...
@@ -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
...
...
helper/tasks/
4
0ChangePassword.sh
→
helper/tasks/
5
0ChangePassword.sh
View file @
c349d1b3
...
...
@@ -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
...
...
helper/tasks/90UmountImage.sh
0 → 100644
View file @
c349d1b3
#! /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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment