diff --git a/debian/changelog b/debian/changelog index a906908..2b93bf3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,15 +1,21 @@ +cockpit-45drives-hardware (1.3.2-1focal) focal; urgency=medium + + * All modules can now be used by users with sudo privelages. + + -- 45Drives Tue, 09 Mar 2021 12:20:03 +0000 + cockpit-45drives-hardware (1.3.1-2focal) focal; urgency=medium * updated requirements of 45drives-tools dependency to >= 1.8.6. - -- 45Drives Mon, 08 Feb 2021 12:47:03 +0000 + -- 45Drives Mon, 08 Mar 2021 12:47:03 +0000 cockpit-45drives-hardware (1.3.1-1focal) focal; urgency=medium * Packaging of cockpit-45drives-hardware now handled using docker. * Added support for all Enhanced models with AMD processors. - -- 45Drives Mon, 08 Feb 2021 10:47:03 +0000 + -- 45Drives Mon, 08 Mar 2021 10:47:03 +0000 cockpit-45drives-hardware (1.3.0-3focal) focal; urgency=medium diff --git a/rpm/cockpit-45drives-hardware.spec b/rpm/cockpit-45drives-hardware.spec index bd66d60..82b0301 100644 --- a/rpm/cockpit-45drives-hardware.spec +++ b/rpm/cockpit-45drives-hardware.spec @@ -3,8 +3,8 @@ %define __os_install_post %{_dbpath}/brp-compress Name: cockpit-45drives-hardware -Version: 1.3.1 -Release: 2%{?dist} +Version: 1.3.2 +Release: 1%{?dist} Summary: A cockpit package for 45Drives Storinator Products. Group: Development/Tools @@ -62,9 +62,11 @@ rm -rf %{buildroot} /usr/share/cockpit/45drives-motherboard/* %changelog -* Thu Feb 25 2021 Mark Hooper 1.3.1-2 +* Tue Mar 09 2021 Mark Hooper 1.3.2-1 +- All modules can now be used by users with sudo privelages. +* Mon Mar 08 2021 Mark Hooper 1.3.1-2 - Updated requirements for 45drives-tools version from >= 1.8.5 to >= 1.8.6. -* Thu Feb 25 2021 Mark Hooper 1.3.1-1 +* Mon Mar 08 2021 Mark Hooper 1.3.1-1 - Packaging of cockpit-45drives-hardware now handled using docker. - Added support for all Enhanced models with AMD processors. * Thu Feb 25 2021 Mark Hooper 1.3.0-1 diff --git a/src/fakeroot/usr/share/cockpit/45drives-disks/45drives-disks.css b/src/fakeroot/usr/share/cockpit/45drives-disks/45drives-disks.css index 2b7eb13..c39a692 100644 --- a/src/fakeroot/usr/share/cockpit/45drives-disks/45drives-disks.css +++ b/src/fakeroot/usr/share/cockpit/45drives-disks/45drives-disks.css @@ -20,6 +20,13 @@ padding-right: 5px; } +.content_block_msg { + text-align: center; + font-size: large; + color: #981C20; + font-family:"RedHatText","Overpass",overpass,helvetica,arial,sans-serif; + padding-top: 5em; +} .header-45D > h2 { color: #FFFFFF; diff --git a/src/fakeroot/usr/share/cockpit/45drives-disks/45drives-disks.html b/src/fakeroot/usr/share/cockpit/45drives-disks/45drives-disks.html index fcd65a6..db50c08 100644 --- a/src/fakeroot/usr/share/cockpit/45drives-disks/45drives-disks.html +++ b/src/fakeroot/usr/share/cockpit/45drives-disks/45drives-disks.html @@ -17,7 +17,7 @@
-
+
diff --git a/src/fakeroot/usr/share/cockpit/45drives-disks/disks.js b/src/fakeroot/usr/share/cockpit/45drives-disks/disks.js index c3b74dc..1590647 100644 --- a/src/fakeroot/usr/share/cockpit/45drives-disks/disks.js +++ b/src/fakeroot/usr/share/cockpit/45drives-disks/disks.js @@ -398,11 +398,10 @@ var disk_app = function( d ) { function get_drive_info(){ var drive_info_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/opt/45drives/tools/lsdev", "-j" ], - {err: "out"} + {err: "out", superuser: "require"} ); drive_info_proc.done( function(data){ @@ -429,10 +428,9 @@ var disk_app = function( d ) { if (confirm("Disks requires a valid drive map.\n Would you like to run dmap?")) { var dmap_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/opt/45drives/tools/dmap" ], - {err: "out"} + {err: "out", superuser: "require"} ); dmap_proc.done( function(data){ @@ -462,14 +460,12 @@ var disk_app = function( d ) { } function get_server_info(){ - //var server_info_promise = cockpit.defer(); // get the server_info.json file var server_info_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-disks/helper_scripts/server_info" ], - {err: "out"} + {err: "out", superuser: "require"} ); server_info_proc.stream( function(data){ @@ -487,10 +483,9 @@ var disk_app = function( d ) { function get_zfs_info(){ var drive_info_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-disks/helper_scripts/zfs_info" ], - {err: "out"} + {err: "out", superuser: "require"} ); drive_info_proc.done( function(data){ @@ -510,11 +505,10 @@ var disk_app = function( d ) { d.jsonLoadRowPositions = function(){ var proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-disks/helper_scripts/dump_json", "/img/disk/ROW.json" ], - {err: "out"} + {err: "out", superuser: "require"} ); proc.stream( function(data){ @@ -858,8 +852,26 @@ function resourceSleep(ms) { async function startDiskApp(){ while(!document.getElementById("disk_app")){await resourceSleep(300);} - document.getElementById("disk_app").innerHTML = ""; - diskP5 = new p5(disk_app, 'disk_app'); + let root_check = cockpit.permission({ admin: true }); + root_check.addEventListener( + "changed", + function() { + if(root_check.allowed){ + //user is an administrator, start the module as normal + document.getElementById("disk_app").innerHTML = ""; + diskP5 = new p5(disk_app, 'disk_app'); + }else{ + //user is not an administrator, replace the page content with message + let page_content = document.getElementById("disk_content"); + page_content.innerHTML = ""; + let user_msg = document.createElement("div"); + user_msg.className = "content_block_msg"; + user_msg.innerHTML = "You must be an administrator to use this feature."; + page_content.appendChild(user_msg); + } + } + ) + } startDiskApp(); \ No newline at end of file diff --git a/src/fakeroot/usr/share/cockpit/45drives-motherboard/45drives-motherboard.css b/src/fakeroot/usr/share/cockpit/45drives-motherboard/45drives-motherboard.css index ecbbc08..bb0b352 100644 --- a/src/fakeroot/usr/share/cockpit/45drives-motherboard/45drives-motherboard.css +++ b/src/fakeroot/usr/share/cockpit/45drives-motherboard/45drives-motherboard.css @@ -28,6 +28,14 @@ align-self: center; } +.content_block_msg { + text-align: center; + font-size: large; + color: #981C20; + font-family:"RedHatText","Overpass",overpass,helvetica,arial,sans-serif; + padding-top: 5em; +} + .detail-table-header{ background-color: #FFFFFF; width: 100%; @@ -56,7 +64,7 @@ padding: 8px; } -.motherboard_content { +.motherboard_container { display: flex; flex-direction: row; justify-content: flex-start; diff --git a/src/fakeroot/usr/share/cockpit/45drives-motherboard/45drives-motherboard.html b/src/fakeroot/usr/share/cockpit/45drives-motherboard/45drives-motherboard.html index a4a3452..c92027e 100644 --- a/src/fakeroot/usr/share/cockpit/45drives-motherboard/45drives-motherboard.html +++ b/src/fakeroot/usr/share/cockpit/45drives-motherboard/45drives-motherboard.html @@ -18,7 +18,8 @@
-
+
+

Gathering Server Information

@@ -56,7 +57,7 @@

Gathering Server Information

- +
diff --git a/src/fakeroot/usr/share/cockpit/45drives-motherboard/motherboard.js b/src/fakeroot/usr/share/cockpit/45drives-motherboard/motherboard.js index 52b6688..d82d349 100644 --- a/src/fakeroot/usr/share/cockpit/45drives-motherboard/motherboard.js +++ b/src/fakeroot/usr/share/cockpit/45drives-motherboard/motherboard.js @@ -48,7 +48,6 @@ var mobo_app = function( m ) { m.createComponentMasks = function(a){ - //var dfd = cockpit.defer(); var img_path = ( "img/motherboard/" + String(mobo_info["Motherboard Info"][0]["Motherboard"][0]["Product Name"]) + @@ -56,7 +55,6 @@ m.createComponentMasks = function(a){ String(mobo_json[a]["id"]) + ".png" ); MASK_ARR.push(m.loadImage(img_path)); - //dfd.resolve(); }; class component{ @@ -106,7 +104,6 @@ m.verifyAssetsLoaded = function(){ m.setup = function(){ let cnv = m.createCanvas(1024,1024); - //cnv.parent("motherboard_app"); cnv.mouseMoved(m.mouseActivity); mobo_image = document.getElementById("mobo_image"); m.frameRate(20); @@ -174,11 +171,9 @@ m.draw = function (){ } m.setGlobalMask = function(){ - //var dfd = cockpit.defer(); let inset = 30; let yTrim = 30; globalMask = m.generateMask(background_img.width,background_img.height,inset,inset+yTrim,background_img.width-(2*inset),background_img.height-((2*inset)+yTrim),true); - //dfd.resolve(); } @@ -352,7 +347,6 @@ m.generateMask = function(w,h,x0,y0,x1,y1,invert=false){ m.resizePopups = function(){ - //var dfd = cockpit.defer(); for(let i = 0; i < components.length; i++){ var lines = components[i].popup.content.split(/\r\n|\r|\n/); var linecount = components[i].popup.content.split(/\r\n|\r|\n/).length; @@ -366,11 +360,9 @@ m.resizePopups = function(){ } components[i].popup.width = 9*max_chars + 10; } - //dfd.resolve(); }; m.getRam= function(){ - //var dfd = cockpit.defer(); if(ram_info){ for(let i = 0; i < ram_info["Ram Info"].length; i++){ for(let c = 0; c < components.length; c++){ @@ -404,11 +396,9 @@ m.getRam= function(){ } } } - //dfd.resolve(); }; m.getPCI = function(){ - //var dfd = cockpit.defer(); let VERTOFFSET = 5.37; let VERTSCALE = 19.0; let WIDTHOFFSET = 1.24; @@ -609,7 +599,6 @@ m.getPCI = function(){ } } - //dfd.resolve(); }; m.getCPU = function(){ @@ -637,7 +626,6 @@ m.getCPU = function(){ }; m.getSATA = function(){ - //var dfd = cockpit.defer(); if(sata_info){ //sata info is a global variable in hardware.js for(let i = 0; i < sata_info["SATA Info"].length; i++){ @@ -678,7 +666,6 @@ m.getSATA = function(){ } } } - //dfd.resolve(); }; m.loadAssets = function(){ @@ -690,14 +677,12 @@ m.loadAssets = function(){ }; m.jsonLoadMotherboard = function(fname){ - //var dfd = cockpit.defer(); var proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-motherboard/helper_scripts/dump_json", fname ], - {err: "out"} + {err: "out", superuser: "require"} ); proc.stream( function(data){ @@ -719,7 +704,6 @@ m.jsonLoadMotherboard = function(fname){ ); } } - //dfd.resolve(); } ); }; @@ -768,16 +752,14 @@ function resourceSleep(ms) { } async function motherboard_script(){ - //var dfd = cockpit.defer(); while(!document.getElementById("motherboard_output") || !document.getElementById("mobo_image") || !document.getElementById("motherboard_msg_state")){await resourceSleep(300);} var m_output = document.getElementById("motherboard_output"); var mobo_img = document.getElementById("mobo_image"); var motherboard_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-motherboard/helper_scripts/motherboard" ], - {err: "out"} + {err: "out", superuser: "require"} ); motherboard_proc.stream( function(data) @@ -793,22 +775,18 @@ async function motherboard_script(){ String(mobo_info["Motherboard Info"][0]["Motherboard"][0]["Product Name"]) + "/" + String(mobo_info["Motherboard Info"][0]["Motherboard"][0]["Product Name"]) + ".json"); document.getElementById("motherboard_msg_state").innerHTML = "✓"; - //dfd.resolve(); } ); } async function pci_script(){ - //var pci_promise = cockpit.defer(); // load the pci information while(!document.getElementById("pci_msg_state")){await resourceSleep(300);} - //document.getElementById("pci_msg_state").innerHTML = "(Loading)"; var pci_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-motherboard/helper_scripts/pci" ], - {err: "out"} + {err: "out", superuser: "require"} ); pci_proc.stream( @@ -823,16 +801,13 @@ async function pci_script(){ } async function sata_script(){ - //var sata_promise = cockpit.defer(); //load the sata information while(!document.getElementById("sata_msg_state")){await resourceSleep(300);} - //document.getElementById("sata_msg_state").innerHTML = "(Loading)"; var sata_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-motherboard/helper_scripts/sata" ], - {err: "out"} + {err: "out", superuser: "require"} ); sata_proc.stream( @@ -841,22 +816,18 @@ async function sata_script(){ console.log("sata_info"); console.log(sata_info); document.getElementById("sata_msg_state").innerHTML = "✓"; - //sata_promise.resolve(); } ); } async function ram_script(){ - //var ram_promise = cockpit.defer(); //load the ram information while(!document.getElementById("ram_msg_state")){await resourceSleep(300);} - //document.getElementById("ram_msg_state").innerHTML = "(Loading)"; var ram_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-motherboard/helper_scripts/ram" ], - {err: "out"} + {err: "out", superuser: "require"} ); ram_proc.stream( function(data){ @@ -864,22 +835,19 @@ async function ram_script(){ console.log("ram_info"); console.log(ram_info); document.getElementById("ram_msg_state").innerHTML = "✓"; - //ram_promise.resolve(); } ); } async function network_script(){ - //var network_promise = cockpit.defer(); while(!document.getElementById("network_msg_state")){await resourceSleep(300);} - //document.getElementById("network_msg_state").innerHTML = "(Loading)"; // load the pci information var network_proc = cockpit.spawn( [ - "/usr/bin/pkexec", + "/usr/share/cockpit/45drives-motherboard/helper_scripts/network" ], - {err: "out"} + {err: "out", superuser: "require"} ); network_proc.stream( @@ -888,7 +856,7 @@ async function network_script(){ console.log("network_info"); console.log(network_info); document.getElementById("network_msg_state").innerHTML = "✓"; - //network_promise.resolve(); + } ); } @@ -900,17 +868,20 @@ function runServerSideScripts(){ function() { if(root_check.allowed){ //user is an administrator, start the module as normal - //system_script(); motherboard_script(); pci_script(); ram_script(); sata_script(); network_script(); }else{ - //user is not an administrator, inform them of this by - //displaying a message on each tab page. - let mo = document.getElementById("motherboard_output"); - mo.innerHTML = "You must be an administrator to use this feature."; + //user is not an administrator, don't run any scripts + let page_content = document.getElementById("motherboard_content"); + page_content.innerHTML = ""; + let user_msg = document.createElement("div"); + user_msg.className = "content_block_msg"; + user_msg.innerHTML = "You must be an administrator to use this feature."; + page_content.appendChild(user_msg); + } } ) @@ -944,14 +915,6 @@ async function startMoboApp(){ " is not available at this time."); } } - //else{ - // document.getElementById("motherboard_output").innerHTML = ( - // "Unable to obtain the required server information to start interactive motherboard application" - // ); - //} } -//document.addEventListener("DOMContentLoaded", (event) => { -// startMoboApp(); -//}); startMoboApp(); \ No newline at end of file diff --git a/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.css b/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.css index bd0b64c..616bf89 100644 --- a/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.css +++ b/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.css @@ -95,6 +95,14 @@ body { margin-left: 1em; } +.content_block_msg { + text-align: center; + font-size: large; + color: #981C20; + font-family:"RedHatText","Overpass",overpass,helvetica,arial,sans-serif; + padding-top: 5em; +} + .fa-refresh { align-self: flex-end; } diff --git a/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.js b/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.js index d94a920..4bf59f0 100644 --- a/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.js +++ b/src/fakeroot/usr/share/cockpit/45drives-system/45drives-system.js @@ -62,10 +62,9 @@ function sys_manual_scan(){ var sys_promise = cockpit.defer(); var proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-system/helper_scripts/system" ], - {err: "out"} + {err: "out",superuser: "require"} ); proc.stream( @@ -92,10 +91,9 @@ function mobo() var mobo_promise = cockpit.defer(); var motherboard_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-system/helper_scripts/motherboard" ], - {err: "out"} + {err: "out",superuser: "require"} ); motherboard_proc.stream( function(data) @@ -108,7 +106,6 @@ function mobo() cpu_content.innerHTML = ""; let cpu_table = buildCPUTable(); cpu_content.appendChild(cpu_table); - mobo_promise.resolve(); } ); @@ -121,10 +118,9 @@ function pci(){ // load the pci information var pci_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-system/helper_scripts/pci" ], - {err: "out"} + {err: "out",superuser: "require"} ); pci_proc.stream( @@ -146,10 +142,9 @@ function ram(){ //load the ram information var ram_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-system/helper_scripts/ram" ], - {err: "out"} + {err: "out",superuser: "require"} ); ram_proc.stream( function(data){ @@ -170,10 +165,9 @@ function network(){ // load the pci information var network_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-system/helper_scripts/network" ], - {err: "out"} + {err: "out",superuser: "require"} ); network_proc.stream( @@ -359,10 +353,9 @@ function get_server_info(){ // get the server_info.json file var server_info_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/usr/share/cockpit/45drives-system/helper_scripts/server_info" ], - {err: "out"} + {err: "out",superuser: "require"} ); server_info_proc.done( function(data){ @@ -375,10 +368,9 @@ function get_server_info(){ if (confirm("/etc/45drives/server_info/server_info.json not found.\nThis file can be created by dmap.\n Would you like to run dmap?")) { var dmap_proc = cockpit.spawn( [ - "/usr/bin/pkexec", "/opt/45drives/tools/dmap" ], - {err: "out"} + {err: "out",superuser: "require"} ); dmap_proc.done( function(data){ @@ -419,7 +411,7 @@ function get_server_info(){ function main() { - root_check = cockpit.permission({ admin: true }); + let root_check = cockpit.permission({ admin: true }); root_check.addEventListener( "changed", function() { @@ -437,8 +429,12 @@ function main() }else{ //user is not an administrator, inform them of this by //displaying a message on each tab page. - let user_msg = document.getElementById("45drives_system_content"); + let page_content = document.getElementById("45drives_system_content"); + page_content.innerHTML = ""; + let user_msg = document.createElement("div"); + user_msg.className = "content_block_msg"; user_msg.innerHTML = "You must be an administrator to use this feature."; + page_content.appendChild(user_msg); } } )