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.
- checksums.yaml +4 -4
- data/lib/cli.rb +5 -3
- data/lib/game_template.rb +25 -29
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a1e9eea7cd1d07e679b5638e4ee39beafc325f875c62ac57a2d242f2f96e8b9
|
4
|
+
data.tar.gz: 9d75d55324afdfae4ff8fcec787565fe15f024b00fa873485ea287db746cdfcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
|
47
|
-
|
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
|
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(
|
45
|
+
exec(@game.launch(install_path))
|
48
46
|
end
|
49
47
|
|
50
|
-
def install(steamuser, steampassword, dev_mode)
|
51
|
-
|
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(
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
create_unit_file(
|
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 #{
|
89
|
-
@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(
|
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(
|
107
|
-
|
108
|
-
out_file.
|
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(
|
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=#{
|
119
|
+
ExecStart=#{cli_path} run #{@game.name} --path #{install_path}"
|
124
120
|
end
|
125
121
|
end
|