Class: GameTemplate
- Inherits:
-
Object
- Object
- GameTemplate
- Defined in:
- lib/game_template.rb
Overview
Create a Rust server
Instance Method Summary collapse
- #disable ⇒ Object
- #enable ⇒ Object
-
#initialize(game, remote = "") ⇒ GameTemplate
constructor
A new instance of GameTemplate.
- #install(install_path, steam_login) ⇒ Object
- #restart ⇒ Object
- #run(install_path) ⇒ Object
- #start ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(game, remote = "") ⇒ GameTemplate
Returns a new instance of GameTemplate.
8 9 10 11 |
# File 'lib/game_template.rb', line 8 def initialize(game, remote = "") @game = game @remote = remote end |
Instance Method Details
#disable ⇒ Object
40 41 42 |
# File 'lib/game_template.rb', line 40 def disable system("sudo -p 'sudo password: ' systemctl disable #{@game.name}") end |
#enable ⇒ Object
36 37 38 |
# File 'lib/game_template.rb', line 36 def enable system("sudo -p 'sudo password: ' systemctl enable #{@game.name}") end |
#install(install_path, steam_login) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/game_template.rb', line 48 def install(install_path, steam_login) if @game.app_id.nil? @game.install_server(install_path) else install_steam_server(install_path, steam_login) end @game.post_install(install_path) if defined? @game.post_install create_unit_file(install_path) end |
#restart ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/game_template.rb', line 17 def restart command = "systemctl restart #{@game.name}" if @remote.nil? system("sudo -p 'sudo password: ' #{command}") else puts @remote puts command Helpers.remote_cmd(@remote, command) end end |
#run(install_path) ⇒ Object
44 45 46 |
# File 'lib/game_template.rb', line 44 def run(install_path) exec(@game.launch(install_path)) end |
#start ⇒ Object
13 14 15 |
# File 'lib/game_template.rb', line 13 def start system("sudo -p 'sudo password: ' systemctl start #{@game.name}") end |
#status ⇒ Object
28 29 30 |
# File 'lib/game_template.rb', line 28 def status system("sudo -p 'sudo password: ' systemctl status #{@game.name}") end |
#stop ⇒ Object
32 33 34 |
# File 'lib/game_template.rb', line 32 def stop system("sudo -p 'sudo password: ' systemctl stop #{@game.name}") end |