|
|
|
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
# Helper functions for programs that work with satellite files.
|
|
|
|
|
|
|
|
show_help() {
|
|
|
|
echo "!! THIS PROGRAM HAS BEEN DEPRECATED !!
|
|
|
|
This was a hack at best, and since freshnaut has been deprecated, it won't be needed anymore.
|
|
|
|
|
|
|
|
Script with helper functions for working with satellite files.
|
|
|
|
Usage: $0 <satellite file> <function> [arguments]
|
|
|
|
|
|
|
|
Functions:
|
|
|
|
variable <name> | Get variable set in the header
|
|
|
|
downloads | Get all download urls
|
|
|
|
options | List all available options and their descriptions"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# -lt 2 ]; then
|
|
|
|
show_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
satellite="$(realpath "$1")"
|
|
|
|
function="$2"
|
|
|
|
|
|
|
|
# Functions reused in all wrappers
|
|
|
|
global="$(printf '
|
|
|
|
download_only=true
|
|
|
|
name_sat="%s"
|
|
|
|
name="$name_sat"
|
|
|
|
|
|
|
|
import() {
|
|
|
|
. "%s/functions/$1.sh"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Allowed external utility commands
|
|
|
|
cut() { "%s" "$@"; }
|
|
|
|
expr() { "%s" "$@"; }
|
|
|
|
' "$(basename "$satellite" .sat)" "$(dirname "$satellite")" "$(command -v cut)" "$(command -v expr)")"
|
|
|
|
|
|
|
|
case "$function" in
|
|
|
|
variable)
|
|
|
|
if [ "$#" -lt 3 ]; then
|
|
|
|
show_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
name="$3"
|
|
|
|
|
|
|
|
printf "$global"'
|
|
|
|
_() {
|
|
|
|
variable="$%s"
|
|
|
|
[ "$variable" ] && echo "$variable"
|
|
|
|
exit $?
|
|
|
|
}
|
|
|
|
. %s
|
|
|
|
' "$name" "$satellite" | PATH= /bin/sh 2> /dev/null
|
|
|
|
;;
|
|
|
|
|
|
|
|
downloads)
|
|
|
|
printf "$global"'
|
|
|
|
download() {
|
|
|
|
[ "$1" ] && echo "$1"
|
|
|
|
}
|
|
|
|
dlextract() {
|
|
|
|
[ "$1" ] && echo "$1"
|
|
|
|
}
|
|
|
|
dlfile() {
|
|
|
|
[ "$1" ] && echo "$1"
|
|
|
|
}
|
|
|
|
_() { exit 0; }
|
|
|
|
. %s
|
|
|
|
' "$satellite" | PATH= /bin/sh 2> /dev/null
|
|
|
|
;;
|
|
|
|
|
|
|
|
options)
|
|
|
|
printf "$global"'
|
|
|
|
define_option() {
|
|
|
|
[ "$1" ] && echo "$1"
|
|
|
|
}
|
|
|
|
_() { exit 0; }
|
|
|
|
. %s
|
|
|
|
' "$satellite" | PATH= /bin/sh 2> /dev/null
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
show_help
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|