0

I have one script to start a service on my ubuntu. I added it on boot machine using "# update-rc.d projeto defaults". But it still doesn't start with the boot machine. I think is because I am using other user to start the script "su - www-data -c ...". But I am not sure, because I run the update-rc.d command as root. When I execute the script from a terminal, it asks the password of the user www-data.

Does anyone know what is happening? Thanks a lot! Felipe

#!/bin/bash
# /var/www/boinc/projeto/bin/start

function action {
        su - www-data -c "/var/www/boinc/projeto/bin/$1"
}

case $1 in
        start|stop|status)
        action $1
        ;;
        *)
        echo "ERRO: usar $0 (start|stop|status)"
        exit 1
        ;;
esac

migrated from stackoverflow.com Sep 14 '12 at 21:26

This question came from our site for professional and enthusiast programmers.

  • Doesn't the -c option need to go before - user? – tripleee Sep 14 '12 at 14:52
  • No, didn't work with the -c before - user – user1546679 Sep 14 '12 at 14:58
1

I wrote a script with sleep function between the commands and it worked...

#!/bin/bash
# /var/www/boinc/projeto/bin/start

su - www-data -c "/var/www/boinc/projeto/bin/stop"
sleep 20
su - www-data -c "/var/www/boinc/projeto/bin/start"
  • You can even accept your own answers... (but maybe only after a certain time) – glglgl Sep 14 '12 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.