35 lines
581 B
Plaintext
35 lines
581 B
Plaintext
#!/usr/bin/ruby.ruby3.4
|
|
require 'json'
|
|
|
|
db_path = '/home/gameserver/server-files/mods.json'
|
|
|
|
unless File.exist?(db_path)
|
|
print ""
|
|
exit! 0
|
|
end
|
|
|
|
begin
|
|
mods = JSON.parse(File.read(db_path))
|
|
args = "-mods="
|
|
counter = 0
|
|
|
|
mods.each do |mod|
|
|
if mod['enabled']
|
|
args += ',' if counter > 0
|
|
args += mod['mod_id'].to_s
|
|
|
|
counter += 1
|
|
end
|
|
end
|
|
|
|
if counter > 0
|
|
print args
|
|
end
|
|
rescue JSON::ParserError
|
|
File.write('/tmp/mod-read-error', 'mods.json is corrupted')
|
|
print ""
|
|
rescue => err
|
|
File.write('/tmp/mod-read-error', err.to_s)
|
|
print ""
|
|
end
|