Kaydet (Commit) a284cee6 authored tarafından mertcelen's avatar mertcelen

Service start,stop,restart systems added .

üst 2a5e2075
......@@ -342,10 +342,9 @@ class OneController extends Controller
public function serviceList()
{
$table = "";
$services = [];
if(server()->type == "linux_ssh"){
$raw = server()->run("systemctl list-units | grep service | awk '{print $1 \":\"$2\" \"$3\" \"$4\":\"$5\" \"$6\" \"$7\" \"$8\" \"$9\" \"$10}'",false);
$services = [];
foreach (explode("\n", $raw) as $package) {
if ($package == "") {
continue;
......@@ -354,21 +353,12 @@ class OneController extends Controller
try {
array_push($services, [
"name" => $row[0],
"status" => $row[1],
"description" => $row[2]
"description" => $row[2],
"status" => $row[1]
]);
} catch (Exception $exception) {
}
}
$table = view('l.table',[
"value" => $services,
"title" => [
"Adı" , "Açıklama" , "Durumu"
],
"display" => [
"name" , "description" , "status"
],
]);
}elseif (server()->type == "windows_powershell"){
$rawServices = server()->run("(Get-WmiObject win32_service | select Name, DisplayName, State, StartMode) -replace '\s\s+',':'");
$services = [];
......@@ -380,26 +370,16 @@ class OneController extends Controller
try{
array_push($services,[
"name" => trim(explode('=',$row[0])[1]),
"displayName" => trim(explode('=',$row[1])[1]),
"state" => trim(explode('=',$row[2])[1]),
"startMode" => trim(explode('=',$row[3])[1])
"description" => trim(explode('=',$row[1])[1]),
"status" => trim(explode('=',$row[2])[1]),
]);
}catch (Exception $exception){
}
}
$table = view('l.table',[
"value" => $services,
"title" => [
"Adı" , "Açıklama" , "Durumu" , "Başlatma"
],
"display" => [
"name" , "displayName" , "state", "startMode"
],
]);
}else{
return respond("Bu sunucudaki servisleri goremezsiniz.",403);
}
return $table;
return respond($services);
}
public function getLogs()
......@@ -596,4 +576,37 @@ class OneController extends Controller
}
return respond("Eklentiler Başarıyla Silindi");
}
public function startService()
{
if(server()->type == "linux_ssh"){
$command = "sudo systemctl start " . request('name');
}else{
$command = "Start-Service " . request("name");
}
server()->run($command);
return respond("Servis Baslatildi",200);
}
public function stopService()
{
if(server()->type == "linux_ssh"){
$command = "sudo systemctl stop " . request('name');
}else{
$command = "Stop-Service " . request("name");
}
server()->run($command);
return respond("Servis Durduruldu",200);
}
public function restartService()
{
if(server()->type == "linux_ssh"){
$command = "sudo systemctl restart " . request('name');
}else{
$command = "Restart-Service " . request("name");
}
server()->run($command);
return respond("Servis Yeniden Baslatildi",200);
}
}
......@@ -85,4 +85,10 @@ Route::group(['middleware' => ['server']], function () {
Route::post('/sunucu/yukselt','Server\OneController@upgradeServer')->name('server_upgrade');
Route::post('/sunucu/eklentiSil','Server\OneController@removeExtension')->name('server_extension_remove');
Route::post('/sunucu/servis/baslat','Server\OneController@startService')->name('server_start_service');
Route::post('/sunucu/servis/durdur','Server\OneController@stopService')->name('server_stop_service');
Route::post('/sunucu/servis/yenidenBaslat','Server\OneController@restartService')->name('server_restart_service');
});
......@@ -36,8 +36,6 @@
</a>
</li>
@endif
{{-- <li class=""><a href="#filesTab" data-toggle="tab" aria-expanded="false">{{__("Dosya Transferi")}}</a>--}}
{{-- </li>--}}
@endif
<li class=""><a href="#logsTab" onclick="getLogs()" data-toggle="tab" aria-expanded="false">{{__("Günlük Kayıtları")}}</a></li>
<li class=""><a href="#settingsTab" data-toggle="tab" aria-expanded="false">{{__("Ayarlar")}}</a></li>
......@@ -153,7 +151,31 @@
</div>
@if(server()->type == "linux_ssh" || server()->type == "windows_powershell")
<div class="tab-pane" id="servicesTab">
@include('l.table',[
"id" => "servicesTable",
"value" => [],
"title" => [
"Servis Adı" , "Aciklamasi" , "Durumu"
],
"display" => [
"name" , "description", "status"
],
"menu" => [
"Baslat" => [
"target" => "startService",
"icon" => "fa-play"
],
"Durdur" => [
"target" => "stopService",
"icon" => "fa-stop"
],
"Yeniden Baslat" => [
"target" => "restartService",
"icon" => "fa-refresh"
]
],
])
</div>
<div class="tab-pane right" id="updatesTab">
<button type="button" style="display: none; margin-bottom: 5px;" class="btn btn-success updateAllPackages" onclick="updateAllPackages()">Tümünü Güncelle</button>
......@@ -241,6 +263,45 @@
"submit_text" => "Eklentileri Sil"
])
@include('l.modal',[
"id"=>"startService",
"title" => "Servisi Baslat",
"text" => "Secili servisi baslatmak istediginize emin misiniz?",
"type" => "danger",
"next" => "reload",
"inputs" => [
"name:-" => "name:hidden",
],
"url" => route('server_start_service'),
"submit_text" => "Servisi Baslat"
])
@include('l.modal',[
"id"=>"stopService",
"title" => "Servisi Durdur",
"text" => "Secili servisi durdurmak istediginize emin misiniz?",
"type" => "danger",
"next" => "reload",
"inputs" => [
"name:-" => "name:hidden",
],
"url" => route('server_stop_service'),
"submit_text" => "Servisi Durdur"
])
@include('l.modal',[
"id"=>"restartService",
"title" => "Servisi Yeniden Baslat",
"text" => "Secili servisi yeniden baslatmak istediginize emin misiniz?",
"type" => "danger",
"next" => "reload",
"inputs" => [
"name:-" => "name:hidden",
],
"url" => route('server_restart_service'),
"submit_text" => "Servisi Yeniden Baslat"
])
@include('l.modal',[
"id"=>"file_upload",
"title" => "Dosya Yükle",
......@@ -486,12 +547,15 @@
showConfirmButton: false,
});
request('{{route('server_service_list')}}', new FormData(), function (response) {
$("#servicesTab").html(response);
$("#servicesTab table").DataTable({
bFilter: true,
"language": {
url: "/turkce.json"
}
let json = JSON.parse(response);
let table = $("#servicesTab table").DataTable();
table.rows().remove();
let counter = 1;
json["message"].forEach(element => {
let row = table.row.add([
counter++, element["name"], element["description"], element["status"]
]).draw(false).node();
$(row).addClass('tableRow');
});
setTimeout(function () {
Swal.close();
......@@ -699,5 +763,7 @@
}
});
});
</script>
@endsection
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment