2014-01-04 20:33:49 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2014-01-06 15:17:56 +01:00
|
|
|
if [ "$1" = "-h" ]; then
|
2016-10-12 09:16:48 +02:00
|
|
|
cat <<EOF>&2
|
2014-01-06 15:17:56 +01:00
|
|
|
Usage: ${0##*/} [OPTIONS]
|
|
|
|
|
|
|
|
With no argument, start transmission-remote-cli. Otherwise, run
|
|
|
|
transmission-remote with the provided options.
|
|
|
|
|
|
|
|
In both cases if transmission-daemon is not running it will be started
|
|
|
|
beforehand.
|
|
|
|
|
|
|
|
EOF
|
2014-11-12 16:15:39 +01:00
|
|
|
exit
|
2014-01-06 15:17:56 +01:00
|
|
|
fi
|
|
|
|
|
2016-11-11 04:25:58 +01:00
|
|
|
for i in transmission-daemon transmission-remote-cli ; do
|
2016-10-12 09:16:48 +02:00
|
|
|
if ! command -v $i >/dev/null 2>&1; then
|
|
|
|
echo >&2 "'$i' not found"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
2014-01-06 15:17:56 +01:00
|
|
|
|
2016-10-12 09:16:48 +02:00
|
|
|
ps -U "$USER" -o comm= | grep -q transmission-da || transmission-daemon
|
2014-01-04 20:33:49 +01:00
|
|
|
if [ $# -eq 0 ]; then
|
2014-11-12 16:15:39 +01:00
|
|
|
exec transmission-remote-cli
|
2014-01-04 20:33:49 +01:00
|
|
|
else
|
2014-11-12 16:15:39 +01:00
|
|
|
## The 'sleep' is needed here to give the daemon some time to start. 1 sec
|
|
|
|
## should be enough on most system.
|
|
|
|
sleep 1
|
|
|
|
transmission-remote "$@"
|
2014-01-04 20:33:49 +01:00
|
|
|
fi
|