gsd-cli 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cli.rb +5 -3
  3. data/lib/game_template.rb +25 -29
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01dfcf1833492c3a45ab541a49ffa80c9fd685b17bb4db80747e67821eb9daee
4
- data.tar.gz: c21eb0061afcdc1ab8b1d4914bf5abfd04d4d9b8088dfc0d78ef301e459b63aa
3
+ metadata.gz: 0a1e9eea7cd1d07e679b5638e4ee39beafc325f875c62ac57a2d242f2f96e8b9
4
+ data.tar.gz: 9d75d55324afdfae4ff8fcec787565fe15f024b00fa873485ea287db746cdfcb
5
5
  SHA512:
6
- metadata.gz: 16ae278d4a5883d7fdadc2c8e344cbb509643b0917a02d5bbd4daae16cb0dd730ba31f3f359f51ee9a75470f23654c3b5d8684a37b278128df1cb6d1995e08b5
7
- data.tar.gz: eb160df6ef69b731a08787931370035b85569bb4075035e2be797df2587a426a300bb13b58dde11f6b49cc880352835a311e0431b05a1e563541b738aaa25241
6
+ metadata.gz: 2e34d638f8bb6064eeedf63d1c8b0c07b01593648e60e6c25ab034168f93b4ac3826ac2643e57b792ab10ed7e7b2f301472c76ae85d64d188a2b5c6cc5117a8a
7
+ data.tar.gz: 2f807aa2ab77e8105cb907b382162408739fb42f1ccf6d9300224ec01076b0df5151d74f93fa71c11972f7514861bb98191a4c4ab2d0887f38515401dda47f73
data/lib/cli.rb CHANGED
@@ -31,7 +31,7 @@ end
31
31
  @games = userdata
32
32
 
33
33
  program :name, "gsd-cli"
34
- program :version, "0.1.15"
34
+ program :version, "0.1.16"
35
35
  program :description, "A cli tool to deploy & manage dedicated game servers on Linux"
36
36
 
37
37
  command :install do |c|
@@ -43,9 +43,11 @@ command :install do |c|
43
43
  c.option "--steamuser OPTIONAL", String, "Steam user account required to install certain games."
44
44
  c.option "--steampassword OPTIONAL", String, "Steam account password for installing certain games."
45
45
  c.action do |args, options|
46
- GameTemplate.new(@games[args.first()], options.path)
47
- .install(options.steamuser, options.steampassword, options.devmode)
46
+ puts "Beginning installation process. This may take a while..."
47
+ GameTemplate.new(@games[args.first()])
48
+ .install(options.path, options.steamuser, options.steampassword, options.devmode)
48
49
  end
50
+ puts "Server installation & deployment complete!".green
49
51
  end
50
52
 
51
53
  command :run do |c|
data/lib/game_template.rb CHANGED
@@ -5,10 +5,8 @@ require "helpers"
5
5
 
6
6
  # Create a Rust server
7
7
  class GameTemplate
8
- def initialize(game, remote, path = nil)
8
+ def initialize(game, remote = "")
9
9
  @game = game
10
- @install_path = get_install_path(path)
11
- @file_path = "/tmp/#{@game.name}.service"
12
10
  @remote = remote
13
11
  end
14
12
 
@@ -44,26 +42,23 @@ class GameTemplate
44
42
  end
45
43
 
46
44
  def run
47
- exec(@game.launch(@install_path))
45
+ exec(@game.launch(install_path))
48
46
  end
49
47
 
50
- def install(steamuser, steampassword, dev_mode)
51
- puts "Beginning installation process. This may take a while..."
52
- ensure_delete_unit_file()
48
+ def install(install_path, steamuser, steampassword, dev_mode)
49
+ ensure_delete_unit_file(install_path)
53
50
  if @game.app_id.nil?
54
- @game.install_server(@install_path)
51
+ @game.install_server(get_install_path(install_path))
55
52
  else
56
- install_steam_server(steamuser, steampassword)
53
+ install_steam_server(install_path, steamuser, steampassword)
57
54
  end
58
- binary_path = if dev_mode.nil?
59
- `which gsd-cli`.strip()
60
- else
61
- puts "Dev mode enabled - running from source"
62
- "#{Dir.pwd}/bin/gsd-cli"
63
- end
64
- create_unit_file(binary_path)
65
- system("sudo -p 'sudo password: ' cp -f #{@file_path} /etc/systemd/system/#{@game.name}.service")
66
- puts "Server installation & deployment complete!".green
55
+ cli_path = if dev_mode.nil?
56
+ `which gsd-cli`.strip()
57
+ else
58
+ puts "Dev mode enabled - running from source"
59
+ "#{Dir.pwd}/bin/gsd-cli"
60
+ end
61
+ create_unit_file(cli_path, install_path)
67
62
  end
68
63
 
69
64
  def update
@@ -77,7 +72,7 @@ class GameTemplate
77
72
  private
78
73
 
79
74
  # Installs or Updates a dedicated game server via Steamcmd
80
- def install_steam_server(steamuser = nil, steampassword = nil)
75
+ def install_steam_server(install_path, steamuser = nil, steampassword = nil)
81
76
  login = if steamuser.nil?
82
77
  "+login anonymous"
83
78
  else
@@ -85,8 +80,8 @@ class GameTemplate
85
80
  end
86
81
  abort("STEAMCMD does not appear to be installed! Aborting...".red) if `which steamcmd`.empty?
87
82
  system("$(which steamcmd) +login anonymous +quit")
88
- system("$(which steamcmd) #{login} +force_install_dir #{@install_path} +app_update #{@game.app_id} validate +quit")
89
- @game.post_install(@install_path) if defined? @game.post_install
83
+ system("$(which steamcmd) #{login} +force_install_dir #{install_path} +app_update #{@game.app_id} validate +quit")
84
+ @game.post_install(install_path) if defined? @game.post_install
90
85
  end
91
86
 
92
87
  def get_install_path(path)
@@ -99,18 +94,19 @@ class GameTemplate
99
94
  install_path
100
95
  end
101
96
 
102
- def ensure_delete_unit_file
103
- File.delete(@file_path) if File.file?(@file_path)
97
+ def ensure_delete_unit_file(unit_file_path)
98
+ File.delete(unit_file_path) if File.file?(unit_file_path)
104
99
  end
105
100
 
106
- def create_unit_file(binary_path)
107
- out_file = File.new(@file_path, "w")
108
- out_file.puts(unit_file_contents(binary_path)) # TODO: Pass in map with config
101
+ def create_unit_file(cli_path, install_path)
102
+ file_path = "/tmp/#{@game.name}.service"
103
+ out_file = File.new(file_path, "w")
104
+ out_file.puts(unit_file_contents(cli_path, install_path)) # TODO: Pass in map with config
109
105
  out_file.close()
106
+ system("sudo -p 'sudo password: ' mv -f #{"/tmp/#{@game.name}.service"} /etc/systemd/system/#{@game.name}.service")
110
107
  end
111
108
 
112
- def unit_file_contents(binary_path)
113
- puts binary_path
109
+ def unit_file_contents(cli_path, install_path)
114
110
  "[Unit]
115
111
  After=network.target
116
112
  Description=#{@desc}
@@ -120,6 +116,6 @@ class GameTemplate
120
116
  LimitNPROC=infinity
121
117
  Type=simple
122
118
  User=#{`whoami`}
123
- ExecStart=#{binary_path} run #{@game.name} --path #{@install_path}"
119
+ ExecStart=#{cli_path} run #{@game.name} --path #{install_path}"
124
120
  end
125
121
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gsd-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Egee