makelni: add pre/post install hook error messages, add lon-tool
This commit is contained in:
parent
c370fe1672
commit
16fb7c36ae
23
makelni
23
makelni
|
@ -2,6 +2,8 @@
|
|||
source ./common.d/functions.sh
|
||||
source ./common.d/variables.sh
|
||||
|
||||
require "lon-tool"
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
log "$0 must be run as root"
|
||||
exit 3
|
||||
|
@ -26,6 +28,11 @@ lnib_has_errors="n"
|
|||
lnib_has_errors="y"
|
||||
}
|
||||
|
||||
[ -z ${imgver+x} ] && {
|
||||
log "LNIBUILD: missing imgver" ierror
|
||||
lnib_has_errors="y"
|
||||
}
|
||||
|
||||
[ -z ${image_type+x} ] && {
|
||||
log "LNIBUILD: missing image_type" ierror
|
||||
lnib_has_errors="y"
|
||||
|
@ -50,7 +57,8 @@ source "./common.d/common.${image_type}.sh"
|
|||
log "Making image: $name"
|
||||
log "Image type: $image_type"
|
||||
|
||||
log "Creating image: $(get_image_path "$name")"
|
||||
IMAGE_PATH="$(get_image_path "$name")"
|
||||
log "Creating image: $IMAGE_PATH"
|
||||
create_image "$name" || _shutdown 1
|
||||
imageroot="$(mount_image "$name")"
|
||||
|
||||
|
@ -62,7 +70,10 @@ prepare_chroot "$imageroot" || _shutdown 1
|
|||
|
||||
[[ $(type -t pre_install) == function ]] && {
|
||||
log "Running pre install hook"
|
||||
pre_install || _shutdown 1
|
||||
pre_install || {
|
||||
log "Failed to execute pre install hook"
|
||||
_shutdown 1
|
||||
}
|
||||
}
|
||||
|
||||
log "Setting up inet"
|
||||
|
@ -92,7 +103,10 @@ gen_fstab "$imageroot" || _shutdown 1
|
|||
|
||||
[[ $(type -t post_install) == function ]] && {
|
||||
log "Running post install hook"
|
||||
post_install || _shutdown 1
|
||||
post_install || {
|
||||
log "Failed to execute post install hook"
|
||||
_shutdown 1
|
||||
}
|
||||
}
|
||||
|
||||
log "Detaching chroot"
|
||||
|
@ -104,4 +118,7 @@ umount_image "$imageroot" || _shutdown 1
|
|||
log "Trimming image"
|
||||
trim_image "$name" || _shutdown 1
|
||||
|
||||
log "Creating lni image"
|
||||
lon-tool image create "$IMAGE_PATH "./out/${name}.lni" --name "$name" -v "$imgver"
|
||||
|
||||
log "Image build finished"
|
||||
|
|
Loading…
Reference in a new issue