add force option

This commit is contained in:
illiliti 2020-03-01 16:42:57 +03:00
parent eab825a40d
commit d6e1d23c70
2 changed files with 12 additions and 3 deletions

3
config
View File

@ -5,6 +5,9 @@
# debug mode
#debug=0
# overwrite existing initramfs image
#force=0
# custom init
#init=""

View File

@ -34,6 +34,7 @@ usage: $0 [options]
-k, --kernel <ver> kernel version
-f, --files <dir> files directory
-d, --debug 0|1 debug mode
-f, --force 0|1 overwrite existing initramfs image
EOF
}
@ -65,6 +66,10 @@ parse_args() {
_debug="${2:?}"
shift 2
;;
-f | --force)
_force="${2:?}"
shift 2
;;
-h | --help)
usage
exit 0
@ -86,6 +91,7 @@ parse_conf() {
moddir="${_moddir:-${moddir:-/lib/modules}}"
filesdir="${_filesdir:-./files}"
debug="${_debug:-${debug:-0}}"
force="${_force:-${force:-0}}"
initramfs="${_initramfs:-${initramfs:-./initramfs-${kernel}}}"
modker="${moddir}/${kernel}"
}
@ -128,8 +134,8 @@ install_requirements() {
create_structure() {
msg info "creating directory structure"
for dir in dev tmp var run etc usr/lib usr/bin mnt/root proc root sys; do
mkdir -p "${workdir}/${dir}"
for _dir in dev tmp var run etc usr/lib usr/bin mnt/root proc root sys; do
mkdir -p "${workdir}/${_dir}"
done
}
@ -422,7 +428,7 @@ create_initramfs() {
# TODO add uncompressed option
# check if image already exist
[ -e "$initramfs" ] &&
[ ! "$force" = 1 ] && [ -e "$initramfs" ] &&
msg warn "looks like you already have initramfs image"
(