gsd-cli 0.1.28 → 0.1.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cli/game_hash.rb +13 -0
- data/lib/cli/install.rb +34 -0
- data/lib/cli/run.rb +13 -0
- data/lib/cli/update.rb +15 -0
- data/lib/cli.rb +106 -106
- data/lib/game_template.rb +9 -32
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ea2d0d001459a63725032b51cc7450dfa1c8a4498a7effb78fc826000bc0305
|
4
|
+
data.tar.gz: 3bfe635ddea7aa2200501410a1dbc0c33224790e20b45103008a8159db037d94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b02f61fdfdf7583a3653aab65c7b15b34bd6a6957231ff02614614cb0e86ad1c19d7d9dea6f97efdcebe81d774ab239d434355a312e676a4a17fe83577b909b3
|
7
|
+
data.tar.gz: 3e966eccf8ee4bb729dfe2665141bdff347e411d319ece26467d0cc27e47c161494c325d1b1a4264e4c11bae59eee0f35abdcc52a59ef52322963fe873a851b3
|
@@ -0,0 +1,13 @@
|
|
1
|
+
def game_hash
|
2
|
+
{
|
3
|
+
"rust" => Rust.new,
|
4
|
+
"sdtd" => SevenDays.new,
|
5
|
+
"gmod" => GarrysMod.new,
|
6
|
+
"aos" => AceOfSpades.new,
|
7
|
+
"tf2" => TeamFortress.new,
|
8
|
+
"ftb" => MinecraftFtb.new,
|
9
|
+
"terraria" => Terraria.new,
|
10
|
+
"starbound" => Starbound.new,
|
11
|
+
"minecraft" => MinecraftSpigot.new
|
12
|
+
}
|
13
|
+
end
|
data/lib/cli/install.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "game_template"
|
4
|
+
require "user_data"
|
5
|
+
|
6
|
+
command :install do |c|
|
7
|
+
c.syntax = "gsd install [args] [options]"
|
8
|
+
c.summary = "Install and deploy a dedicated game server as a daemon."
|
9
|
+
c.description = "Installs and deploy a dedicated game server as a daemon (systemd unit)."
|
10
|
+
c.option "--path OPTIONAL", String, "Path that the game server will be installed to."
|
11
|
+
c.option "--steamuser OPTIONAL", String, "Steam user account required to install certain games."
|
12
|
+
c.option "--steampassword OPTIONAL", String, "Steam account password for installing certain games."
|
13
|
+
c.action do |args, options|
|
14
|
+
abort("Install what? Provide a game name argument!") if (args.first().nil?)
|
15
|
+
install(game_hash[args.first()], optons.path, options.steamuser, options.steampassword)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def install(game, path, steam_user, steam_password)
|
20
|
+
puts "Beginning installation process. This may take a while...".yellow
|
21
|
+
install_path = if path.nil?
|
22
|
+
puts "Install path was not provided: installing to /opt/#{game.name}".yellow
|
23
|
+
"/opt/#{game.name}"
|
24
|
+
else
|
25
|
+
path
|
26
|
+
end
|
27
|
+
steam_login = if user.nil?
|
28
|
+
"+login anonymous"
|
29
|
+
else
|
30
|
+
"+login #{steam_user} #{steam_password}"
|
31
|
+
end
|
32
|
+
GameTemplate.new(game).install(install_path, steam_login)
|
33
|
+
puts "Server installation & deployment complete!".green
|
34
|
+
end
|
data/lib/cli/run.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "game_template"
|
4
|
+
|
5
|
+
command :run do |c|
|
6
|
+
c.syntax = "gsd run [args]"
|
7
|
+
c.summary = "Run an installed dedicated game server as a new process."
|
8
|
+
c.description = "Runs an installed dedicated game server as a new process. This command is used by the daemon and is not designed to be run manually."
|
9
|
+
c.option "--path STRING", String, "Path that the game server will be installed to."
|
10
|
+
c.action do |args, options|
|
11
|
+
GameTemplate.new(game_hash[args.first()]).run(options.path)
|
12
|
+
end
|
13
|
+
end
|
data/lib/cli/update.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "game_template"
|
4
|
+
|
5
|
+
command :update do |c|
|
6
|
+
c.syntax = "gsd update [args] [options]"
|
7
|
+
c.summary = "Updates an installed dedicated game server."
|
8
|
+
c.description = "Updates an installed dedicated game server."
|
9
|
+
c.option "--path OPTIONAL", String, "Path that the game server will be installed to."
|
10
|
+
c.option "--steamuser OPTIONAL", String, "Steam user account required to install certain games."
|
11
|
+
c.option "--steampassword OPTIONAL", String, "Steam account password for installing certain games."
|
12
|
+
c.action do |args, options|
|
13
|
+
GameTemplate.new(game_hash[args.first()], options.path).update(options.path)
|
14
|
+
end
|
15
|
+
end
|
data/lib/cli.rb
CHANGED
@@ -31,121 +31,121 @@ end
|
|
31
31
|
@games = userdata
|
32
32
|
|
33
33
|
program :name, "gsd-cli"
|
34
|
-
program :version, "0.1.
|
34
|
+
program :version, "0.1.29"
|
35
35
|
program :description, "A cli tool to deploy & manage dedicated game servers on Linux"
|
36
36
|
|
37
|
-
command :install do |c|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
37
|
+
# command :install do |c|
|
38
|
+
# c.syntax = "gsd install [args] [options]"
|
39
|
+
# c.summary = "Install and deploy a dedicated game server as a daemon."
|
40
|
+
# c.description = "Installs and deploy a dedicated game server as a daemon (systemd unit)."
|
41
|
+
# c.option "--path OPTIONAL", String, "Path that the game server will be installed to."
|
42
|
+
# c.option "--devmode OPTIONAL", String, "To run from source or as a Gem. ('y' to run from source)"
|
43
|
+
# c.option "--steamuser OPTIONAL", String, "Steam user account required to install certain games."
|
44
|
+
# c.option "--steampassword OPTIONAL", String, "Steam account password for installing certain games."
|
45
|
+
# c.action do |args, options|
|
46
|
+
# abort("Install what? Provide a game name argument!") if (args.first().nil?)
|
47
|
+
# puts "Beginning installation process. This may take a while...".yellow
|
48
|
+
# game = @games[args.first()]
|
49
|
+
# GameTemplate.new(game)
|
50
|
+
# .install("/opt/#{game.name}", options.steamuser, options.steampassword)
|
51
|
+
# puts "Server installation & deployment complete!".green
|
52
|
+
# end
|
53
|
+
# end
|
54
54
|
|
55
|
-
command :run do |c|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
55
|
+
# command :run do |c|
|
56
|
+
# c.syntax = "gsd run [args]"
|
57
|
+
# c.summary = "Run an installed dedicated game server as a new process."
|
58
|
+
# c.description = "Runs an installed dedicated game server as a new process. This command is used by the daemon and is not designed to be run manually."
|
59
|
+
# c.option "--path STRING", String, "Path that the game server will be installed to."
|
60
|
+
# c.action do |args, options|
|
61
|
+
# GameTemplate.new(@games[args.first()]).run(options.path)
|
62
|
+
# end
|
63
|
+
# end
|
64
64
|
|
65
|
-
command :update do |c|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
65
|
+
# command :update do |c|
|
66
|
+
# c.syntax = "gsd update [args] [options]"
|
67
|
+
# c.summary = "Updates an installed dedicated game server."
|
68
|
+
# c.description = "Updates an installed dedicated game server."
|
69
|
+
# c.option "--path STRING", String, "Path that the game server will be update to."
|
70
|
+
# c.action do |args, options|
|
71
|
+
# GameTemplate.new(@games[args.first()], options.path).update(options.path)
|
72
|
+
# end
|
73
|
+
# end
|
74
74
|
|
75
|
-
command :start do |c|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
75
|
+
# command :start do |c|
|
76
|
+
# c.syntax = "gsd start [args]"
|
77
|
+
# c.summary = "Start a installed dedicated game server."
|
78
|
+
# c.description = "Starts a dedicated game server daemon that has already been installed to the system."
|
79
|
+
# c.action do |args|
|
80
|
+
# GameTemplate.new(@games[args.first()]).start()
|
81
|
+
# end
|
82
|
+
# end
|
83
83
|
|
84
|
-
command :restart do |c|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
84
|
+
# command :restart do |c|
|
85
|
+
# c.syntax = "gsd restart [args]"
|
86
|
+
# c.summary = "Restart a installed dedicated game server."
|
87
|
+
# c.description = "Restarts a dedicated game server daemon that has already been installed to the system."
|
88
|
+
# c.option "--remote OPTIONAL", String, "Connection string to a remote host server."
|
89
|
+
# c.action do |args, options|
|
90
|
+
# GameTemplate.new(@games[args.first()], options.remote).restart()
|
91
|
+
# end
|
92
|
+
# end
|
93
93
|
|
94
|
-
command :status do |c|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
end
|
94
|
+
# command :status do |c|
|
95
|
+
# c.syntax = "gsd status [args]"
|
96
|
+
# c.summary = "Display the status of a installed dedicated game server."
|
97
|
+
# c.description = "Requests and returns the status of a installed dedicated game server from systemd."
|
98
|
+
# c.action do |args|
|
99
|
+
# GameTemplate.new(@games[args.first()]).status()
|
100
|
+
# end
|
101
|
+
# end
|
102
102
|
|
103
|
-
command :stop do |c|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end
|
103
|
+
# command :stop do |c|
|
104
|
+
# c.syntax = "gsd stop [args]"
|
105
|
+
# c.summary = "Stop running dedicated game server."
|
106
|
+
# c.description = "Stops a running dedicated game server daemon."
|
107
|
+
# c.action do |args|
|
108
|
+
# GameTemplate.new(@games[args.first()]).stop()
|
109
|
+
# end
|
110
|
+
# end
|
111
111
|
|
112
|
-
command :enable do |c|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
end
|
112
|
+
# command :enable do |c|
|
113
|
+
# c.syntax = "gsd enable [args]"
|
114
|
+
# c.summary = "Force a dedicated game server daemon to launch at system start."
|
115
|
+
# c.description = "Enables a dedicated game server daemon to start when the system starts."
|
116
|
+
# c.action do |args|
|
117
|
+
# GameTemplate.new(@games[args.first()]).stop()
|
118
|
+
# end
|
119
|
+
# end
|
120
120
|
|
121
|
-
command :disable do |c|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
end
|
121
|
+
# command :disable do |c|
|
122
|
+
# c.syntax = "gsd disable [args]"
|
123
|
+
# c.summary = "Disable a dedicated game server daemon from starting at system start."
|
124
|
+
# c.description = "Disables a dedicated game server daemon from starting when the system starts."
|
125
|
+
# c.action do |args|
|
126
|
+
# GameTemplate.new(@games[args.first()]).stop()
|
127
|
+
# end
|
128
|
+
# end
|
129
129
|
|
130
|
-
command :list do |c|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
130
|
+
# command :list do |c|
|
131
|
+
# c.syntax = "gsd list"
|
132
|
+
# c.summary = "Provides a list of supported dedicated game servers."
|
133
|
+
# c.description = "Provides a list of available dedicated game servers and their status."
|
134
|
+
# c.action do
|
135
|
+
# puts "The following games are currently supported by gsd:".yellow.bold
|
136
|
+
# YAML.safe_load(File.read("#{File.dirname(__FILE__)}/../conf/supported_games.yml"))["games"]
|
137
|
+
# .each do |game|
|
138
|
+
# puts game.light_blue
|
139
|
+
# end
|
140
|
+
# end
|
141
|
+
# end
|
142
142
|
|
143
|
-
command :uninstall do |c|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
end
|
143
|
+
# command :uninstall do |c|
|
144
|
+
# c.syntax = "gsd uninstall [args]"
|
145
|
+
# c.summary = "Uninstall a dedicated game server."
|
146
|
+
# c.description = "Uninstalls and removes all files associated with a dedicated game server."
|
147
|
+
# c.option "--name STRING", String, "Name of the dedicated game server."
|
148
|
+
# c.action do |_args, _options|
|
149
|
+
# puts "Not Implemented"
|
150
|
+
# end
|
151
|
+
# end
|
data/lib/game_template.rb
CHANGED
@@ -45,16 +45,14 @@ class GameTemplate
|
|
45
45
|
exec(@game.launch(install_path))
|
46
46
|
end
|
47
47
|
|
48
|
-
def install(install_path,
|
49
|
-
# ensure_delete_unit_file(install_path) if install_path.nil? == false
|
48
|
+
def install(install_path, steam_login)
|
50
49
|
if @game.app_id.nil?
|
51
|
-
@game.install_server(
|
50
|
+
@game.install_server(install_path)
|
52
51
|
else
|
53
|
-
install_steam_server(install_path,
|
52
|
+
install_steam_server(install_path, steam_login)
|
54
53
|
end
|
55
54
|
@game.post_install(install_path) if defined? @game.post_install
|
56
|
-
|
57
|
-
create_unit_file(cli_path, install_path)
|
55
|
+
create_unit_file(`which gsd-cli`.strip(), install_path)
|
58
56
|
end
|
59
57
|
|
60
58
|
def update(install_path)
|
@@ -68,37 +66,16 @@ class GameTemplate
|
|
68
66
|
private
|
69
67
|
|
70
68
|
# Installs or Updates a dedicated game server via Steamcmd
|
71
|
-
def install_steam_server(install_path
|
72
|
-
login = if steamuser.nil?
|
73
|
-
"+login anonymous"
|
74
|
-
else
|
75
|
-
"+login #{steamuser} #{steampassword}"
|
76
|
-
end
|
69
|
+
def install_steam_server(install_path, steam_login)
|
77
70
|
abort("STEAMCMD does not appear to be installed! Aborting...".red) if `which steamcmd`.empty?
|
78
|
-
system("$(which steamcmd)
|
79
|
-
system("$(which steamcmd) #{
|
80
|
-
# @game.post_install(install_path) if defined? @game.post_install
|
81
|
-
end
|
82
|
-
|
83
|
-
def get_install_path(path)
|
84
|
-
install_path = if path.nil?
|
85
|
-
# puts "Install path not defined: installing to /tmp/#{@game.name}".yellow
|
86
|
-
"/opt/#{@game.name}"
|
87
|
-
else
|
88
|
-
path
|
89
|
-
end
|
90
|
-
install_path
|
91
|
-
end
|
92
|
-
|
93
|
-
def ensure_delete_unit_file(unit_file_path)
|
94
|
-
File.delete(unit_file_path) if File.file?(unit_file_path)
|
71
|
+
system("$(which steamcmd) #{steam_login} +quit")
|
72
|
+
system("$(which steamcmd) #{steam_login} +force_install_dir #{install_path} +app_update #{@game.app_id} validate +quit")
|
95
73
|
end
|
96
74
|
|
97
75
|
def create_unit_file(cli_path, install_path)
|
98
76
|
file_path = "/tmp/#{@game.name}.service"
|
99
|
-
|
100
|
-
|
101
|
-
out_file.close()
|
77
|
+
`touch #{file_path}`
|
78
|
+
`echo #{unit_file_contents} >> #{file_path}`
|
102
79
|
system("mv -f #{"/tmp/#{@game.name}.service"} /etc/systemd/system/#{@game.name}.service")
|
103
80
|
end
|
104
81
|
|
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.
|
4
|
+
version: 0.1.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Egee
|
@@ -47,6 +47,10 @@ extra_rdoc_files: []
|
|
47
47
|
files:
|
48
48
|
- bin/gsd-cli
|
49
49
|
- lib/cli.rb
|
50
|
+
- lib/cli/game_hash.rb
|
51
|
+
- lib/cli/install.rb
|
52
|
+
- lib/cli/run.rb
|
53
|
+
- lib/cli/update.rb
|
50
54
|
- lib/game_template.rb
|
51
55
|
- lib/helpers.rb
|
52
56
|
- lib/servers/ace_of_spades.rb
|