Moved SteamCMD init from install.sh to command

This commit is contained in:
ilumos 2017-08-28 02:26:34 +01:00
parent 9bfc565d01
commit de26d0eef2
5 changed files with 90 additions and 14 deletions

View file

@ -1,3 +1,3 @@
DOWNLOADS_DIRECTORY="/tmp/lancache-autofill"
STEAMCMD_PATH="/usr/games/steam/steamcmd.sh"
STEAMCMD_PATH="~/steam/steamcmd.sh"
DEFAULT_STEAM_USER="your-username-here"

View file

@ -19,30 +19,38 @@ Automatically fill a [lancache](https://github.com/zeropingheroes/lancache) with
* `sudo ./install.sh`
# Quick Start
1. Set the default Steam account to be used when queueing apps for download:
1. Install and initialise SteamCMD:
`./lancache-autofill steam:initialise`
2. Set the default Steam account to be used when queueing apps for download:
`nano .env`
2. Search for the apps you wish to download to find their app ID:
3. Search for the apps you wish to download to find their app ID:
`./lancache-autofill steam:search-apps "team fortress 2"`
`440 Team Fortress 2
[...]`
3. Queue the app for download by ID:
4. Queue the app for download by ID:
`./lancache-autofill steam:queue-app 440`
4. Start downloading items in the download queue:
5. Authorise your Steam account:
`./lancache-autofill steam:authorise-account`
6. Start downloading items in the download queue:
`./lancache-autofill steam:start-downloading`
5. View the download queue to see the status of the downloads:
7. View the download queue to see the status of the downloads:
`./lancache-autofill steam:show-queue`
6. Clear the temporary download location:
8. Clear the temporary download location:
`./lancache-autofill app:initialise-downloads-directory`
@ -55,6 +63,10 @@ Automatically fill a [lancache](https://github.com/zeropingheroes/lancache) with
* Initialise the downloads directory.
`steam:initialise`
* Install and initialise SteamCMD
`steam:authorise-account [account]`
* Authorise a Steam account to allow download of apps in their library.

View file

@ -17,9 +17,6 @@ apt install -y lib32gcc1 \
printf "${GREEN}Installing dependencies with Composer${BLACK}\n"
cd $SCRIPT_DIR && composer install
printf "${GREEN}Installing Steam${BLACK}\n"
mkdir -p /usr/games/steam && cd /usr/games/steam && curl -sqL "http://media.steampowered.com/client/steamcmd_linux.tar.gz" | tar zxvf -
printf "${GREEN}Creating database file${BLACK}\n"
cd $SCRIPT_DIR && touch "database.sqlite"

View file

@ -10,7 +10,7 @@ use Zeropingheroes\LancacheAutofill\Console\Commands\{
InitialiseDatabase, InitialiseDownloadsDirectory
};
use Zeropingheroes\LancacheAutofill\Console\Commands\Steam\{
AuthoriseAccount, Dequeue, QueueApp, Requeue, SearchApps, ShowQueue, StartDownloading, UpdateAppList
AuthoriseAccount, Dequeue, Initialise, QueueApp, Requeue, SearchApps, ShowQueue, StartDownloading, UpdateAppList
};
// Load Composer's autoloader
@ -26,9 +26,10 @@ $dotenv = new Dotenv(__DIR__);
$dotenv->load();
$dotenv->required(['DOWNLOADS_DIRECTORY', 'STEAMCMD_PATH', 'DEFAULT_STEAM_USER']);
if (!file_exists(getenv('STEAMCMD_PATH'))) {
die('SteamCMD not found - please check the STEAMCMD_PATH environment variable is set correctly');
}
// TODO: Move to class so existance of SteamCMD can be checked at the appropriate time
//if (!file_exists(getenv('STEAMCMD_PATH'))) {
// die('SteamCMD not found - please check the STEAMCMD_PATH environment variable is set correctly');
//}
// Set up the console app
$app = new Application(new Container, new Dispatcher, '5.4');
@ -52,6 +53,7 @@ $app->add(new ShowQueue);
$app->add(new Dequeue);
$app->add(new Requeue);
$app->add(new AuthoriseAccount);
$app->add(new Initialise);
$app->add(new StartDownloading);
// Run the console app

View file

@ -0,0 +1,65 @@
<?php
namespace Zeropingheroes\LancacheAutofill\Console\Commands\Steam;
use Illuminate\Console\Command;
use Symfony\Component\Process\Process;
class Initialise extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'steam:initialise';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Initialise Steam';
/**
* The URL to get the SteamCMD binary from.
*
* @var string
*/
const STEAMCMD_URL = 'http://media.steampowered.com/client/steamcmd_linux.tar.gz';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$steamCmdDirectory = dirname(getenv('STEAMCMD_PATH'));
if ($this->confirm('Are you sure you wish to initialise SteamCMD"? This will remove the directory "'.$steamCmdDirectory.'"')) {
$process['remove'] = new Process('rm -rf '.$steamCmdDirectory);
$process['create'] = new Process('mkdir -p '.$steamCmdDirectory.' && cd '.$steamCmdDirectory.' && curl -sqL "'.self::STEAMCMD_URL.'" | tar zxvf -');
$process['run'] = new Process('unbuffer '.getenv('STEAMCMD_PATH').' +login anonymous +quit');
foreach ($process as $process) {
$process->run(function ($type, $buffer) {
if (Process::ERR === $type) {
$this->error(str_replace(["\r", "\n"], '', $buffer));
}
else {
$this->line(str_replace(["\r", "\n"], '', $buffer));
}
});
if (!$process->isSuccessful()) {
$this->error('Error initialising SteamCMD');
die();
}
}
$this->info('Successfully initialised SteamCMD');
}
}
}