|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Pterodactyl - Panel |
| 4 | + * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in all |
| 14 | + * copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | + * SOFTWARE. |
| 23 | + */ |
| 24 | +use Illuminate\Database\Seeder; |
| 25 | +use Pterodactyl\Models\Service; |
| 26 | +use Pterodactyl\Models\ServiceOption; |
| 27 | +use Pterodactyl\Models\ServiceVariable; |
| 28 | + |
| 29 | +class SourceServiceTableSeeder extends Seeder |
| 30 | +{ |
| 31 | + /** |
| 32 | + * The core service ID. |
| 33 | + * |
| 34 | + * @var Models\Service |
| 35 | + */ |
| 36 | + protected $service; |
| 37 | + |
| 38 | + /** |
| 39 | + * Stores all of the option objects. |
| 40 | + * |
| 41 | + * @var array |
| 42 | + */ |
| 43 | + protected $option = []; |
| 44 | + |
| 45 | + /** |
| 46 | + * Run the database seeds. |
| 47 | + * |
| 48 | + * @return void |
| 49 | + */ |
| 50 | + public function run() |
| 51 | + { |
| 52 | + $this->addCoreService(); |
| 53 | + $this->addCoreOptions(); |
| 54 | + $this->addVariables(); |
| 55 | + } |
| 56 | + |
| 57 | + private function addCoreService() |
| 58 | + { |
| 59 | + $this->service = Service::updateOrCreate([ |
| 60 | + 'author' => config('pterodactyl.service.core'), |
| 61 | + 'folder' => 'rust', |
| 62 | + ], [ |
| 63 | + 'name' => 'Rust', |
| 64 | + 'description' => 'The only aim in Rust is to survive. To do this you will need to overcome struggles such as hunger, thirst and cold. Build a fire. Build a shelter. Kill animals for meat. Protect yourself from other players, and kill them for meat. Create alliances with other players and form a town. Do whatever it takes to survive.', |
| 65 | + 'startup' => './RustDedicated -batchmode +server.port {{SERVER_PORT}} +server.identity "rust" +rcon.port {{RCON_PORT}} +rcon.web true +server.hostname \"{{HOSTNAME}}\" +server.level \"{{LEVEL}}\" +server.description \"{{DESCRIPTION}}\" +server.url \"{{URL}}\" +server.headerimage \"{{SERVER_IMG}}\" +server.worldsize \"{{WORLD_SIZE}}\" +server.seed \"{{SEED}}\" +server.maxplayers {{MAX_PLAYERS}} +rcon.password \"{{RCON_PASS}}\" {{ADDITIONAL_ARGS}}', |
| 66 | + 'index_file' => Service::defaultIndexFile(), |
| 67 | + ]); |
| 68 | + } |
| 69 | + |
| 70 | + private function addCoreOptions() |
| 71 | + { |
| 72 | + $script = <<<'EOF' |
| 73 | +apt update |
| 74 | +apt -y --no-install-recommends install curl lib32gcc1 ca-certificates |
| 75 | +
|
| 76 | +cd /tmp |
| 77 | +curl -sSL -o steamcmd.tar.gz http://media.steampowered.com/installer/steamcmd_linux.tar.gz |
| 78 | +
|
| 79 | +mkdir -p /mnt/server/steam |
| 80 | +tar -xzvf steamcmd.tar.gz -C /mnt/server/steam |
| 81 | +cd /mnt/server/steam |
| 82 | +
|
| 83 | +chown -R root:root /mnt |
| 84 | +
|
| 85 | +export HOME=/mnt/server |
| 86 | +./steamcmd.sh +login anonymous +force_install_dir /mnt/server +app_update 258550 +quit |
| 87 | +
|
| 88 | +mkdir -p /mnt/server/.steam/sdk32 |
| 89 | +cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so |
| 90 | +EOF; |
| 91 | + |
| 92 | + $this->option['rustvanilla'] = ServiceOption::updateOrCreate([ |
| 93 | + 'service_id' => $this->service->id, |
| 94 | + 'tag' => 'rustvanilla', |
| 95 | + ], [ |
| 96 | + 'name' => 'Vanilla', |
| 97 | + 'description' => 'Vanilla Rust server.', |
| 98 | + 'docker_image' => 'tenten8401/pterodactyl-rust', |
| 99 | + 'config_startup' => '{"done": "Server startup complete", "userInteraction": []}', |
| 100 | + 'config_files' => '{}', |
| 101 | + 'config_logs' => '{"custom": false, "location": "latest.log"}', |
| 102 | + 'config_stop' => 'quit', |
| 103 | + 'config_from' => null, |
| 104 | + 'startup' => null, |
| 105 | + 'script_install' => $script, |
| 106 | + 'script_entry' => 'bash', |
| 107 | + 'script_container' => 'ubuntu:latest', |
| 108 | + ]); |
| 109 | + } |
| 110 | + |
| 111 | + private function addVariables() |
| 112 | + { |
| 113 | + $this->addVanillaVariables(); |
| 114 | + } |
| 115 | + |
| 116 | + private function addVanillaVariables() |
| 117 | + { |
| 118 | + ServiceVariable::updateOrCreate([ |
| 119 | + 'option_id' => $this->option['rustvanilla']->id, |
| 120 | + 'env_variable' => 'LD_LIBRARY_PATH', |
| 121 | + ], [ |
| 122 | + 'name' => 'LD_LIBRARY_PATH', |
| 123 | + 'description' => 'A fix for Rust not starting.', |
| 124 | + 'default_value' => './RustDedicated_Data/Plugins/x86_64', |
| 125 | + 'user_viewable' => 0, |
| 126 | + 'user_editable' => 0, |
| 127 | + 'rules' => 'required', |
| 128 | + ]); |
| 129 | + |
| 130 | + ServiceVariable::updateOrCreate([ |
| 131 | + 'option_id' => $this->option['rustvanilla']->id, |
| 132 | + 'env_variable' => 'HOSTNAME', |
| 133 | + ], [ |
| 134 | + 'name' => 'Server Name', |
| 135 | + 'description' => 'The name of your server in the public server list.', |
| 136 | + 'default_value' => 'A Rust Server', |
| 137 | + 'user_viewable' => 1, |
| 138 | + 'user_editable' => 1, |
| 139 | + 'rules' => 'required|string', |
| 140 | + ]); |
| 141 | + |
| 142 | + ServiceVariable::updateOrCreate([ |
| 143 | + 'option_id' => $this->option['rustvanilla']->id, |
| 144 | + 'env_variable' => 'LEVEL', |
| 145 | + ], [ |
| 146 | + 'name' => 'Level', |
| 147 | + 'description' => 'The world file for Rust to use.', |
| 148 | + 'default_value' => 'Procedural Map', |
| 149 | + 'user_viewable' => 1, |
| 150 | + 'user_editable' => 1, |
| 151 | + 'rules' => 'required|string', |
| 152 | + ]); |
| 153 | + |
| 154 | + ServiceVariable::updateOrCreate([ |
| 155 | + 'option_id' => $this->option['rustvanilla']->id, |
| 156 | + 'env_variable' => 'DESCRIPTION', |
| 157 | + ], [ |
| 158 | + 'name' => 'Description', |
| 159 | + 'description' => 'The description under your server title. Commonly used for rules & info.', |
| 160 | + 'default_value' => 'Powered by Pterodactyl', |
| 161 | + 'user_viewable' => 1, |
| 162 | + 'user_editable' => 1, |
| 163 | + 'rules' => 'required', |
| 164 | + ]); |
| 165 | + |
| 166 | + ServiceVariable::updateOrCreate([ |
| 167 | + 'option_id' => $this->option['rustvanilla']->id, |
| 168 | + 'env_variable' => 'URL', |
| 169 | + ], [ |
| 170 | + 'name' => 'URL', |
| 171 | + 'description' => 'The URL for your server. This is what comes up when clicking the "Visit Website" button.', |
| 172 | + 'default_value' => 'http://pterodactyl.io', |
| 173 | + 'user_viewable' => 1, |
| 174 | + 'user_editable' => 1, |
| 175 | + 'rules' => 'url', |
| 176 | + ]); |
| 177 | + |
| 178 | + ServiceVariable::updateOrCreate([ |
| 179 | + 'option_id' => $this->option['rustvanilla']->id, |
| 180 | + 'env_variable' => 'WORLD_SIZE', |
| 181 | + ], [ |
| 182 | + 'name' => 'World Size', |
| 183 | + 'description' => 'The world size for a procedural map.', |
| 184 | + 'default_value' => '3000', |
| 185 | + 'user_viewable' => 1, |
| 186 | + 'user_editable' => 1, |
| 187 | + 'rules' => 'required|integer', |
| 188 | + ]); |
| 189 | + |
| 190 | + ServiceVariable::updateOrCreate([ |
| 191 | + 'option_id' => $this->option['rustvanilla']->id, |
| 192 | + 'env_variable' => 'SEED', |
| 193 | + ], [ |
| 194 | + 'name' => 'World Seed', |
| 195 | + 'description' => 'The seed for a procedural map.', |
| 196 | + 'default_value' => '', |
| 197 | + 'user_viewable' => 1, |
| 198 | + 'user_editable' => 1, |
| 199 | + 'rules' => 'present', |
| 200 | + ]); |
| 201 | + |
| 202 | + ServiceVariable::updateOrCreate([ |
| 203 | + 'option_id' => $this->option['rustvanilla']->id, |
| 204 | + 'env_variable' => 'MAX_PLAYERS', |
| 205 | + ], [ |
| 206 | + 'name' => 'Max Players', |
| 207 | + 'description' => 'The maximum amount of players allowed in the server at once.', |
| 208 | + 'default_value' => '40', |
| 209 | + 'user_viewable' => 1, |
| 210 | + 'user_editable' => 1, |
| 211 | + 'rules' => 'required|integer', |
| 212 | + ]); |
| 213 | + |
| 214 | + ServiceVariable::updateOrCreate([ |
| 215 | + 'option_id' => $this->option['rustvanilla']->id, |
| 216 | + 'env_variable' => 'SERVER_IMG', |
| 217 | + ], [ |
| 218 | + 'name' => 'Server Header Image', |
| 219 | + 'description' => 'The header image for the top of your server listing.', |
| 220 | + 'default_value' => '', |
| 221 | + 'user_viewable' => 1, |
| 222 | + 'user_editable' => 1, |
| 223 | + 'rules' => 'url', |
| 224 | + ]); |
| 225 | + |
| 226 | + ServiceVariable::updateOrCreate([ |
| 227 | + 'option_id' => $this->option['rustvanilla']->id, |
| 228 | + 'env_variable' => 'RCON_PORT', |
| 229 | + ], [ |
| 230 | + 'name' => 'RCON Port', |
| 231 | + 'description' => 'Port for RCON connections.', |
| 232 | + 'default_value' => '8401', |
| 233 | + 'user_viewable' => 1, |
| 234 | + 'user_editable' => 0, |
| 235 | + 'rules' => 'required|integer', |
| 236 | + ]); |
| 237 | + |
| 238 | + ServiceVariable::updateOrCreate([ |
| 239 | + 'option_id' => $this->option['rustvanilla']->id, |
| 240 | + 'env_variable' => 'RCON_PASS', |
| 241 | + ], [ |
| 242 | + 'name' => 'RCON Password', |
| 243 | + 'description' => 'Remote console access password.', |
| 244 | + 'default_value' => 'CHANGEME', |
| 245 | + 'user_viewable' => 1, |
| 246 | + 'user_editable' => 1, |
| 247 | + 'rules' => 'required', |
| 248 | + ]); |
| 249 | + |
| 250 | + ServiceVariable::updateOrCreate([ |
| 251 | + 'option_id' => $this->option['rustvanilla']->id, |
| 252 | + 'env_variable' => 'ADDITIONAL_ARGS', |
| 253 | + ], [ |
| 254 | + 'name' => 'Additional Arguments', |
| 255 | + 'description' => 'Add additional startup parameters to the server.', |
| 256 | + 'default_value' => '', |
| 257 | + 'user_viewable' => 1, |
| 258 | + 'user_editable' => 1, |
| 259 | + 'rules' => 'present', |
| 260 | + ]); |
| 261 | + } |
| 262 | +} |
0 commit comments