I am trying to get a simple bash script to run when I click on it. It runs perfectly from the cli but starting motion
with sudo
fails to start. I have that script setup with sudoers already for nopasswd, it starts up correctly and does not ask for password when run from cli. It also closes everything correctly when ran from cli, but it is almost like the sudo
lines get skipped when I just double click on the file and tell it to run.
Here is my script:
#!/bin/bash
check_process() {
[ "$1" = "" ] && return 0
[ `pgrep -n $1` ] && return 1 || return 0
}
check_process "motion"
if [ $? -eq 0 ]
then
sudo /etc/init.d/motion start
firefox http://localhost:8081/ > /dev/null &
else
sudo /etc/init.d/motion stop
killall firefox > /dev/null &
fi