Results 1 to 4 of 4

Thread: Using a startup script to run an application installed in the opt folder...

  1. #1
    Join Date
    Jan 2012
    Beans
    7

    Using a startup script to run an application installed in the opt folder...

    Hi There

    I'm a Mac user who dabbles in a bit of the awesome ubuntu, I'm not a complete noob but I'm no expert! I've followed some really great steps on installing the airvideo server on my ubuntu 10.04 box at home. It all works nicely however I'm a little confused over the /opt folder - and not just for this application but in general when it comes to any application I would like to run from boot.

    The issue I'm having is when I run a script from /etc/init.d it wont work on boot. If I move the application to my home folder e.g move /opt/airvideo-server to /home/media and change the script to reflect the path, then it works. Obviously there is a permissions issue.

    If you want to know what steps I've taken so far (copied from the website instructions I'm following) see below:

    Fire up a terminal and enter

    sudo [text editor of choice] /etc/init.d/airvideo-server
    In the file (which should be blank), paste the following:

    #!/bin/bash
    case "$1" in
    start)
    echo "Starting AirVideo"
    start-stop-daemon --start --quiet -b -m -p /var/run/airvideo-server.pid --chuid airvideo --exec /usr/bin/java -- -jar /opt/airvideo-server/AirVideoServerLinux.jar /opt/airvideo-server/AirVideoServerLinux.properties
    ;;
    stop)
    echo "Stopping AirVideo"
    start-stop-daemon --stop --quiet --pidfile /var/run/airvideo-server.pid
    rm -f /var/run/airvideo-server
    ;;
    *)
    echo "Usage: /etc/init.d/airvideo-server {start|stop}"
    exit 1
    ;;
    esac
    exit 0
    Save the file out, then create the user which is going to be used to run the file. You should also double check to make sure that /opt/airvideo is readable by this account.

    sudo adduser airvideo
    Make the file executable, then add it to the startup defaults.

    sudo chmod +x /etc/init.d/airvideo-server
    sudo update-rc.d airvideo-server defaults
    When you next reboot your system, airvideo should start automatically.


    I've added the user 'airvideo' to my list of users as instructed, but what permissions need to be in place for:

    1) the user?
    2) /opt folder itself?
    3) /opt/airvideo-server folder?
    4) who needs to own the folder? or folders?
    5) what else would be needed for the script to work?

    This problem / solution would also help me with my teamspeak server setup which also only works outside of the /opt folder with a simple startup script.

    I appreciate any input and help! Thanks!

  2. #2
    Join Date
    Nov 2009
    Beans
    77
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Using a startup script to run an application installed in the opt folder...

    I don't know for sure if this will work but what I have done is create the bash file in a local folder (ie /home/smith/bash/script1.sh) then in the file /etc/rc.local call that file (ie sh /home/smith/bash/script1.sh). This should run the script upon start up right after the end of boot processes also this can be ran as sudo.
    "Excellent" -- mrburns

  3. #3
    Join Date
    Jan 2012
    Beans
    7

    Re: Using a startup script to run an application installed in the opt folder...

    Thanks for your suggestion. The only issue with this method is it will be dependent on a script in a home folder, which I'd prefer to avoid encase I make any changes or remove any of the home folders later on.

    Is there no other solution that would work within the /etc/init.d folder and /opt folder?

  4. #4
    Join Date
    Jan 2010
    Beans
    7

    Re: Using a startup script to run an application installed in the opt folder...

    A very simple way is to install your script in /usr/bin or /usr/local/bin.

    Then access Startup Applications and link to your script. Script will then be enabled at startup.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •