Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
# LANParty toolset
# Written by @Pips801, tweaked by @_bashNinja
#
#
#container names
STEAMCACHE="Steam"
ORIGINCACHE="Origin"
BLIZZARDCACHE="Blizzard"
GENERICCACHE="Generic"
#IP
STEAMCACHE_IP="10.0.0.2"
BLIZZARDCACHE_IP="10.0.0.5"
ORIGINCACHE_IP="10.0.0.4"
GENERICCACHE_IP="10.0.0.3"
if [[ $1 == "cache" ]]
then
if [[ $2 == "size" ]] # saltlan cache size
then
if [[ -n "$3" ]] #saltlan cache size <target> (if isset <target>)
then
docker exec $3 du -sh /data/cache | sed "s/\/data\/cache//"
else #no target
echo "[Error] No cache selected."
echo "Cache options: Steam, Blizzard, Origin, Generic"
exit 1
fi
elif [[ $2 == "list" ]] # saltlan cache list
then
docker exec Steam ls -1 /data/cache/depot/
elif [[ $2 == "delete" ]] # saltlan cache delete
then
if [[ -n "$3" ]] # saltlan cache <appid>
then
docker exec Steam rm -r /data/cache/depot/$3/
echo "Deleted $3"
else # no target
echo "[Error] appid not set."
exit 1
fi
elif [[ $2 == "lookup" ]]
then
if [[ -n "$3" ]]
then
curl -Ls https://steamdb.info/depot/$3 | grep "\<h1" | sed 's/.*header-title\">//;s/<\/h1.*//' | sed 's/<[^>]*>//g' | sed 's/Depot » //g'
else
echo "[Error] appid not set."
exit 1
fi
elif [[ $2 == "restart" ]]
then
if [[ -n "$3" ]]
then
docker restart $3 > /dev/null
echo "Restarted."
else
echo "[Error] No cache selected."
fi
fi
elif [[ $1 = "logs" ]]
then
if [[ -n "$2" ]]
then
echo "[Info] Press Ctrl-c to exit."
docker exec $2 tail -F /data/logs/access.log
else
echo "[Error] No cache selected."
echo "Cache options: steam, blizzard, origin, uplay"
fi
elif [[ $1 == "start" ]]
then
clear
figlet LANParty | lolcat -a -d 7
echo "Starting $STEAMCACHE..."
docker start $STEAMCACHE > /dev/null
echo "Starting $BLIZZARDCACHE..."
docker start $BLIZZARDCACHE > /dev/null
echo "Starting $ORIGINCACHE..."
docker start $ORIGINCACHE > /dev/null
echo "$starting $GENERICCACHE..."
docker start $GENERICCACHE > /dev/null
# echo "Starting Grafana..."
# service grafana-server restart
# tmux new -d -s grafana "grafana-server | lolcat -p 100 -F 0.005"
#
# echo "Starting InfluxDB..."
# service influxd stop
# tmux new -d -s influx "influxd | lolcat -p 100 -F 0.005"
#
# echo "Starting Telegraf..."
# service telegraf stop
# tmux new -d -s telegraf "telegraf | lolcat -p 100 -F 0.005"
echo "Done."
elif [[ $1 == "stop" ]]
then
clear
figlet LANParty | lolcat -a -d 7
echo "Stopping $STEAMCACHE..."
docker stop $STEAMCACHE
echo "Stopping $ORIGINCACHE..."
docker stop $ORIGINCACHE
echo "Stopping $BLIZZARDCACHE..."
docker stop $BLIZZARDCACHE
echo "Stopping $GENERICCACHE..."
docker stop $GENERICCACHE
# tmux kill-session -t telegraf
# tmux kill-session -t influx
# tmux kill-session -t grafana
elif [[ $1 == "help" ]]
then
figlet "LANParty"
echo "
LANParty toolset
Written by @Pips801, tweaked by @_bashNinja
Usage:
#~: ./lanparty
start
stop
cache
restart <cache>
size <cache>
list
delete <appid>
lookup <appid>
logs
<cache>"
else
echo "[Error] No option selected."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.