Improved entry point scripts (sort of)
Signed-off-by: James P. Ketrenos <james.p.ketrenos@intel.com>
This commit is contained in:
parent
8062ac263c
commit
6285d1ea75
@ -1,7 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
PARAM=$0
|
||||
PARAM=${PARAM/.\/cmd_}
|
||||
# Strip path and cmd_ prefix from command name
|
||||
PARAM=${PARAM##*/cmd_}
|
||||
|
||||
short() {
|
||||
echo "Decode H264 video and save as raw file"
|
||||
@ -40,7 +41,6 @@ ffmpeg \
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
arguments=()
|
||||
for arg in $*; do
|
||||
[[ $arg =~ ^-- ]] && {
|
||||
|
@ -1,7 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
PARAM=$0
|
||||
PARAM=${PARAM/.\/cmd_}
|
||||
# Strip path and cmd_ prefix from command name
|
||||
PARAM=${PARAM##*/cmd_}
|
||||
|
||||
short() {
|
||||
echo "Encode 10 frames from YUV420 raw input as H264 with 5Mbps using VBR mode"
|
||||
@ -43,8 +44,8 @@ ffmpeg -loglevel debug \
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
arguments=()
|
||||
|
||||
for arg in $*; do
|
||||
[[ $arg =~ ^-- ]] && {
|
||||
command=${arg/--}
|
||||
|
95
assets/entry
95
assets/entry
@ -1,14 +1,24 @@
|
||||
#!/bin/bash
|
||||
request=$1
|
||||
shift
|
||||
|
||||
commands=(info help version ffmpeg)
|
||||
commands+=(cmd_*)
|
||||
# Pull off any 'entry' options
|
||||
options=()
|
||||
arguments=()
|
||||
for arg in "$@"; do
|
||||
(( ${#arguments[@]} == 0 )) && [[ "${arg}" =~ ^--.* ]] && {
|
||||
options+=(${arg##--})
|
||||
} || {
|
||||
arguments+=($arg)
|
||||
}
|
||||
done
|
||||
|
||||
cd /assets
|
||||
request=${arguments[0]}
|
||||
arguments=("${arguments[@]:1}")
|
||||
|
||||
. SOLUTION
|
||||
. MANIFEST
|
||||
commands=(info help version ffmpeg shell)
|
||||
commands+=(/assets/cmd_*)
|
||||
|
||||
. /assets/SOLUTION
|
||||
. /assets/MANIFEST
|
||||
|
||||
name() {
|
||||
cat << EOF
|
||||
@ -33,6 +43,21 @@ 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"
|
||||
@ -48,7 +73,7 @@ ffmpeg() {
|
||||
[ "$1" == "--short" ] && {
|
||||
echo "Run ffmpeg commands."
|
||||
} || {
|
||||
/usr/local/bin/ffmpeg $*
|
||||
/usr/local/bin/ffmpeg "${@}"
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,35 +86,49 @@ $(name)
|
||||
|
||||
Commands:
|
||||
EOF
|
||||
# Change cmd_foo to ./cmd_foo in expansion below
|
||||
for cmd in ${commands[@]}; do
|
||||
printf " %-15s %s\n" ${cmd/cmd_} "$(${cmd/cmd_/./cmd_} --short)"
|
||||
printf " %-15s %s\n" ${cmd##*/cmd_} "$(${cmd} --short)"
|
||||
done
|
||||
}
|
||||
|
||||
echo ""
|
||||
}
|
||||
|
||||
case $request in
|
||||
info)
|
||||
info $*
|
||||
;;
|
||||
badOption() {
|
||||
cat << EOF
|
||||
$(name)
|
||||
|
||||
ffmpeg)
|
||||
ffmpeg $*
|
||||
;;
|
||||
Error: Unrecognized option: $1
|
||||
|
||||
version)
|
||||
version $*
|
||||
;;
|
||||
EOF
|
||||
exit 3
|
||||
}
|
||||
|
||||
help|"")
|
||||
help $*
|
||||
;;
|
||||
[[ "${request}" == "" ]] && {
|
||||
request="help"
|
||||
}
|
||||
|
||||
*)
|
||||
[ ! -f ./cmd_$request ] && {
|
||||
[[ " ${commands[@]} " =~ " ${request} " ]] && {
|
||||
$request "${arguments[@]}"
|
||||
exit $?
|
||||
}
|
||||
|
||||
for option in "${options[@]}"; do
|
||||
case $option in
|
||||
debug) debug=1
|
||||
;;
|
||||
*) unrecognizedOption $option
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ ! -f /assets/cmd_$request ] && {
|
||||
echo "'${request}' is not a recognized command."
|
||||
} || {
|
||||
(( $debug )) && {
|
||||
/bin/bash -x /assets/cmd_$request "${arguments[@]}"
|
||||
} || {
|
||||
./cmd_$request $*
|
||||
/assets/cmd_$request "${arguments[@]}"
|
||||
}
|
||||
;;
|
||||
esac
|
||||
exit $?
|
||||
}
|
||||
|
3
intel-docker
Executable file
3
intel-docker
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
QSV_DEVICE=${QSV_DEVICE:-/dev/dri/renderD128}
|
||||
docker run -e QSV_DEVICE --device=/dev/dri "$@"
|
Loading…
x
Reference in New Issue
Block a user