107 lines
1.7 KiB
Bash
Executable File
107 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)
|
|
for file in assets/commands/*; do
|
|
[[ -x "${file}" ]] && commands+=("${file}")
|
|
done
|
|
|
|
. /assets/SOLUTION
|
|
. /etc/os-release
|
|
|
|
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 : ${NAME} ${VERSION}
|
|
Detected hardware : ${HW}
|
|
Package repository : ${GPGPU_PACKAGE_REPOSITORY}
|
|
Package stream : ${GPGPU_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 $?
|
|
}
|