diff --git a/install.sh b/install.sh index f8340f1..c78820b 100644 --- a/install.sh +++ b/install.sh @@ -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}')" diff --git a/src/scripts/config.sh b/src/bin/config.sh similarity index 100% rename from src/scripts/config.sh rename to src/bin/config.sh diff --git a/src/scripts/sim/setup.sh b/src/bin/sim/setup.sh similarity index 100% rename from src/scripts/sim/setup.sh rename to src/bin/sim/setup.sh diff --git a/src/scripts/sim/steamtricks_install_manager.sh b/src/bin/sim/steamtricks_install_manager.sh similarity index 100% rename from src/scripts/sim/steamtricks_install_manager.sh rename to src/bin/sim/steamtricks_install_manager.sh diff --git a/src/bin/steamtricks.pl b/src/bin/steamtricks.pl new file mode 100644 index 0000000..bb94eac --- /dev/null +++ b/src/bin/steamtricks.pl @@ -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 = ; + 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"; +} \ No newline at end of file diff --git a/src/scripts/steamtricks.pl b/src/scripts/steamtricks.pl deleted file mode 100644 index 5e20686..0000000 --- a/src/scripts/steamtricks.pl +++ /dev/null @@ -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); \ No newline at end of file diff --git a/webinstall.sh b/webinstall.sh index 4e530f9..f0ec754 100644 --- a/webinstall.sh +++ b/webinstall.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash install_steamtricks () { - curl | tar -xvC ~/.steamtricks + curl | tar -xvC ~/.steamtricks/ }