optimize the usage of explorers for __filesystem

This commit is contained in:
Daniel Heule 2016-07-29 15:27:13 +02:00
parent 2ed762cd72
commit 36c20230b8
5 changed files with 7 additions and 119 deletions

View File

@ -1,38 +0,0 @@
#!/bin/sh
#
# 2016 - 2016 Daniel Heule (hda at sfs.biz)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
os=$("$__explorer/os")
blkdev="$(cat "$__object/parameter/blkdev")"
case "$os" in
centos|fedora|redhat|suse|gentoo)
if [ ! -x "$(command -v lsblk)" ]; then
echo "lsblk is required for __filesystem type" >&2
exit 1
else
echo -n $(lsblk -n -o FSTYPE "$blkdev" 2>/dev/null)
fi
;;
*)
echo "__filesystem type lacks implementation for os: $os" >&2
exit 1
;;
esac

View File

@ -1,38 +0,0 @@
#!/bin/sh
#
# 2016 - 2016 Daniel Heule (hda at sfs.biz)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
os=$("$__explorer/os")
blkdev="$(cat "$__object/parameter/blkdev")"
case "$os" in
centos|fedora|redhat|suse|gentoo)
if [ ! -x "$(command -v lsblk)" ]; then
echo "lsblk is required for __filesystem type" >&2
exit 1
else
echo -n $(lsblk -n -o LABEL "$blkdev" 2>/dev/null)
fi
;;
*)
echo "__filesystem type lacks implementation for os: $os" >&2
exit 1
;;
esac

View File

@ -1,38 +0,0 @@
#!/bin/sh
#
# 2016 - 2016 Daniel Heule (hda at sfs.biz)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
os=$("$__explorer/os")
blkdev="$(cat "$__object/parameter/blkdev")"
case "$os" in
centos|fedora|redhat|suse|gentoo)
if [ ! -x "$(command -v lsblk)" ]; then
echo "lsblk is required for __filesystem type" >&2
exit 1
else
echo -n $(lsblk -n -o MOUNTPOINT "$blkdev" 2>/dev/null)
fi
;;
*)
echo "__filesystem type lacks implementation for os: $os" >&2
exit 1
;;
esac

View File

@ -28,7 +28,8 @@ case "$os" in
echo "lsblk is required for __filesystem type" >&2
exit 1
else
echo -n $(lsblk -n -o NAME "$blkdev" 2>/dev/null)
#echo -n $(lsblk -nd -P -o NAME,FSTYPE,LABEL,MOUNTPOINT "$blkdev" 2>/dev/null)
lsblk -nd -P -o NAME,FSTYPE,LABEL,MOUNTPOINT "$blkdev" 2>/dev/null
fi
;;
*)

View File

@ -34,10 +34,11 @@ else
fi
blkdev_devname="$(cat "$__object/explorer/blkdev_devname")"
blkdev_fstype="$(cat "$__object/explorer/blkdev_fstype")"
blkdev_label="$(cat "$__object/explorer/blkdev_label")"
blkdev_mountpoint="$(cat "$__object/explorer/blkdev_mountpoint")"
blkdev_devname="$(grep -P -o2 'NAME="\K[^"]*' "$__object/explorer/lsblk")"
blkdev_fstype="$(grep -P -o2 'FSTYPE="\K[^"]*' "$__object/explorer/lsblk")"
blkdev_label="$(grep -P -o2 'LABEL="\K[^"]*' "$__object/explorer/lsblk")"
blkdev_mountpoint="$(grep -P -o2 'MOUNTPOINT="\K[^"]*' "$__object/explorer/lsblk")"
if [ -z "$blkdev_devname" ]; then
echo "Specified device $mydev not found on target system" >&2