How-to: Getting uShare to run at Startup

From

Jump to: navigation, search

Step 1: Open /etc/ushare.conf and setup all options as you would like them to be used.

sudo gedit /etc/ushare.conf


Step 2: Create a new Document. (Right Click >> Create Document >> Empty File) http://i601.photobucket.com/albums/tt100/tombstonex/create.jpg


Step 3: Open new Document and add the following to the file, then save.

#!/bin/bash
#
# Automatic Startup Script for uShare
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/ushare
NAME=ushare
DESC="uShare UPnP A/V Media Server"
PIDFILE=/tmp/ushare.pid


[ -r "/etc/ushare.conf" ] && . /etc/ushare.conf

# abort if no executable exists
[ -x $DAEMON ] || exit 0

# abort if no shared directory is defined
[ -z "$USHARE_DIR" ] && exit 0



set -e


checkpid() {
  [ -e $PIDFILE ] || touch $PIDFILE
}
case "$1" in
 start)
    echo -n "Starting $DESC: $NAME...........:"
    start-stop-daemon --start --quiet --background --oknodo \
      --make-pidfile --pidfile $PIDFILE \
      --exec $DAEMON -- $USHARE_OPTIONS
    echo -e " Completed.\n"
###############################################################################################
## Make uShare start with the settigns from the default configuration file (/etc/ushare.conf)##
###############################################################################################
echo -e "\n----------------------------------------------\r"
echo -e "| Started uShare with the following settings |\r"
echo -e "----------------------------------------------\n"

# Check for Xbox Support 
#
case  $ENABLE_XBOX  in
  yes)
    echo -e "XBOX Support:      Yes\r"
    string_xbox=-x
  ;;
  true)
    echo -e "XBOX Support:      Yes\r"
    string_xbox=-x
  ;;
  1)
    echo -e "XBOX Support:      Yes\r"
    string_xbox=-x
  ;;
  *)
    echo -e "XBOX Support:      No\r"
  ;;
           esac
alt
# Check for Enabled Webpage#
############################
case  $ENABLE_WEB  in
  yes)
if test $USHARE_PORT
then
string_port_display=$USHARE_PORT
string_port="-p $USHARE_PORT"
else
string_port_display=Random
fi
    echo -e "XBOX_WEB:          Yes - Running at http://YourIP:$string_port_display/web/ushare.html \r"
  ;;
  true)
if test $USHARE_PORT
then
string_port_display=$USHARE_PORT
string_port="-p $USHARE_PORT"
else
string_port_display=Random
fi
    echo -e "XBOX_WEB:          Yes - Running at http://YourIP:$string_port_display/web/ushare.html \r"
  ;;
  1)
if test $USHARE_PORT
then
string_port_display=$USHARE_PORT
string_port="-p $USHARE_PORT"
else
string_port_display=Random
fi
    echo -e "XBOX_WEB:          Yes - Running at http://YourIP:$string_port_display/web/ushare.html \r"
  ;;
  *)
    echo -e "XBOX_WEB:          No\r"
    string_web=-w

  ;;
           esac

# Check for Enabled Telnet#
###########################
case  $ENABLE_TELNET  in
  yes)
if test $USHARE_TELNET_PORT
then
string_telnet_port_display=$USHARE_TELNET_PORT
string_telnet_port="-q $USHARE_TELNET_PORT"
else
string_port_display=Random
fi
echo -e "Telnet Support:    Yes - Running on port: $string_telnet_port_display\r"
  ;;
  true)
if test $USHARE_TELNET_PORT
then
string_telnet_port_display=$USHARE_TELNET_PORT
string_telnet_port="-q $USHARE_TELNET_PORT"
else
string_port_display=Random
fi
echo -e "Telnet Support:    Yes - Running on port: $string_telnet_port_display\r"
  ;;
  1)
if test $USHARE_TELNET_PORT
then
string_telnet_port_display=$USHARE_TELNET_PORT
string_telnet_port="-q $USHARE_TELNET_PORT"
else
string_port_display=Random
fi
echo -e "Telnet Support:    Yes - Running on port: $string_telnet_port_display\r"
  ;;
  *)
    echo -e "Telnet Support:    No\r"
    string_telnet=-t
  ;;
           esac

# Check for DLNA Support#
#########################
case  $ENABLE_DLNA  in
  yes)
    echo -e "PS3/DLNA Support:  Yes\r"
    string_dlna=-d
  ;;
  true)
    echo -e "PS3/DLNA Support:  Yes\r"
    string_dlna=-d
  ;;
  1)
    echo -e "PS3/DLNA Support:  Yes\r"
    string_dlna=-d
  ;;
  *)
    echo -e "PS3/DLNA Support:  No\r"
  ;;
           esac

# Make The Command#
###################
   USHARE_OPTIONS="$string_web $string_telnet $string_xbox $string_dlna $string_port $string_telnet_port"
    echo -e "\a\nCommand used to start uShare: $DAEMON $USHARE_OPTIONS\n"
#################
# END OF SCRIPT #
#################
  ;;
 startup)
    sleep 12
    $0 start
  ;;
 stop)
    echo -n "Stopping $DESC: $NAME...........:"
    start-stop-daemon --stop --signal 2 --quiet --oknodo --pidfile $PIDFILE
    echo -e " Completed.\n"
  ;;
  reload|force-reload)
    echo -n "Reloading $DESC: $NAME...........:"
    start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $PIDFILE --e $PIDFILE
    echo -e " Completed.\n"
  ;;
  restart)
    $0 stop
    sleep 2
    $0 start
    echo -e "Restart Completed. \n"
  ;;
  --help)
    echo -e "\n\n\nuShare Startup Script, a modified startup script for uShare (version 1.1a)\r"
    echo -e "TombstoneX 2009\n"
    echo -e "Usage:     $N <command>\n"
    echo -e "<Commands>\r"
    echo -e "  start              Manual starting of uShare\r"
    echo -e "  startup            For use when using as a startup command\r"
    echo -e "  stop               Used to stop uShare\r"
    echo -e "  reload             Used to refresh the library file list\r"
    echo -e "  force-reload       Used to refresh the library file list\r"
    echo -e "  restart            Used to refresh the library file list\n\n"
  ;;
  *)
    N=/etc/init.d/$NAME
    echo -e "Usage: $N {start|stop|restart|reload}\n" >&2
    exit 2
  ;;
esac


exit 0

Step 4: Change the file to executable. (Right Click on file >> Properties >> under the Permissions tab >> Check mark "Allow executing file as program") http://i601.photobucket.com/albums/tt100/tombstonex/properties.jpg


Step 5: Add new script to startup. (System >> Preferences >> Startup Applications >> Click the "Add" button >> Give a name, Browse to the file you created >> Click Add) http://i601.photobucket.com/albums/tt100/tombstonex/startup.jpg

Step 6. Restart computer and go test Xbox360/PS3

Tip: If you add new files and need to restart the server go to terminal and type:

/location/to/file/filename restart


--TombstoneX 20:07, 2 June 2009 (EEST)

Personal tools
Sponsor
  System76