core-agent-linux/qubes-rpc/qubes.Backup
Marek Marczykowski-Górecki 9c839d789f
qubes-rpc: fix issues found by shellcheck
Most of them are missing quotes, `` -> $(), and -o/-a usage in
conditions. Also add few directives disabling checks where were too
verbose.
2017-09-30 04:45:31 +02:00

25 lines
631 B
Bash
Executable File

#!/bin/sh
echo Starting Backupcopy
read -r args
echo Arguments: "$args"
if [ -d "$args" ] ; then
echo "Performing backup to directory $args"
TARGET="$args/qubes-backup-$(date +'%Y-%m-%dT%H%M%S')"
echo "Copying STDIN data to $TARGET"
cat > "$TARGET"
else
echo "Checking if arguments is matching a command"
COMMAND=$(echo "$args" | cut -d ' ' -f 1)
if command -v "$COMMAND" >/dev/null; then
echo "Redirecting STDIN to $args"
# Parsing args to handle quotes correctly
# Dangerous method if args are uncontrolled
eval "set -- $args"
"$@"
else
echo "Invalid command $COMMAND"
exit 1
fi
fi