User:Deej
http://www.fragland.org/deej/572.gif
Guilty for founding the Retired Old Farts which provide:
- ETPro servers
- ETTV servers
- ETPub servers
- General annoyance
- Pub requests for a competition mod
My interpretation of ETTV setups
Since I'm quite fond of toying around with new developments, I'm always one of the first to test new ETTV / ETPro releases and bug bani with questions about them. Having said that, here's my 'personal' view on a good ETTV broadcast (this is not the Bible!):
Terminology
There are 5 different "participants" possibly involved in an ETTV broadcast:
- Master - the gameserver hosting the actual game
- Viewer - the viewer wanting to view a game (duh)
- Broadcaster - a server that is directly connected to a gameserver and allows viewer to connect directly to itself
- Hub - a server that is directly connected to a gameserver and allows other ETTV 'slaves' to connect to itself, but not viewers
- Slave - a server that connects to a hub or perhaps a broadcaster and and allows viewers to connect to itself
Keep this terminology in mind when you stroll through my text ;-).
Today's broadcasts
Most ETTV games I see today use this set-up:
Viewer -> Broadcaster -> Master
If you remember that an ETTV server connects at an unlimited rate to another server, you might see a problem arising when lots of people would like to see a "big match".
The trouble was / is that before ETTV b8 and 'autodelay', we had to do some fancy flying to get a delayed broadcast or delayed hub up. Usually you would start a 'recorder' daemon that recorded demos and a 'playback' daemon from that same directory, so that it started playing back the recorded demo after roughly 60 or 90 seconds. This does require fancy scripting and lots of manual work to sort out demos, connect slaves to hubs etc...
With ettv_autodelay, things have become a lot easier. Ideally the gameserver now only allows 2 or 4 ETTV hubs to connect to it, which delay and relay the signal. The responsibility for the admins of the hub is of course greater as they should not have any PK3s active on their hubs that are not on the pure list of the server. The less PK3s you need, the better!
Deej's proposition
The best setup IMHO is to have the following:
Viewers -> Slave 1 |
Viewers -> Slave 2 |
Viewers -> Slave 3 |--> Hub 1 |
|--> Hub 2 | --> Master
Viewers -> Slave ... |--> Hub n |
|
Viewers -> Slave n |
This alleviates the load on the Master Game Server firmly as only 2 or 4 hubs are required where slaves can then connect to! Furthermore with autodelay all the 'slave' administrators only need to connect their slave to a given hub. No more playing around with delays, demos, symbolic links, PIDs that get screwed up etc...
Some scripts I use
Hub script
This script launches a hub that delays its feed by x seconds, configurable inside the script. You can safely remove the stuff like PERONI_IP, FRAGLAND_IP etc... at the beginning since those only store the IPs of the root servers we manage (it's easier for me to keep track of them that way).
How do you use this script? Copy / paste this script and save it as hub.sh or any other name you prefer. Then use ./hub.sh start to start and ./hub.sh stop to stop your hub.
Be aware that it's much better to actually do "quit" in the console of your hub instead of ./hub.sh stop as this cleanly disconnects the hub from a game server. With ./hub.sh stop the hub stays with ping 999 on the gameserver and needs to time out. Maybe we should ask Bani to improve POSIX signal interpretation of the ETTV binary :-).
#!/bin/bash
#################################################################
# #
# reT!reD.ettv delayed hub script #
# - #
# reT!reD.deej #
# #
#################################################################
# #
# This script can be used to start up a delayed ETTV stream #
# where ETTV slaves connect to the hub to relay the signal. #
# #
# The daemon serves as a hub for other ETTV slaves to connect #
# to and as such alleviate the load on the game server hosting #
# the match. #
# #
# This script creates a subdirectory which represents the #
# date of the match and stores the demos in this subdir. #
# #
# The script launches the daemon in a different screen #
# which you can reattach with "screen -r hub". #
# #
# Credits: #
# - Daita (pourix.net) for the original idea & script #
# - Tony J. White (et.tjw.org) for his ETDED on Linux guide #
# - aNgel (fragland.org) for debugging Beavis' mistakes ;-) #
# #
# Questions? Contact me on deej@fragland.org or go to #r0f.et #
# #
#################################################################
# #
# http://www.fragland.org #
# #
#################################################################
# Webperoni Game Server IP
# ettv.fragland.org
PERONI_IP="83.133.81.192"
# Deinprovider WebServer IP
# ettv2.fragland.org
FRAGLAND_IP="217.20.115.116"
# Ionmedia Game Server IP
# ettv3.fragland.org
IONMEDIA_IP="62.216.174.68"
# Hetzner Game Server IP
# WServer2.ath.cx IP
# ettv4.fragland.org
HETZNER_IP="213.239.207.195"
# Planet Hosting Game Server IP
# ettv5.fragland.org
PLANET_IP="85.190.1.13"
#################################################################
# #
# Start Modifying From Here #
# #
#################################################################
#
# Parameters of the Game Server to Connect to
#
# IMPORTANT: Let the admin of the game server do
# "fdir *.pk3" in his console and give you the output!
#
# PK3 mismatches between game server and ETTV hosts
# account for the majority of crashes of ETTV.
#
MATCH_DATE=`date +%Y%m%d` # Do NOT modify
MATCH_HOST="et.fragland.org:27965" # Match server port & address
MATCH_ETTV_PASS="[get_pass_from_admin]" # Match server ETTV password
MATCH_PASS="[get_pass_from_admin]" # Match server password
#
# IPs & Ports For Your Host
#
THISHOST_IP=$PERONI_IP # Replace with your IP
HUB_PORT="50000" # Port of the public hub for ETTV slaves
#
# Hostnames & ETTV Client name
#
# - hostname shows up in server browsers
# - ETTV client name shows up as the name
# of your server in the game server.
#
HUB_HOSTNAME="^7reT^1!^7reD^1.^7ettv ^7hub ^1#^71"
ETTV_CLIENT=$HUB_HOSTNAME
#
# Passwords
#
HUB_RCON_PASS="[put_your_pass_here]"
HUB_PRIVATE_PASS="[put_your_pass_here]"
HUB_ETTV_PASS="[put_your_pass_here]"
HUB_PASS="[put_your_pass_here]"
#
# Directories
#
BASEPATH="/srv/et/ETTV/ettv_hub" # Path to ettv.x86. Use absolute paths!
#
# ETTV Net settings for ETTV b8 & up
#
ETTV_NETBLAST="1" # Sends all packets as one big one
ETTV_TV_IPTOS="0"
ETTV_SV_IPTOS="0"
ETTV_MTU="1400" # Can be increased to avoid fragmentation
#
# Other relevant ETTV settings
#
SHOUTCAST_DELAY="60" # Delay between live match & broadcasting hub in seconds
HUB_SLAVES="8" # 1 ETTV slave connects at an UNLIMITED rate to the hub!
ALLOW_DL="0" # Allow downloading (only works for viewers on slaves)
ALLOW_WWW_DL="0" # Allow downloading over http?
WWW_DL_URL="http://www.yoursite.com" # Do not append a "/" at the end!
#
# User To Launch Daemon
#
# Good practice:
# What doesn't need root priviliges doesn't get them!
#
# User gamed mentioned here under is not a standard linux user,
# he was created on our systems by us.
#
# gamed can not log in. His homedir is equal to the path
# where all our servers are installed.
#
USER="gamed"
#################################################################
# #
# STOP Modifying Here #
# #
#################################################################
#
# Assembling the Command Line
#
HOMEPATH="$BASEPATH/$MATCH_DATE"
BINARY="ettv.x86"
DAEMON="$BASEPATH/$BINARY"
HUB_OPTIONS="\
+set fs_game etpro \
+set dedicated 2 \
+set net_ip $THISHOST_IP \
+set net_port $HUB_PORT \
+set fs_basepath $BASEPATH \
+set fs_homepath $HOMEPATH \
+set com_hunkMegs 128 \
+set g_password $HUB_PASS \
+set rconpassword $HUB_RCON_PASS \
+set sv_hostname $HUB_HOSTNAME \
+set sv_maxclients $((HUB_SLAVES+2)) \
+set sv_maxRate 25000 \
+set sv_allowDownload $ALLOW_DL \
+set sv_wwwDownload $ALLOW_WWW_DL \
+set sv_wwwBaseURL "$WWW_DL_URL" \
+set sv_wwwDlDisconnected 0 \
+set g_log "hub.log" \
+set logfile 2 \
+set b_ettv_flags 3 \
+set ettv_autorecord 1 \
+set ettv_clientname $ETTV_CLIENT \
+set ettv_sv_maxslaves $HUB_SLAVES \
+set ettv_password $HUB_ETTV_PASS \
+set ettv_netblast $ETTV_NETBLAST \
+set ettv_tv_iptos $ETTV_TV_IPTOS \
+set ettv_sv_iptos $ETTV_SV_IPTOS \
+set ettv_mtu $ETTV_MTU \
+set ettv_delay $SHOUTCAST_DELAY \
+tv connect $MATCH_HOST $MATCH_ETTV_PASS $MATCH_PASS"
#
# Functions
#
hub_start () {
#
# FYI'ing the user
#
echo -n "Match Date is "
echo -n "$MATCH_DATE"
echo -e ".\nDemos are stored in $HOMEPATH/etpro/demos/.\n"
echo -n "Starting Hub: "
screen -dmS hub su -m -c "$DAEMON $HUB_OPTIONS" - $USER
sleep 1
echo -e "done.\n"
echo -e "Getting PID...\n"
get_pids
echo -n "Hub has PID "
echo -e "$HUB_PID\n"
echo "ETTV slaves can now connect to your box by issuing:"
echo -e "tv connect $THISHOST_IP:$HUB_PORT $HUB_ETTV_PASS $HUB_PASS\n"
}
hub_stop () {
#
# Refresh the PIDs
#
get_pids
echo -n "Shutting Down Hub: "
sleep 1
if [ $HUB_PID ]
then
kill -3 $HUB_PID
echo -e "done."
else
echo -e "failed.\nHub wasn't active anymore.\n"
fi
sleep 1
}
get_pids (){
#
# We used to launch the same binary twice so pidof didn't work.
# As from beta 8 ettv delayed feeds were automatic so
# no more fancy scripting tricks are required :-)
#
HUB_PID=`pidof $DAEMON`
}
clean_up (){
#
# Clean up prompt
#
echo -n "Clean up demos directory [y/n]? "
read ANSWER
case "$ANSWER" in
y)
rm -Rf $BASEPATH/$MATCH_DATE
ls -l --color=always $BASEPATH
;;
*)
echo "Following demos still exist:"
ls -l --color=always $BASEPATH/$MATCH_DATE/etpro/demos/
;;
esac
}
#
# Performing The magic :-)
#
case "$1" in
start)
hub_start
;;
stop)
hub_stop
clean_up
;;
*)
SCRIPT_NAME=`basename $0`
echo "Usage: $SCRIPT_NAME {start|stop}"
exit 1
;;
esac
exit 0
Slave script
This script connects an undelayed slave to a hub (that hopefully delays the signal ;-)). The usage of this script is very similar to the Hub script. Copy / paste it and save it as slave.sh or any other name you prefer. THen issue ./slave.sh start to start your slave and ./slave.sh stop to stop it. Like above, it is actually better to do quit in the console instead of just killing the slave with this script.
#!/bin/bash
#################################################################
# #
# reT!reD.ettv slave script #
# - #
# reT!reD.deej #
# #
#################################################################
# #
# This script can be used to start up an ETTV slave to connect #
# to a HUB provided by another server. #
# #
# This script launches the daemon in a different screen which #
# you can reattach with "screen -r slave" #
# #
# Credits: #
# - Daita (pourix.net) for the original idea & script #
# - Tony J. White (et.tjw.org) for his ETDED on Linux guide #
# - aNgel (fragland.org) for debugging Beavis' mistakes ;-) #
# #
# Questions? Contact me on deej@fragland.org or go to #r0f.et #
# #
#################################################################
# #
# http://www.fragland.org #
# #
#################################################################
# Webperoni Game Server IP
# ettv.fragland.org
PERONI_IP="83.133.81.192"
# Deinprovider WebServer IP
# ettv2.fragland.org
FRAGLAND_IP="217.20.115.116"
# Ionmedia Game Server IP
# ettv3.fragland.org
IONMEDIA_IP="62.216.174.68"
# Hetzner Game Server IP
# WServer2.ath.cx IP
# ettv4.fragland.org
HETZNER_IP="213.239.207.195"
# Planet Hosting Game Server IP
# ettv5.fragland.org
PLANET_IP="85.190.1.13"
#################################################################
# #
# Start Modifying From Here #
# #
#################################################################
#
# Hub Info
#
# IMPORTANT: Let the admin of the hub do a
# fdir *.pk3 in his console and give you the output!
#
# PK3 mismatches between game server and ETTV hosts
# account for the majority of crashes of ETTV.
#
HUB_IP=$PERONI_IP # Hub runs on Webperoni
HUB_PORT="50000"
HUB_ETTV_PASS="[get_pass_from_hub_admin]"
HUB_PASS="[get_pass_from_hub_admin]"
HUB_HOST="$HUB_IP:$HUB_PORT"
#
# Slave Info
#
SLAVE_IP=$FRAGLAND_IP # select from list above
SLAVE_PORT="27960" # port of the public broadcaster
SLAVE_HOSTNAME="^7reT^1!^7reD^1.^7ettv ^1#^72"
ETTV_CLIENT=$SLAVE_HOSTNAME # Shows up on Hub
SLAVE_SLOTS="100"
SLAVE_PASS="[put_your_pass_here]"
SLAVE_PRIVATE_SLOTS="10"
SLAVE_PRIVATE_PASS="[put_your_pass_here]"
SLAVE_ETTV_SLAVES="0"
SLAVE_ETTV_PASS="[put_your_pass_here]"
RCON_PASS="[put_your_pass_here]"
ALLOW_DL="1"
ALLOW_WWW_DL="1" # Allow downloading over http?
WWW_DL_URL="http://www.yoursite.com" # No "/" at the end!
RECORD_GAME="0" # 1 = record the game, 0 = don't
#
# Directories
#
BASEPATH="/srv/et/ETTV/ettv_slave" # Path to ettv.x86. Use absolute paths here!
#
# User To Launch Daemon
#
# Good practice:
# What doesn't need root priviliges doesn't get them!
#
# User gamed mentioned here under is not a standard linux user,
# he was created on our systems by us.
#
# gamed cannot log in. His homedir is equal to the path where
# all our servers are installed.
#
USER="gamed"
#################################################################
# #
# STOP Modifying Here #
# #
#################################################################
#
# Assembling the Command Line
#
BINARY="ettv.x86"
DAEMON="$BASEPATH/$BINARY"
HOMEPATH="$BASEPATH"
SLAVE_OPTIONS="\
+set fs_game etpro \
+set dedicated 2 \
+set net_ip $SLAVE_IP \
+set net_port $SLAVE_PORT \
+set fs_basepath $BASEPATH \
+set fs_homepath $HOMEPATH \
+set com_hunkMegs 128 \
+set sv_maxclients $SLAVE_SLOTS \
+set sv_privateclients $SLAVE_PRIVATE_SLOTS \
+set sv_privatepassword $SLAVE_PRIVATE_PASS \
+set sv_hostname $SLAVE_HOSTNAME \
+set ettv_delay 0 \
+set ettv_autorecord $RECORD_GAME \
+set ettv_clientname $ETTV_CLIENT \
+set g_password $SLAVE_PASS \
+set rconpassword $RCON_PASS \
+set sv_maxRate 18000 \
+set sv_allowDownload $ALLOW_DL \
+set sv_wwwDownload $ALLOW_WWW_DL \
+set sv_wwwBaseURL "$WWW_DL_URL" \
+set sv_wwwDlDisconnected 0 \
+set g_log "slave.log" \
+set logfile 2 \
+tv connect $HUB_HOST $HUB_ETTV_PASS $HUB_PASS"
#
# Functions
#
slave_start (){
#
# FYI'ing the user
#
echo -n "Starting Slave: "
screen -dmS slave su -m -c "$DAEMON $SLAVE_OPTIONS" - $USER
echo -e "done.\n"
echo -e "Getting PID...\n"
sleep 1
SLAVE_PID=`pidof $DAEMON`
echo -n "Slave has PID "
echo -e "$SLAVE_PID.\n"
}
slave_stop (){
#
# Refresh the PID
#
SLAVE_PID=`pidof $DAEMON`
echo -n "Shutting Down Slave: "
sleep 1
if [ $SLAVE_PID ]
then
kill -3 $SLAVE_PID
echo -e "done."
else
echo -e "failed.\nSlave wasn't active anymore.\n"
fi
}
#
# Performing The magic :-)
#
case "$1" in
start)
slave_start
;;
stop)
slave_stop
;;
restart)
slave_stop
sleep 1
slave_start
;;
*)
SCRIPT_NAME=`basename $0`
echo "Usage: $SCRIPT_NAME {start|stop|restart}"
exit 1
;;
esac
exit 0
Old school record / playback script
This is a script to broadcast a game the old-fashioned way. It records a demo and starts playing it back after roughly 60 seconds. There's some symbolic linking stuff done inside to make sure it stores all the logs, otherwise the 'broadcaster' would override the recorder's log, which makes broadcasting very hard to debug :-)!
Copy / paste this script and save it as broadcast.sh or any other name you prefer. The usual comments on quit and 999 are applicable here as well. This script "should" work with ETTV earlier then b8. However, YMMV.
#!/bin/bash
#################################################################
# #
# reT!reD.ettv delayed broadcast script #
# - #
# reT!reD.deej #
# #
#################################################################
# #
# This script can be used to start up a delayed ETTV stream #
# where viewers connect directly to the broadcaster. #
# #
# This script creates a subdirectory which represents the #
# date of the match and stores the demos in this subdir. #
# #
# The script launches the daemons in different screens #
# which you can reattach with "screen -r recorder" #
# or "screen -r broadcaster". #
# #
# Credits: #
# - Daita (pourix.net) for the original idea & script #
# - Tony J. White (et.tjw.org) for his ETDED on Linux guide #
# - aNgel (fragland.org) for debugging Beavis' mistakes ;-) #
# #
# Questions? Contact me on deej@fragland.org or go to #r0f.et #
# #
#################################################################
# #
# http://www.fragland.org #
# #
#################################################################
# Webperoni Game Server IP
# ettv.fragland.org
PERONI_IP="83.133.81.192"
# Deinprovider WebServer IP
# ettv2.fragland.org
FRAGLAND_IP="217.20.115.116"
# Ionmedia Game Server IP
# ettv3.fragland.org
IONMEDIA_IP="62.216.174.68"
# Hetzner Game Server IP
# WServer2.ath.cx IP
# ettv4.fragland.org
HETZNER_IP="213.239.207.195"
# Planet Hosting Game Server IP
# ettv5.fragland.org
PLANET_IP="85.190.1.13"
#################################################################
# #
# START Modifying #
# #
#################################################################
#
# Parameters of the Game Server to Connect to
#
# IMPORTANT: Let the admin of the game server do
# "fdir *.pk3" in his console and give you the output!
#
# PK3 mismatches between game server and ETTV hosts
# account for the majority of crashes of ETTV.
#
MATCH_DATE=`date +%Y%m%d` # Today's date for creating the subdir
MATCH_HOST="et.fragland.org:27965" # Match server port & address
MATCH_ETTV_PASS="[get_pass_from_admin]" # Match server ETTV password
MATCH_PASS="[get_pass_from_admin]" # Match server password
#
# IPs & Ports For Your Host
#
THISHOST_IP=$PERONI_IP # This host is Webperoni
RECORDER_PORT="44999" # Port of the private recorder
BROADCASTER_PORT="27960" # Port of the public broadcaster
#
# Hostnames & ETTV Client name
#
# - hostname shows up in server browsers
# - ETTV client name shows up as the name
# of your server in the game server.
#
RECORDER_HOSTNAME="^7reT^1!^7reD^1.^7ettv ^7recorder ^1#^71"
BROADCASTER_HOSTNAME="^7reT^1!^7reD^1.^7ettv ^1#^71"
ETTV_CLIENT=$BROADCASTER_HOSTNAME
#
# Passwords
#
RCON_PASS="[put_your_pass_here]"
RECORDER_PASS="[put_your_pass_here]"
BROADCASTER_PRIVATE_PASS="[put_your_pass_here]"
BROADCASTER_ETTV_PASS="[put_your_pass_here]"
BROADCASTER_PASS="[put_your_pass_here]" # Issue /rcon g_password "" for opening it up to the crowd
#
# Directories
#
BASEPATH="/srv/et/ETTV/ettv_brc" # Path to ettv.x86. Use absolute paths here!
#
# ETTV Net settings for ETTV b8 & up
#
ETTV_NETBLAST="1"
ETTV_TV_IPTOS="0"
ETTV_SV_IPTOS="0"
ETTV_MTU="1400"
#
# Other relevant settings
#
SHOUTCAST_DELAY="60" # Delay between live match & broadcasting hub in seconds
BROADCASTER_SLOTS="100"
BROADCASTER_PRIVATE_SLOTS="10"
BROADCASTER_ETTV_SLAVES="0"
ALLOW_DL="1"
ALLOW_WWW_DL="1" # Allow downloading over http?
WWW_DL_URL="http://www.yoursite.org" # No "/" at the end!
#
# User To Launch Daemon
#
# Good practice:
# What doesn't need root priviliges doesn't get them!
#
# User gamed mentioned here under is not a standard linux user,
# he was created on our systems by us.
#
# gamed cannot log in. His homedir is equal to the path
# where all our servers are installed.
#
USER="gamed"
#################################################################
# #
# STOP Modifying #
# #
#################################################################
#
# Assembling the Command Line
#
RECORDER_HOMEPATH="$BASEPATH/$MATCH_DATE/recorder"
BROADCASTER_HOMEPATH="$BASEPATH/$MATCH_DATE/broadcaster"
BINARY="ettv.x86"
DAEMON="$BASEPATH/$BINARY"
RECORDER_OPTIONS="\
+set fs_game etpro \
+set dedicated 1 \
+map oasis \
+set net_ip $THISHOST_IP \
+set net_port $RECORDER_PORT \
+set fs_basepath $BASEPATH \
+set fs_homepath $RECORDER_HOMEPATH \
+set com_hunkMegs 128 \
+set g_password $RECORDER_PASS \
+set rconpassword $RCON_PASS \
+set sv_hostname $RECORDER_HOSTNAME \
+set sv_maxclients 4 \
+set sv_maxRate 25000 \
+set sv_allowDownload 0 \
+set sv_wwwDownload 0 \
+set sv_wwwBaseURL "$WWW_DL_URL" \
+set sv_wwwDlDisconnected 0 \
+set g_log "recorder.log" \
+set logfile 2 \
+set b_ettv_flags 3 \
+set ettv_sv_maxslaves 2 \
+set ettv_clientname $ETTV_CLIENT \
+set ettv_password $BROADCASTER_ETTV_PASS \
+set ettv_netblast $ETTV_NETBLAST \
+set ettv_tv_iptos $ETTV_TV_IPTOS \
+set ettv_sv_iptos $ETTV_SV_IPTOS \
+set ettv_mtu $ETTV_MTU \
+set ettv_autorecord 1 \
+set ettv_delay 1 \
+tv connect $MATCH_HOST $MATCH_ETTV_PASS $MATCH_PASS"
BROADCASTER_OPTIONS="\
+set fs_game etpro \
+set dedicated 2 \
+set net_ip $THISHOST_IP \
+set net_port $BROADCASTER_PORT \
+set fs_basepath $BASEPATH \
+set fs_homepath $BROADCASTER_HOMEPATH \
+set com_hunkMegs 160 \
+set sv_maxclients $BROADCASTER_SLOTS \
+set sv_privateclients $BROADCASTER_PRIVATE_SLOTS \
+set sv_privatepassword $BROADCASTER_PRIVATE_PASS \
+set sv_hostname $BROADCASTER_HOSTNAME \
+set g_password $BROADCASTER_PASS \
+set rconpassword $RCON_PASS \
+set sv_maxRate 18000 \
+set sv_allowDownload $ALLOW_DL \
+set sv_wwwDownload $ALLOW_WWW_DL \
+set sv_wwwBaseURL "$WWW_DL_URL" \
+set sv_wwwDlDisconnected 0 \
+set g_log "broadcaster.log" \
+set logfile 2 \
+set ettv_autoplay 1 \
+set ettv_password $BROADCASTER_ETTV_PASS \
+set b_ettv_flags 3 \
+set ettv_sv_maxslaves $BROADCASTER_ETTV_SLAVES \
+demo demo0000"
#
# Functions
#
broadcast_start (){
#
# FYI'ing the user
#
echo -e "\n"
echo -n "Match Date is "
echo -n "$MATCH_DATE"
echo -e ".\nDemos are stored in $RECORDER_HOMEPATH/etpro/demos/.\n"
echo -n "Starting Recorder: "
screen -dmS recorder su -m -c "$DAEMON $RECORDER_OPTIONS" - $USER
echo "done."
get_pids
echo -n "Recorder has PID "
echo -n $RECORDER_PID
echo -e ".\n\nSleeping for $SHOUTCAST_DELAY seconds."
sleep $SHOUTCAST_DELAY
mkdir "$BROADCASTER_HOMEPATH"
mkdir "$BROADCASTER_HOMEPATH/etpro"
ln -s "$RECORDER_HOMEPATH/etpro/demos" "$BROADCASTER_HOMEPATH/etpro"
chown -R $USER "$BROADCASTER_HOMEPATH"
chmod -R 775 "$BROADCASTER_HOMEPATH"
echo -n "Starting Broadcaster: "
screen -dmS broadcaster su -m -c "$DAEMON $BROADCASTER_OPTIONS" - $USER
echo -e "done.\n"
echo -e "Getting PIDs...\n"
sleep 1
get_pids
echo -n "Recorder has PID "
echo -n $RECORDER_PID
echo -e ".\n\nBroadcaster has PID "
echo -e "$BROADCASTER_PID.\n"
}
broadcast_stop (){
get_pids
echo -n "Shutting Down Broadcaster: "
sleep 1
if [ $BROADCASTER_PID ]
then
kill -3 $BROADCASTER_PID
echo -e "done."
else
echo -e "failed.\nBroadcaster wasn't active anymore.\n"
fi
echo -n "Shutting Down Recorder: "
sleep 1
if [ $RECORDER_PID ]
then
kill -3 $RECORDER_PID
echo -e "done."
else
echo -e "failed.\nRecorder wasn't active anymore.\n"
fi
sleep 1
clean_up
}
clean_up (){
#
# Clean up prompt
#
echo -n "Clean up demos directory [y/n]? "
read ANSWER
case "$ANSWER" in
y)
rm -Rf $BASEPATH/$MATCH_DATE
ls -l --color=always $BASEPATH
;;
*)
echo "Following demos still exist:"
ls -l --color=always $BASEPATH/$MATCH_DATE/etpro/demos/
;;
esac
}
get_pids (){
#
# Pulling some very ugly tricks here
#
RECORDER_PID=`ps aux|grep "+set net_port $RECORDER_PORT"|grep -v "su -m -c"|grep -v "SCREEN -dmS"\|awk '{ print $1 $2 }'|tr -d "$USER"`
BROADCASTER_PID=`ps aux|grep "+set net_port $BROADCASTER_PORT"|grep -v "su -m -c"|grep -v "SCREEN -dmS"|awk '{ print $1 $2 }'|tr -d "$USER"`
}
#
# Performing The magic :-)
#
case "$1" in
start)
broadcast_start
;;
stop)
broadcast_stop
;;
*)
SCRIPT_NAME=`basename $0`
echo "Usage: $SCRIPT_NAME {start|stop}"
exit 1
;;
esac
exit 0
Sanitization script
This is a script to restore an ETTV directory to the bare minimum required to broadcast matches or be a hub. It isn't a very advanced script but it gets the job done. Copy / paste this script and save it as sanitize.sh or any other name you prefer. Just do ./sanitize.sh do delete all files in etmain & etpro that are not needed anymore.
Note: this script deletes everything it finds in the etmain and etpro directories. If you have stuff that you do not want to delete in there, add it to the ETMAIN_FILES & ETPRO_FILES arrays.
#!/bin/bash
#################################################################
# #
# reT!reD.ettv clean-up script #
# - #
# reT!reD.deej #
# #
#################################################################
# #
# This script is used to restore an ETTV directory to the bare #
# minimum in terms of files. #
# #
# Use it to clean up after an ETTV session so you can start the #
# next session with a minimum of PK3s. #
# #
# Questions? Contact me on deej@fragland.org or go to #r0f.et #
# #
#################################################################
# #
# http://www.fragland.org #
# #
#################################################################
ETMAIN_FILES=("description.txt" "hunkusage.dat" "mp_bin.pk3" "pak0.pk3" "pak1.pk3" "pak2.pk3" "qagame.mp.i386.so")
ETPRO_FILES=("etpro-3_2_0.pk3" "etpro_cheats.dat" "qagame.mp.i386.so" "tvgame.mp.i386.so" "animations" "configs" "maps" "etpromapscripts")
BASEPATH="/srv/et/ETTV/ettv_hub"
#
# Test for existence of backup directories
#
if [ ! -d "$BASEPATH/etmain/bak/" ]; then
mkdir "$BASEPATH/etmain/bak"
fi
if [ ! -d "$BASEPATH/etpro/bak/" ]; then
mkdir "$BASEPATH/etpro/bak"
fi
#
# Clear etmain
#
for i in ${ETMAIN_FILES[@]}
do
mv "$BASEPATH/etmain/$i" "$BASEPATH/etmain/bak/"
done
rm $BASEPATH/etmain/*
#
# Clear etpro
#
for i in ${ETPRO_FILES[@]}
do
mv "$BASEPATH/etpro/$i" "$BASEPATH/etpro/bak/"
done
rm $BASEPATH/etpro/*
#
# Restore etmain
#
for i in ${ETMAIN_FILES[@]}
do
mv "$BASEPATH/etmain/bak/$i" "$BASEPATH/etmain/"
done
#
# Restore etpro
#
for i in ${ETPRO_FILES[@]}
do
mv "$BASEPATH/etpro/bak/$i" "$BASEPATH/etpro/"
done
#
# Clean the backup directories
#
rm -Rf $BASEPATH/etmain/bak
rm -Rf $BASEPATH/etpro/bak
Have fun broadcasting!
deej 01:18, 10 November 2005 (PST)