#!/bin/sh if [ "$1" = "-h" ]; then cat <&2 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 exit fi for i in transmission-daemon transmission-remote-cli ; do if ! command -v $i >/dev/null 2>&1; then echo >&2 "'$i' not found" exit 1 fi done ps -U "$USER" -o comm= | grep -q transmission-da || transmission-daemon if [ $# -eq 0 ]; then exec transmission-remote-cli else ## 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 "$@" fi