Class: GameTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/game_template.rb

Overview

Create a Rust server

Instance Method Summary collapse

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

#disableObject



40
41
42
# File 'lib/game_template.rb', line 40

def disable
  system("sudo -p 'sudo password: ' systemctl disable #{@game.name}")
end

#enableObject



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, )
  if @game.app_id.nil?
    @game.install_server(install_path)
  else
    install_steam_server(install_path, )
  end
  @game.post_install(install_path) if defined? @game.post_install
  create_unit_file(install_path)
end

#restartObject



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

#startObject



13
14
15
# File 'lib/game_template.rb', line 13

def start
  system("sudo -p 'sudo password: ' systemctl start #{@game.name}")
end

#statusObject



28
29
30
# File 'lib/game_template.rb', line 28

def status
  system("sudo -p 'sudo password: ' systemctl status #{@game.name}")
end

#stopObject



32
33
34
# File 'lib/game_template.rb', line 32

def stop
  system("sudo -p 'sudo password: ' systemctl stop #{@game.name}")
end