Page 1 of 5 123 ... LastLast
Results 1 to 10 of 48

Thread: mocp (music on console player) init.d script doesn't work unless i cd to /etc/init.d

  1. #1

    mocp (music on console player) init.d script doesn't work unless i cd to /etc/init.d

    hello. i was wondering what would cause an init.d script to not load unless the user cd'd to the /etc/init.d directory it was located manually? i am using mocp under an ubuntu 12.04 minimal console (no x, no de, or wm) and am trying to make a music jukebox (i have already tried xbmc and geexbox but i want a dedicated mp3 playback setup with basic ff/rw, skip, stop, pause, etc - nothing else). i would like mocp to start at boot from a console and i don't have x installed (don't need it). mocp itself runs superb even after resuming from suspend, but when i type:

    Code:
    sudo /etc/init.d/mocp start
    and enter my password i get:

    Code:
    /etc/init.d/mocp: 64: /etc/init.d/mocp: Syntax error: unexpected end of file (expecting ";;")
    but when i manually cd to the directory typing:

    Code:
    cd /etc/init.d
    to go to the directory the mocp init script is in and then type:

    Code:
    sudo mocp start
    to run it, it starts.

    what is going on here? i wonder what part of the script is having the snafoo (if there really is a syntax error, where does the ";;" bash was expecting go?)?

    here is the script if anyone wants to have a look: http://pastebin.com/gPXfRq56

    thanks a bunch!
    Last edited by thebestofall007; June 2nd, 2012 at 03:02 AM.

  2. #2
    Join Date
    May 2010
    Location
    uk
    Beans
    8,221
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: mocp (music on console player) init.d script doesn't work unless i cd to /etc/ini

    Hi

    First things first. There is a problem with the script. Add the three lines highlighted in bold to the bottom of it. I've left three of the original lines for reference as well

    Code:
    *)
            echo "Usage: $0 {start|stop|restart|status}"
            exit 1
    ;;
    
    esac
    
    exit 0;
    EDIT: In the case of this script, i'm not sure the last exit 0; need to be there but.. meh.

    Kind regards
    Last edited by matt_symes; June 2nd, 2012 at 05:08 PM.
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

  3. #3
    Join Date
    May 2010
    Location
    uk
    Beans
    8,221
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: mocp (music on console player) init.d script doesn't work unless i cd to /etc/ini

    Hi

    Sorry for the delay. I had to pop out to the supermarket.

    to go to the directory the mocp init script is in and then type:

    Code:
    sudo mocp start
    to run it, it starts.
    Before making the changes in my last post, what happens when you navigate to the /etc/init.d directory and type

    Code:
    sudo ./mocp start


    EDIT: Hint. Bear in mind that mocp is mostly likely going to be in your list of paths.

    Kind regards
    Last edited by matt_symes; June 2nd, 2012 at 05:08 PM.
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

  4. #4

    Re: mocp (music on console player) init.d script doesn't work unless i cd to /etc/ini

    Quote Originally Posted by matt_symes View Post
    Hi

    First things first. There is a problem with the script. Add the three lines highlighted in bold to the bottom of it. I've left three of the original lines for reference as well

    Code:
    *)
            echo "Usage: $0 {start|stop|restart|status}"
            exit 1
    ;;
    
    esac
    
    exit 0;
    EDIT: In the case of this script, i'm not sure the last exit 0; need to be there but.. meh.

    Kind regards
    made the changes you noted plus changed "USER" references to my account name (like in "export HOME=/home/USER") , but now i am getting a
    Code:
    start-stop-daemon: need at least one of --exec, --pidfile, --user, or --name try 'start-stop-daemon --help' for more  information

  5. #5

    Re: mocp (music on console player) init.d script doesn't work unless i cd to /etc/ini

    Quote Originally Posted by matt_symes View Post
    Hi

    Sorry for the delay. I had to pop out to the supermarket.



    Before making the changes in my last post, what happens when you navigate to the /etc/init.d directory and type:
    Code:
    sudo ./mocp start


    EDIT: Hint. Bear in mind that mocp is mostly likely going to be in your list of paths.

    Kind regards
    it outputs a command not found if done from the default home directory. but cd'ing to the /etc/init.d directory and typing sudo mocp start starts it. but typing sudo ./mocp start after cd'ing outputs:
    Code:
    start-stop-daemon: need at least one of --exec, --pidfile, --user, or --name try 'start-stop-daemon --help' for more  information
    Last edited by thebestofall007; June 2nd, 2012 at 05:47 PM.

  6. #6
    Join Date
    May 2010
    Location
    uk
    Beans
    8,221
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: mocp (music on console player) init.d script doesn't work unless i cd to /etc/ini

    Hi

    Quote Originally Posted by thebestofall007 View Post
    made the changes you noted plus changed "USER" references to my account name (like in "export HOME=/home/USER") , but now i am getting a
    Code:
    start-stop-daemon: need at least one of --exec, --pidfile, --user, or --name try 'start-stop-daemon --help' for more  information
    That is a different error so that means the script is running now even if it is not working correctly.

    A couple of questions as i do not have mocp installed in my system.

    1. What version and what release of *buntu are you using ?

    2. How did you install mocp ? From a ppa, sofware center, compiled from source etc.... Please post the exact commands you used.

    3. Did you have any errors when you installed the script ?

    I am really surprised there were errors in the init script in the first place and i would like to see where you got it from.

    I may also then set up a VM and install your setup and the install mocp the way you did and see what happens.

    Kind regards
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

  7. #7

    Re: mocp (music on console player) init.d script doesn't work unless i cd to /etc/ini

    1. i'm running ubuntu 12.04 minimal from an iso i downloaded from http://archive.ubuntu.com/ubuntu/dis...tboot/mini.iso and didn't install ANY packages in the install.

    2. i installed mocp using
    Code:
    sudo apt-get install moc
    It is in the repo's. the program is called moc, and it is started by typing "mocp".

    3. nope. i didn't have any errors when i installed it. i renamed the script to mocp and moved it into the /etc/init.d directory, cd'd to the directory, typed:
    Code:
    sudo update-rc.d mocp defaults
    .

    to update the startup. before i did this, i had to install dos2unix by typing
    Code:
    sudo apt-get install dos2unix
    and run it on the mocp script to make it unix compatible as it will be dos encoded, then typed
    Code:
    chmod a+x mocp
    to make it executable, then ran it manually by typing:
    Code:
    sudo mocp start
    it ran as explained earlier.

    the site i got the script is here:http://moc.daper.net/node/744

    please let me know what comes up. thanks.
    Last edited by thebestofall007; June 2nd, 2012 at 06:37 PM.

  8. #8
    Join Date
    May 2010
    Location
    uk
    Beans
    8,221
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: mocp (music on console player) init.d script doesn't work unless i cd to /etc/ini

    Hi

    Another fan of minimal installs. Nice

    I will install it on Quantal and see what it does.

    Not to disparage the writer of that script, however it does not seem to work.

    Give me an hour or two to eat first though.

    Kind regards
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

  9. #9
    Join Date
    May 2010
    Location
    uk
    Beans
    8,221
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: mocp (music on console player) init.d script doesn't work unless i cd to /etc/ini

    Hi

    I've had a look at the script and only really found a few issues. This is the ammended script.

    I cannot test this until tomorrow so i am posting this at risk but if there are any problems then we can look at them tomorrow.

    I think i have fixed the issues (but like i said i cant test this tonight) and i modified the code slightly.

    Change USER=matthew to your user name.

    Uncomment out any of the lines below where i have said uncomment below, for that functionality...

    Code:
    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides:             MOCP Application Instance
    # Required-Start:       $all
    # Required-Stop:
    # Default-Start:        2 3 4 5
    # Default-Stop:         0 1 6
    # Short-Description:    starts instance of mocp
    # Description:          starts instance of mocp using start-stop-daemon
    ### END INIT INFO
    
    # Change the user here as required
    USER=matthew
    
    is_running()
    {
    	# Start the daemon
            if ! pidof -o  %PPID mocp > /dev/null; then
            	return 1;
    	else
    		return 0;
            fi
    }
    
    start_mocd()
    {
    	if ! is_running; then
    
    		echo "Starting MOCP...";
    
                    # Start the daemon
                    start-stop-daemon --start --chuid "$USER" --exec /usr/bin/mocp -- -S;
    
    		# Give time for the daemon to start
    		sleep 2;
    
    		# Uncomment below for full volume
                    #/usr/bin/mocp --volume 100 --play;
    
    		# Uncomment below for shuffle
                    #/usr/bin/mocp --on shuffle;
    
    		# Uncomment below for auto next
                    #/usr/bin/mocp --on autonext;
    
    		# Uncomment below for auto repeat
    		#/usr/bin/mocp --on repeat;
    
    		echo "Starting MOCP...";
    	else
                    echo "MOCP Already Running...";
            fi
    }
    
    stop_mocd()
    {
    	if is_running; then
    		# Stop the daemon
    		start-stop-daemon --stop --exec /usr/bin/mocp -- -x;
    	else
    		echo "MOCP is not running";
    	fi
    }
    
    case "$1" in
    	start)
    		# Start moc as a daemon.
    		start_mocd;
    	;;
    
    	stop)
            	stop_mocd;
    	;;
    
    	restart)
    		# Stop mocd
    		stop_mocd;
    
    		# Give time for the daemon to stop.
    		sleep 1;
    
    		# Restart the daemon
    		start_mocd;
    	;;
    
    	status)
    
    		if is_running; then
    			echo "Running";
    			exit 0;
    		else
    			echo "Not running";
    			exit 1;
    		fi
    	;;
    
    	*)
            	echo "Usage: $0 {start|stop|restart|status}"
            	exit 0;
    	;;
    esac
    Last edited by matt_symes; June 2nd, 2012 at 10:27 PM.
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

  10. #10

    Re: mocp (music on console player) init.d script doesn't work unless i cd to /etc/ini

    Quote Originally Posted by matt_symes View Post
    Hi

    I've had a look at the script and only really found a few issues. This is the ammended script.

    I cannot test this until tomorrow so i am posting this at risk but if there are any problems then we can look at them tomorrow.

    I think i have fixed the issues (but like i said i cant test this tonight) and i modified the code slightly.

    Change USER=matthew to your user name.

    Uncomment out any of the lines below where i have said uncomment below, for that functionality...

    Code:
    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides:             MOCP Application Instance
    # Required-Start:       $all
    # Required-Stop:
    # Default-Start:        2 3 4 5
    # Default-Stop:         0 1 6
    # Short-Description:    starts instance of mocp
    # Description:          starts instance of mocp using start-stop-daemon
    ### END INIT INFO
    
    # Change the user here as required
    USER=matthew
    
    is_running()
    {
    	# Start the daemon
            if ! pidof -o  %PPID mocp > /dev/null; then
            	return 1;
    	else
    		return 0;
            fi
    }
    
    start_mocd()
    {
    	if ! is_running; then
    
    		echo "Starting MOCP...";
    
                    # Start the daemon
                    start-stop-daemon --start --chuid "$USER" --exec /usr/bin/mocp -- -S;
    
    		# Give time for the daemon to start
    		sleep 2;
    
    		# Uncomment below for full volume
                    #/usr/bin/mocp --volume 100 --play;
    
    		# Uncomment below for shuffle
                    #/usr/bin/mocp --on shuffle;
    
    		# Uncomment below for auto next
                    #/usr/bin/mocp --on autonext;
    
    		# Uncomment below for auto repeat
    		#/usr/bin/mocp --on repeat;
    
    		echo "Starting MOCP...";
    	else
                    echo "MOCP Already Running...";
            fi
    }
    
    stop_mocd()
    {
    	if is_running; then
    		# Stop the daemon
    		start-stop-daemon --stop --exec /usr/bin/mocp -- -x;
    	else
    		echo "MOCP is not running";
    	fi
    }
    
    case "$1" in
    	start)
    		# Start moc as a daemon.
    		start_mocd;
    	;;
    
    	stop)
            	stop_mocd;
    	;;
    
    	restart)
    		# Stop mocd
    		stop_mocd;
    
    		# Give time for the daemon to stop.
    		sleep 1;
    
    		# Restart the daemon
    		start_mocd;
    	;;
    
    	status)
    
    		if is_running; then
    			echo "Running";
    			exit 0;
    		else
    			echo "Not running";
    			exit 1;
    		fi
    	;;
    
    	*)
            	echo "Usage: $0 {start|stop|restart|status}"
            	exit 0;
    	;;
    esac
    this split the log wide open, but i have one question: how do you i get the player to start up @ boot with the default blue ncurses interface that is invoked when a user types "mocp" in the terminal/console when running the binary? the script loads mocp as a daemon, but i get no player/interface.

    again, THANKS A BUNCH!!

Page 1 of 5 123 ... LastLast

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
  •