#!/bin/bash # # Kill mythfrontend in Ubuntu. # # When killing mythfrontend.real, do it twice with kill -15 to overcome bug in # MythTV GUI programs where they do not shut down properly with just one kill -15. # If it still does not shut down, use kill -9. # Note: This script is intended for use with MythTV on Ubuntu, where a script # "mythfrontend" is used to run the real mythfrontend program "mythfrontend.real". # If you do want the "mythfrontend" script to automatically restart # "mythfrontend.real", then change the follwing "kill_mythfrontend_script=1" to # "kill_mythfrontend_script=0" kill_mythfrontend_script=0 # If there is any parameter on the command line (it does not matter what the # text of the parameter is), then force the "mythbuntu" script to also be killed. if [ "$1" != "" ]; then kill_script=1 else kill_script=$kill_mythfrontend_script fi # Kill the "mythfrontend" script. if [ $kill_script -ne 0 ]; then pid=$(ps -ef | grep "/bin/sh /usr/bin/mythfrontend" | grep -v grep | awk '{print $2}') if [ "$pid" != "" ]; then kill $pid fi fi # Kill mythfrontend.real. oldpid=$(pidof mythfrontend.real) if [ "$oldpid" != "" ]; then if [ $oldpid -ne 0 ]; then kill -15 $oldpid sleep 1 kill -15 $oldpid sleep 0.1 newpid=$(pidof mythfrontend.real) if [ "$newpid" != "" ]; then if [ $newpid -eq $oldpid ]; then #echo Mythfrontend has not shut down - doing kill -9 kill -9 $oldpid fi fi fi fi