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