Progress on the install script

This commit is contained in:
wasabi
2025-05-29 17:52:59 -05:00
parent 457351034b
commit d7541cc843
7 changed files with 97 additions and 24 deletions

View File

@@ -1,10 +1,18 @@
#!/usr/bin/env bash
unsupported_shell () {
echo "Your shell $SHELL is not supported by this install script"
echo "You will need to manually install by extracting a tarball from"
echo "https://github.com/charwrangler404/steamtricks/releases to your home folder"
echo "and setting the STEAMTRICKS_PREFIX environment variable in your shell's profile"
}
install () {
mkdir ~/.steamtricks
cp src/* ~/.steamtricks
cp -r src/* ~/.steamtricks
export SHELLPROFILE="~/.${1}rc"
echo "export STEAMTRICKS_PREFIX=\"~/.steamtricks\"">>"${SHELLPROFILE}"
echo "source ~/.steamtricks/steamtricks.conf">>"${SHELLPROFILE}"
echo "export PATH=\"$PATH:$HOME/.steamtricks/bin\""
source "${SHELLPROFILE}"
edit_prefix
@@ -12,17 +20,14 @@ install () {
install_manager () {
case "$1" in
sh | fish) echo "Shell ${SHELL} not supported"; exit 1
;;
bash | zsh | yash) install
;;
*) echo "You will need to install this by manually adding it to either your /etc/profile for system-wide installation or to your shell's profile"
*) unsupported_shell
;;
esac
}
read -r -p "Would you like to install the multiple-install game manager? [y/N]" ANS
case "$ANS" in
[yY]* ) install_manager "$(echo $SHELL | awk -F "/" '{print $NF}')"

85
src/bin/steamtricks.pl Normal file
View File

@@ -0,0 +1,85 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
use Config::Tiny;
use File::Basename;
sub setup_config;
sub print_help;
sub main;
sub parse_config;
use constant {
VERSION = "v0.1.0"
}
my $steamtricks_prefix = $ENV{'STEAMTRICKS_PREFIX'};
my $change_install = '';
my $new_config = '';
my $game = '';
my $game_version = '';
my $new_steam_prefix = '~/.var/app/com.valvesoftware.Steam/data/Steam/steamapps/common';
my $help = '';
my $version = '';
my $config_location = "${steamtricks_prefix}/steamtricks.conf"
GetOptions ('steam-prefix=s' => \$steam_prefix,
'change-install' => \$change_install,
'setup-config' => \$new_config,
'steam-prefix=s' => \$new_steam_prefix,
'game-version=s' => \$game_version,
'help' => \$help,
'version' => \$print_version);
main;
sub main {
if ($help) {
print_help;
return 0;
} else if ($version) {
print basename($0), VERSION;
} else if ($new_config) {
setup_config($new_steam_prefix)
}
}
sub parse_config {
if (-s "$config_location" ) {
my $config = Config::Tiny->read( "$config_location" );
} else {
warn "config file ${config_location} not found. Creating new config with flatpak defaults\n";
setup_config;
}
}
sub setup_config {
print "Creating config with STEAM_PREFIX=${new_steam_prefix}\n"
if (-s "${config_location}") {
warn "$config_location already exists, do you wish to overwrite this file? [y/N]";
my $ans = <STDIN>;
chomp $ans;
switch($ans) {
case /[yY].?/ { my $config = Config::Tiny->new({ _ => { STEAM_PREFIX => "$new_steam_prefix" } }) }
else { die "Config not created. Exiting" }
}
} else {
my $config = Config::Tiny->new({ _ => { STEAM_PREFIX => "$new_steam_prefix" }});;
}
$config->write( ${config_location} ) or die "Config file $config_location could not be written: $!\n";
}
sub print_help {
print basename($0), "\n";
}

View File

@@ -1,17 +0,0 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
my $steam_prefix = $ENV{'STEAM_PREFIX'};
my $steamtricks_prefix = $ENV{'STEAMTRICKS_PREFIX'};
my $change_install = '';
my $game = '';
my $version = '';
my @games = split(/,/, $ENV{'SIM_MANAGED_GAMES'});
GetOptions ('steam-prefix=s' => \$steam_prefix,
'change-install' => \$change_install,
'version=s' => \$version);

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
install_steamtricks () {
curl | tar -xvC ~/.steamtricks
curl | tar -xvC ~/.steamtricks/
}