Include default installation scripts, as well as ability to symlink a script

This commit is contained in:
Dane Everitt 2017-04-27 16:16:57 -04:00
parent 77b1a258d9
commit 30b4934013
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
12 changed files with 346 additions and 11 deletions

View file

@ -146,7 +146,16 @@ class OptionController extends Controller
*/
public function viewScripts(Request $request, $id)
{
return view('admin.services.options.scripts', ['option' => ServiceOption::findOrFail($id)]);
$option = ServiceOption::with('copyFrom')->findOrFail($id);
return view('admin.services.options.scripts', [
'copyFromOptions' => ServiceOption::whereNull('copy_script_from')->where([
['service_id', $option->service_id],
['id', '!=', $option->id],
])->get(),
'relyOnScript' => ServiceOption::where('copy_script_from', $option->id)->get(),
'option' => $option,
]);
}
/**
@ -234,11 +243,14 @@ class OptionController extends Controller
try {
$repo->scripts($id, $request->only([
'script_install', 'script_entry', 'script_container',
'script_install', 'script_entry',
'script_container', 'copy_script_from',
]));
Alert::success('Successfully updated option scripts to be run when servers are installed.')->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.services.option.scripts', $id)->withErrors(json_decode($ex->getMessage()));
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception was encountered while attempting to process that request. This error has been logged.')->flash();

View file

@ -40,12 +40,12 @@ class OptionController extends Controller
return response()->json([
'scripts' => [
'install' => (! $server->option->script_install) ? null : str_replace(["\r\n", "\n", "\r"], "\n", $server->option->script_install),
'install' => (! $server->option->copy_script_install) ? null : str_replace(["\r\n", "\n", "\r"], "\n", $server->option->copy_script_install),
'privileged' => $server->option->script_is_privileged,
],
'config' => [
'container' => $server->option->script_container,
'entry' => $server->option->script_entry,
'container' => $server->option->copy_script_container,
'entry' => $server->option->copy_script_entry,
],
'env' => $environment->merge([
'STARTUP=' . $server->startup,