#!/bin/sh
#sfs 151009
STOP(){
    ntf -q "transmission.service запущен" "Остановить?" && wt "sudo systemctl stop transmission.service" && exit
}
systemctl is-active transmission.service && STOP

STOPM(){
    ntf -q "transmission запущен" "Остановить?" && wt "sudo killall transmission-daemon" && exit
}
#pidof transmission-daemon && STOPM

post_install() {
  post_upgrade
  sudo passwd -l transmission &>/dev/null
}

post_upgrade() {
  # create user/group that the daemon will run as by default, do not delete this on uninstall, as it will own files
  sudo getent group transmission >/dev/null || groupadd -g 169 transmission
  sudo getent passwd transmission >/dev/null || useradd -c 'Transmission BitTorrent Client' -u 169 -g transmission -b '/var/lib' -m -s /bin/false transmission
}
#post_install
www="http://localhost:9091" #/transmission/web/?lang=ru"
#dd="/home/`sfsusr`/Downloads"
if [ "`which rc`" ];then
    sudo wt "transmission-daemon  --log-error -e /var/log/transmission \
    --watch-dir "$dd" \
    --download-dir "$dd""  && defaultbrowser $www &
else
    echo "$www"
    sudo wt "systemctl start transmission.service" 
    defaultbrowser "http://localhost:9091" &
fi