Skip to content

Instantly share code, notes, and snippets.

@vortex-5
Last active September 27, 2015 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vortex-5/1300249 to your computer and use it in GitHub Desktop.
Save vortex-5/1300249 to your computer and use it in GitHub Desktop.
utorrent server gist
# It is highly recommended that you run this under a user account and not as root
# The LOGFILE must also be set to a directory writable by the user account
# Location of the log file (must be by the current user writable)
env LOGFILE=/home/utorrent/log/utorrent.log
# Path to the utorrent server
env UTORRENT_PATH=/home/utorrent/shared/programs/utorrent/utorrent-server-v3_0
# Name of the utorrent server binary (you usually don't need to change this)
env EXEC=utserver
# Nice value you can comment this out if don't want to run at a lower priority
nice 15
start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [016]
# It is highly recommended that you don't run as the root user you will need
# to change this line to have your own user account for example:
#
# exec su <your user account> -c <utorrent command>
exec su utorrent -c "$UTORRENT_PATH/$EXEC -settingspath $UTORRENT_PATH -logfile $LOGFILE"
post-start script
#bind validation
while [ ! -e $LOGFILE ]; do
sleep 1 #Wait for file to be generated
done
while [ ! -n "$(cat $LOGFILE|grep 'IPv6 is installed')" ]; do
#wait until utorrent has finished bootup (IPv6 MESSAGE is the last message)
sleep 1
done
RESULT=$(cat $LOGFILE|grep 'bind failed')
if [ -n "$RESULT" ]; then
#bind failure stop the job
exit 3
fi
end script
post-stop script
#block process until server is completed shutting down fully
while [ -n "$(pidof "$EXEC")" ]; do
sleep 1
done
rm $LOGFILE
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment