summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2017-07-25 16:07:40 +1000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2017-08-15 13:03:28 +1000
commit9f9bc4da3369b5637963064e2cd9d98e9dbd20d4 (patch)
tree004fa46daa2090933d7711ef7e0d89bce68558ce /utils
parent606c23f642a4e8a3a238cdbc3cd10d74708cbfad (diff)
downloadtalos-petitboot-9f9bc4da3369b5637963064e2cd9d98e9dbd20d4.tar.gz
talos-petitboot-9f9bc4da3369b5637963064e2cd9d98e9dbd20d4.zip
utils/pb-plugin: Advertise pb-plugins to discover server
Update the pb-plugin utility to create a 'plugin' pb-event when it successfully scans or installs a pb-plugin. To aid invoking pb-plugin from pb-discover there following two commands are updated: - `pb-plugin scan` can now be called for a single directory. - `pb-plugin install` now has an optional "auto" argument that will skip asking for confirmation before installation. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'utils')
-rwxr-xr-xutils/pb-plugin54
1 files changed, 40 insertions, 14 deletions
diff --git a/utils/pb-plugin b/utils/pb-plugin
index e107f96..a42d051 100755
--- a/utils/pb-plugin
+++ b/utils/pb-plugin
@@ -16,7 +16,7 @@ Usage: $0 <command>
Where <command> is one of:
install <FILE|URL> - install plugin from FILE/URL
- scan - look for available plugins on attached devices
+ scan <DIR> - look for available plugins on attached devices
create <DIR> - create a new plugin archive from DIR
lint <FILE> - perform a pre-distribution check on FILE
EOF
@@ -150,7 +150,12 @@ EOF
do_install()
{
- local url name file __dest
+ local url name file __dest auto
+
+ if [ "$1" == "auto" ]; then
+ auto=y
+ shift;
+ fi
url=$1
@@ -186,17 +191,20 @@ do_install()
sha256sum "$file" | cut -f1 -d' '
echo
- echo "Do you want to install this plugin? (y/N)"
- read resp
+ if [ -z "$auto" ]
+ then
+ echo "Do you want to install this plugin? (y/N)"
+ read resp
- case $resp in
- [yY]|[yY][eE][sS])
- ;;
- *)
- echo "Cancelled"
- exit 0
- ;;
- esac
+ case $resp in
+ [yY]|[yY][eE][sS])
+ ;;
+ *)
+ echo "Cancelled"
+ exit 0
+ ;;
+ esac
+ fi
__dest=$(mktemp -d)
gunzip -c "$file" | ( cd $__dest && cpio -i -d)
@@ -223,6 +231,12 @@ do_install()
__create_wrapper "$__dest" "$binary"
done
+ pb-event plugin@local \
+ name=$PLUGIN_NAME id=$PLUGIN_ID version=$PLUGIN_VERSION \
+ vendor=$PLUGIN_VENDOR vendor_id=$PLUGIN_VENDOR_ID \
+ date=$PLUGIN_DATE executables="$PLUGIN_EXECUTABLES" \
+ source_file=$url installed="yes"
+
echo "Plugin installed"
plugin_info
}
@@ -260,6 +274,9 @@ do_scan_mount()
printf "To run this plugin:\n"
printf " $0 install $plugin_path\n"
printf "\n"
+
+ pb-event plugin@$dev name=$PLUGIN_NAME \
+ path=$plugin_path installed="no"
)
if [ $? = 0 ]
then
@@ -271,9 +288,18 @@ do_scan_mount()
do_scan()
{
- local found mnt
+ local found mnt dev locations
found=0
- for mnt in $__pb_mount_dir/*
+ dev=$1
+
+ if [ -z $dev ]; then
+ locations=$__pb_mount_dir/*
+ else
+ echo "Scanning device $dev"
+ locations=$dev
+ fi
+
+ for mnt in $locations
do
do_scan_mount $mnt
done
OpenPOWER on IntegriCloud