#!/bin/bash # cs2d download script by Livia version=0125 download_url="http://www.unrealsoftware.de/get.php?get" # bold output bold="\033[1m" reset="\e[0m" # from https://bbs.archlinux.org/viewtopic.php?id=141195 grabcid() { local file=cs2d_${version}_linux.zip echo "$(curl -Ss "${download_url}=${file}&p=1" | grep -o '"get.php[^"]\+"' | cut -d'"' -f2 | sed 's/.\+cid=//g')" } getfile() { local file=${1} local url=${2} echo -e "${bold}Downloading ${file}${reset}" curl -o ${file} ${url} echo -e "${bold}Extracting ${file}${reset}" unzip ${file} } install() { cid=$(grabcid) echo -e "${bold}Client id is ${cid}${reset}" win="cs2d_${version}_win.zip" linux="cs2d_${version}_linux.zip" dedicated="cs2d_dedicated_linux.zip" getfile "${win}" "${download_url}=${win}&p=1&cid=${cid}" getfile "${linux}" "${download_url}=${linux}&p=1&cid=${cid}" getfile "${dedicated}" "http://www.unrealsoftware.de/files_pub/${dedicated}" chmod +x cs2d_dedicated CounterStrike2D rm ${win} ${linux} ${dedicated} } install