1
0
James Ketrenos 82aba14ec6 Red Hat images can now be built and pushed. See README.md
Signed-off-by: James Ketrenos <james.p.ketrenos@intel.com>
2019-11-07 11:59:01 -08:00

106 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
arguments=()
for arg in "$@"; do
arguments+=($arg)
done
# First argument is the command
request=${arguments[0]}
# Rest of the arguments
arguments=("${arguments[@]:1}")
commands=(info help version shell)
commands+=(/assets/commands/*)
. /assets/SOLUTION
. /assets/MANIFEST
name() {
cat << EOF
Intel Accelerated Graphics and Media Access container
Copyright (C) 2019 Intel Corporation
-----
EOF
}
info() {
HW=$(/assets/intel-gpu-info)
[ $? ] || {
HW="None"
}
[ "$1" == "--short" ] && {
echo "Information about running container environment"
} || {
cat << EOF
$(name)
Container base OS : ${OS_DISTRO} ${OS_RELEASE}
Release information: ${RELEASE_INFO}
Detected hardware : ${HW}
Package repository : ${PACKAGE_REPOSITORY}
Package stream : ${OS_DISTRO}-${PACKAGE_STREAM}
EOF
}
}
shell() {
[ "$1" == "--short" ] && {
echo "Access container via /bin/bash (similar to --entrypoint /bin/bash)"
} || {
(( ${#@} > 0 )) && {
cmd=$1
shift
$cmd "${@}"
exit $?
}
/bin/bash
}
}
version() {
[ "$1" == "--short" ] && {
echo "Show container version information"
} || {
cat << EOF
${CONTAINER} version ${RELEASE_INFO}.
EOF
}
}
help() {
[ "$1" == "--short" ] && {
echo "This help information"
} || {
cat << EOF
$(name)
Commands:
EOF
for cmd in ${commands[@]}; do
printf " %-15s %s\n" ${cmd##*/} "$(${cmd} --short)"
done
}
echo ""
}
[[ "${request}" == "" ]] && {
request="help"
}
[[ " ${commands[@]} " =~ " ${request} " ]] && {
$request "${arguments[@]}"
exit $?
}
[ ! -f /assets/commands/$request ] && {
shell "${request}" "${arguments[@]}"
} || {
/assets/commands/$request "${arguments[@]}"
exit $?
}