gsd-cli 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a97a17b4db6722b3f8ff9a5424414eaaf53ebcdd7f62279d3aab28a7f4764ec6
4
- data.tar.gz: e95f7fc14f61d47845ff9ae0328c79f2320fc8064c7fff5b5856cdcd8e9aa47e
3
+ metadata.gz: 180005bcfea09309b5ef539282bb63634e3e8e5f51f4097ab897106732f71683
4
+ data.tar.gz: c1488aab97f08b0474f720af85f1ee613e8df1bc64fc9094e6f777423451f0bc
5
5
  SHA512:
6
- metadata.gz: b2313a302848d705ee15bdab95c3a91a1a10aa5e16d22d2b1de0795c8ee4b633290b7b59b9e1eff1e3d73b05717c7b52c8508a6065fa3c60abb456c2661fec2a
7
- data.tar.gz: ed9a1fe9dbd30fc46f91c3b3e1009259b43b9064be35dc6cddbe6e28ed1c730c6faa1646e308a6f3e201b04074b5b9c271a316258197759c4fb3376c16704b0b
6
+ metadata.gz: beb67e9455bc06afaeaf3dbcf668045b5de61ef31a6fc20537826c308bad7ade4ac4dfca1a08ddb000d788e616271ba890dec3a68546604178ecd2acc0876b42
7
+ data.tar.gz: 2b042fb9335aed22bb71abc7aa4f65fa5e988ebace7bf34d166fa09b3215e840902f88cb04fafdbb2c976cda3fe6beda3bab231aa4276e756f18a8da60578ee4
data/lib/cli.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "yaml"
2
4
  require "colorize"
3
5
  require "commander/import"
@@ -29,7 +31,7 @@ end
29
31
  @games = userdata
30
32
 
31
33
  program :name, "gsd-cli"
32
- program :version, "0.1.13"
34
+ program :version, "0.1.14"
33
35
  program :description, "A cli tool to deploy & manage dedicated game servers on Linux"
34
36
 
35
37
  command :install do |c|
@@ -79,8 +81,9 @@ command :restart do |c|
79
81
  c.syntax = "gsd restart [args]"
80
82
  c.summary = "Restart a installed dedicated game server."
81
83
  c.description = "Restarts a dedicated game server daemon that has already been installed to the system."
82
- c.action do |args|
83
- GameTemplate.new(@games[args.first()]).restart()
84
+ c.option "--remote OPTIONAL", String, "Connection string to a remote host server."
85
+ c.action do |args, options|
86
+ GameTemplate.new(@games[args.first()], options.remote).restart()
84
87
  end
85
88
  end
86
89
 
@@ -138,7 +141,7 @@ command :uninstall do |c|
138
141
  c.summary = "Uninstall a dedicated game server."
139
142
  c.description = "Uninstalls and removes all files associated with a dedicated game server."
140
143
  c.option "--name STRING", String, "Name of the dedicated game server."
141
- c.action do |args, options|
144
+ c.action do |_args, _options|
142
145
  puts "Not Implemented"
143
146
  end
144
147
  end
data/lib/game_template.rb CHANGED
@@ -1,11 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "colorize"
4
+ require "helpers"
2
5
 
3
6
  # Create a Rust server
4
7
  class GameTemplate
5
- def initialize(game, path = nil)
8
+ def initialize(game, remote, path = nil)
6
9
  @game = game
7
10
  @install_path = get_install_path(path)
8
11
  @file_path = "/tmp/#{@game.name}.service"
12
+ @remote = remote
9
13
  end
10
14
 
11
15
  def start
@@ -13,7 +17,14 @@ class GameTemplate
13
17
  end
14
18
 
15
19
  def restart
16
- system("sudo -p 'sudo password: ' systemctl restart #{@game.name}")
20
+ command = "systemctl restart #{@game.name}"
21
+ if @remote.nil?
22
+ system("sudo -p 'sudo password: ' #{command}")
23
+ else
24
+ puts @remote
25
+ puts command
26
+ Helpers.remote_cmd(@remote, command)
27
+ end
17
28
  end
18
29
 
19
30
  def status
@@ -80,7 +91,7 @@ class GameTemplate
80
91
 
81
92
  def get_install_path(path)
82
93
  install_path = if path.nil?
83
- # puts "Install path not defined: installing to /tmp/#{@game.name}".yellow
94
+ # puts "Install path not defined: installing to /tmp/#{@game.name}".yellow
84
95
  "/tmp/#{@game.name}"
85
96
  else
86
97
  path
@@ -107,7 +118,6 @@ class GameTemplate
107
118
  WantedBy=default.target
108
119
  [Service]
109
120
  LimitNPROC=infinity
110
- WorkingDirectory=#{@install_path}
111
121
  Type=simple
112
122
  User=#{`whoami`}
113
123
  ExecStart=#{binary_path} run #{@game.name} --path #{@install_path}"
data/lib/helpers.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Helpers
4
+ def self.remote_cmd(connection, command)
5
+ system("ssh #{connection} '#{command}'")
6
+ end
7
+ 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.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Egee
@@ -29,6 +29,7 @@ files:
29
29
  - lib/game_servers/team_fortress.rb
30
30
  - lib/game_servers/terraria.rb
31
31
  - lib/game_template.rb
32
+ - lib/helpers.rb
32
33
  homepage: https://github.com/Egeeio/gsd-cli
33
34
  licenses:
34
35
  - MIT