1
0

Improved entry point scripts (sort of)

Signed-off-by: James P. Ketrenos <james.p.ketrenos@intel.com>
This commit is contained in:
James P. Ketrenos 2019-09-19 14:17:44 -07:00
parent 8062ac263c
commit 6285d1ea75
4 changed files with 76 additions and 33 deletions

View File

@ -1,7 +1,8 @@
#!/bin/bash #!/bin/bash
PARAM=$0 PARAM=$0
PARAM=${PARAM/.\/cmd_} # Strip path and cmd_ prefix from command name
PARAM=${PARAM##*/cmd_}
short() { short() {
echo "Decode H264 video and save as raw file" echo "Decode H264 video and save as raw file"
@ -40,7 +41,6 @@ ffmpeg \
EOF EOF
} }
arguments=() arguments=()
for arg in $*; do for arg in $*; do
[[ $arg =~ ^-- ]] && { [[ $arg =~ ^-- ]] && {

View File

@ -1,7 +1,8 @@
#!/bin/bash #!/bin/bash
PARAM=$0 PARAM=$0
PARAM=${PARAM/.\/cmd_} # Strip path and cmd_ prefix from command name
PARAM=${PARAM##*/cmd_}
short() { short() {
echo "Encode 10 frames from YUV420 raw input as H264 with 5Mbps using VBR mode" echo "Encode 10 frames from YUV420 raw input as H264 with 5Mbps using VBR mode"
@ -43,8 +44,8 @@ ffmpeg -loglevel debug \
EOF EOF
} }
arguments=() arguments=()
for arg in $*; do for arg in $*; do
[[ $arg =~ ^-- ]] && { [[ $arg =~ ^-- ]] && {
command=${arg/--} command=${arg/--}

View File

@ -1,14 +1,24 @@
#!/bin/bash #!/bin/bash
request=$1
shift
commands=(info help version ffmpeg) # Pull off any 'entry' options
commands+=(cmd_*) options=()
arguments=()
for arg in "$@"; do
(( ${#arguments[@]} == 0 )) && [[ "${arg}" =~ ^--.* ]] && {
options+=(${arg##--})
} || {
arguments+=($arg)
}
done
cd /assets request=${arguments[0]}
arguments=("${arguments[@]:1}")
. SOLUTION commands=(info help version ffmpeg shell)
. MANIFEST commands+=(/assets/cmd_*)
. /assets/SOLUTION
. /assets/MANIFEST
name() { name() {
cat << EOF 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() { version() {
[ "$1" == "--short" ] && { [ "$1" == "--short" ] && {
echo "Show container version information" echo "Show container version information"
@ -48,7 +73,7 @@ ffmpeg() {
[ "$1" == "--short" ] && { [ "$1" == "--short" ] && {
echo "Run ffmpeg commands." echo "Run ffmpeg commands."
} || { } || {
/usr/local/bin/ffmpeg $* /usr/local/bin/ffmpeg "${@}"
} }
} }
@ -61,35 +86,49 @@ $(name)
Commands: Commands:
EOF EOF
# Change cmd_foo to ./cmd_foo in expansion below
for cmd in ${commands[@]}; do for cmd in ${commands[@]}; do
printf " %-15s %s\n" ${cmd/cmd_} "$(${cmd/cmd_/./cmd_} --short)" printf " %-15s %s\n" ${cmd##*/cmd_} "$(${cmd} --short)"
done done
} }
echo ""
} }
case $request in badOption() {
info) cat << EOF
info $* $(name)
;;
ffmpeg) Error: Unrecognized option: $1
ffmpeg $*
;;
version) EOF
version $* exit 3
;; }
help|"") [[ "${request}" == "" ]] && {
help $* request="help"
;; }
*) [[ " ${commands[@]} " =~ " ${request} " ]] && {
[ ! -f ./cmd_$request ] && { $request "${arguments[@]}"
echo "'${request}' is not a recognized command." 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[@]}"
} }
;; exit $?
esac }

3
intel-docker Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
QSV_DEVICE=${QSV_DEVICE:-/dev/dri/renderD128}
docker run -e QSV_DEVICE --device=/dev/dri "$@"