Move sleep 5 to here before CheckForNetwork:
Determine if the network is up by looking for any non-loopback network interfaces.
Currently supports only OSX “Darwin” OS
Sleep 5 <---------------------------------------------------Insert here
CheckForNetwork()
{
local test
if [ -z “${NETWORKUP:=}” ]; then
test=$(ifconfig -a inet 2>/dev/null | sed -n -e ‘/127.0.0.1/d’ -e ‘/0.0.0.0/d’ -e ‘/inet/p’ | wc -l)
if [ “${test}” -gt 0 ]; then
NETWORKUP=“-YES-”
else
NETWORKUP=“-NO-”
fi
fi
}
Determine if the operating system is OSX “darwin”. If so, then delay running the rest of
the script until the network is up. This avoids the binding of PlexConnect to the
loopback address which occurs if the bash script is called from a LaunchDaemon/plist
file at boot time.
Sleep 5 <----------------------------------------------------Remove from here
What you should be doing is entering in your startup script code into terminal one part at a time until you find out what is preventing it from starting at boot. Make sure plexconnect is stopped before you try. This is how I discovered my osx box was not working and required sleep 1 in plexconnect.bash on osx in order to load plexconnect @ boot on unix.
https://github.com/wahlmanj/PlexConnect/blob/master/update/OSX/PlexConnect.bash
Just out of curiosity why are you using a unix startup script in part of your code that specifically looks for Darwin os aka OSX? In the 2nd post i provided in your topic none of them seem to use unix startup scripts so why are you? Where did you even come up with this script? Start here:
Not Ubuntu but maybe this will help.https://forums.plex.tv/topic/97010-plexconnect-on-archlinux/
Also this which has Ubuntu:https://forums.plex.tv/topic/71220-linux-install-for-plex-connect/
Your startup script should look similar to this:
Below is the init script. This script is saved as /etc/init.d/plexconnect.
#!/bin/bash
BEGIN INIT INFO
Provides: plexconnect
Required-Start: plexmediaserver networking
Required-Stop: plexmediaserver networking
Default-Start: 3 4 5
Default-Stop: 0 1 6
Short-Description: This is the Plex Connect daemon
Description: This script starts the Plex Connect
Python scripts in a detached screen.
END INIT INFO
Using the lsb functions to perform the operations.
. /lib/lsb/init-functions
Process name ( For display )
NAME=PlexConnect
Daemon name, where is the actual executable
DAEMON=“/usr/bin/screen”
DAEMON_OPTS=“-S PlexConnect -d -m /usr/local/lib/plexconnect/PlexConnect.py”
DAEMON_USER=“root”
pid file for the daemon
PIDFILE=/var/run/PlexConnect.pid
If the daemon is not there, then exit.
test -x “$DAEMON” || exit 5
case $1 in
start)
Checked the PID file exists and check the actual status of process
if [ -e $PIDFILE ]; then
status_of_proc -p $PIDFILE “$DAEMON $DAEMON_OPTS” “$NAME process” && status=“0” || status=“$?”
If the status is SUCCESS then don’t need to start again.
if [ $? = “0” ]; then
log_success_msg “Starting the process $NAME”
exit # Exit
fi
fi
Start the daemon.
Start the daemon with the help of start-stop-daemon
Log the message appropriately
if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -p $PIDFILE – ${DAEMON_OPTS}; then
while read line ; do [[ $line =~ ([0-9]*).PlexConnect ]] && echo ${BASH_REMATCH[1]} ; done < <(screen -ls) > $PIDFILE
log_success_msg “Starting the process $NAME”
else
log_failure_msg “Starting the process $NAME”
fi
;;
stop)
Stop the daemon.
if [ -e $PIDFILE ]; then
status_of_proc -p $PIDFILE “$DAEMON DAEMON_OPTS” “Stoppping the $NAME process” && status=“0” || status=“$?”
if [ “$?” = 0 ]; then
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
/bin/rm -rf $PIDFILE
log_success_msg ““Stopping the $NAME process””
fi
else
log_failure_msg “$NAME process is not running”
fi
;;
restart)
Restart the daemon.
$0 stop && sleep 2 && $0 start
;;
status)
Check the status of the process.
if [ -e $PIDFILE ]; then
status_of_proc -p $PIDFILE “$DAEMON $DAEMON_OPTS” “$NAME process” && exit 0 || exit $?
log_success_msg “$NAME process is running”
else
log_failure_msg “$NAME process is not running”
fi
;;
reload)
$0 restart
;;
*)
For invalid arguments, print the usage message.
echo “Usage: $0 {start|stop|restart|reload|status}”
exit 2
;;
esac
Now you need to make sure the script has the correct permissions and add it script as a service / daemon so that it starts automatically. Then start the daemon. To do this, make sure the permissions are correct and use update-rc.d. If you are using the root user you do not need the ‘sudo’ command at the front of the commands below.
sudo chown root:root /etc/init.d/plexconnect
sudo chmod 755 /etc/init.d/plexconnect
sudo update-rc.d plexconnect defaults
sudo /sbin/service plexconnect start