Skip to content

Commit

Permalink
Merge pull request #62 from nevernever69/dev
Browse files Browse the repository at this point in the history
Added support for Arch
  • Loading branch information
KunalSin9h authored Apr 10, 2024
2 parents 3355689 + 8f5bb99 commit 3b2090c
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 81 deletions.
48 changes: 48 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 3.0)
project(RunScript)

if(UNIX AND NOT APPLE)
file(READ "/etc/os-release" OS_RELEASE)

string(REGEX MATCH "ID=([A-Za-z]*)" LINUX_ID_MATCH "${OS_RELEASE}")
set(LINUX_ID "${CMAKE_MATCH_1}")

if(NOT LINUX_ID)
string(REGEX MATCH "ID_LIKE=([A-Za-z]*)" LINUX_ID_LIKE_MATCH "${OS_RELEASE}")
set(LINUX_ID "${CMAKE_MATCH_1}")
endif()

if(LINUX_ID STREQUAL "")
message(WARNING "Could not identify Linux distribution. Adapting as much as possible.")
set(DISTRO "Unknown Linux Distribution")
else()
if(LINUX_ID STREQUAL "arch")
message(STATUS "Detected Arch Linux")
set(DISTRO "Arch Linux")
add_custom_target(run_script
COMMAND sudo pacman -S --needed base-devel curl wget file openssl gtk3 patchelf libappindicator-gtk3 librsvg -y webkit2gtk
COMMENT "Running script on Arch Linux"
)
elseif(LINUX_ID STREQUAL "debian")
message(STATUS "Detected Debian Linux")
set(DISTRO "Debian Linux")
add_custom_target(run_script
COMMAND sudo apt-get install libwebkit2gtk-4.0-dev build-essential curl wget file libssl-dev libgtk-3-dev patchelf libappindicator3-dev librsvg2-dev -y
COMMENT "Running script on Debian Linux"
)

else()
message(STATUS "Detected ${LINUX_ID}-like Linux distribution")
set(DISTRO "${LINUX_ID}-like Linux")
add_custom_target(run_script
COMMAND sudo apt-get install libwebkit2gtk-4.0-dev build-essential curl wget file libssl-dev libgtk-3-dev patchelf libappindicator3-dev librsvg2-dev -y
COMMENT "Running script on Debian Linux"
)

endif()
endif()


else()
message(FATAL_ERROR "This CMake script is designed for Linux systems only.")
endif()
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
all: build run
build:
cmake -Bbuild
cmake --build build/


clean:
rm -rf build/
Binary file added public/arch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 0 additions & 73 deletions scripts/setup_host.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src-tauri/src/commands/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub async fn get_distro() -> Result<String, rspc::Error> {
"cat",
false,
true,
vec!["/etc/lsb-release"],
vec!["/etc/*-release"],
)
.exec(None)
{
Expand Down
11 changes: 7 additions & 4 deletions src/components/Home/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { ScrollArea } from "../ui/scroll-area";
import General from "./General";
import AllServices from "./Services";
import Ubuntu from "./UbuntuBranding";
import Ubuntu from './UbuntuBranding.tsx'
import Update from "./Update";

import {useContext} from 'react';
import {DistroContext} from '../context/Distro.jsx'

Check failure on line 7 in src/components/Home/Home.tsx

View workflow job for this annotation

GitHub Actions / build-frontend

Could not find a declaration file for module '../context/Distro.jsx'. '/home/runner/work/secops/secops/src/components/context/Distro.jsx' implicitly has an 'any' type.
export default function Home() {
const distrocontext = useContext(DistroContext);
const imageSrc = distrocontext.distro === "arch" ? "/arch.png" : "/ubuntu.png";

Check failure on line 10 in src/components/Home/Home.tsx

View workflow job for this annotation

GitHub Actions / build-frontend

'distrocontext' is of type 'unknown'.
return (
<div className="flex gap-2 xl:gap-4 h-[84vh]">
<div className="w-1/3 flex flex-col gap-2 xl:gap-4">
<div className="h-24 xl:h-36 border rounded shadow p-1 xl:p-2 flex items-center justify-center">
<div className="flex gap-2 xl:gap-4 items-center">
<img
src="/ubuntu.png"
alt="Ubuntu Desktop Logo"
src={imageSrc}
alt= {distrocontext.distro + "Desktop Logo"}

Check failure on line 18 in src/components/Home/Home.tsx

View workflow job for this annotation

GitHub Actions / build-frontend

'distrocontext' is of type 'unknown'.
className="h-14 xl:h-24 w-14 xl:w-24"
/>
<Ubuntu />
Expand Down
12 changes: 9 additions & 3 deletions src/components/Home/UbuntuBranding.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { rspc } from "@/context/rspc";
import React, {useContext} from 'react';

Check failure on line 2 in src/components/Home/UbuntuBranding.tsx

View workflow job for this annotation

GitHub Actions / build-frontend

'React' is declared but its value is never read.
import {DistroContext} from "../context/Distro.jsx";

Check failure on line 3 in src/components/Home/UbuntuBranding.tsx

View workflow job for this annotation

GitHub Actions / build-frontend

Could not find a declaration file for module '../context/Distro.jsx'. '/home/runner/work/secops/secops/src/components/context/Distro.jsx' implicitly has an 'any' type.

// This will collect information about the distro
// The data will be like this
Expand All @@ -7,6 +9,7 @@ import { rspc } from "@/context/rspc";
// DISTRIB_CODENAME=jammy
// DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"
export default function Ubuntu() {
const distrocontext = useContext(DistroContext);
const { data, isLoading, error } = rspc.useQuery(["get_distro"]);

if (error) {
Expand All @@ -18,13 +21,16 @@ export default function Ubuntu() {
}

const info = data.split("\n");
const release = info[2].replace("DISTRIB_CODENAME=", "");
const distro = info[3].replace('DISTRIB_DESCRIPTION="', "").replace('"', "");
const release = info[2].replace(/PRETTY_NAME=("|')(.*?)\1|DISTRIB_CODENAME=("|')(.*?)\3/g, "$2$4");
const distro_name = info[3].replace('DISTRIB_DESCRIPTION="', "").replace('"', "").replace("ID=", "");
distrocontext.setDistro(distro_name);

Check failure on line 26 in src/components/Home/UbuntuBranding.tsx

View workflow job for this annotation

GitHub Actions / build-frontend

'distrocontext' is of type 'unknown'.


return (
<div className="flex flex-col">
<span className="text-purple-800 font-semibold">{release}</span>
<span className="font-bold text-md xl:text-xl">{distro}</span>
<span className="font-bold text-md xl:text-xl">{distro_name}</span>
</div>
);
}

13 changes: 13 additions & 0 deletions src/components/context/Distro.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {createContext, useState} from 'react';
export const DistroContext = createContext(null);
export const DistroProvider = (props) => {
const [distro, setDistro] = useState('Ubuntu');
return(
<DistroContext.Provider value={{distro, setDistro}}>
{props.children}
</DistroContext.Provider>

)
}


3 changes: 3 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import TOR from "./components/TOR";
import Settings from "./components/Settings";
import Help from "./components/Help";
import Firewall from "./components/Firewall";
import {DistroProvider} from './components/context/Distro.jsx'

Check failure on line 14 in src/main.tsx

View workflow job for this annotation

GitHub Actions / build-frontend

Could not find a declaration file for module './components/context/Distro.jsx'. '/home/runner/work/secops/secops/src/components/context/Distro.jsx' implicitly has an 'any' type.

const router = createBrowserRouter([
{
Expand Down Expand Up @@ -39,8 +40,10 @@ document.addEventListener("DOMContentLoaded", () => {

ReactDom.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<DistroProvider>
<RspcProvider>
<RouterProvider router={router} />
</RspcProvider>
</DistroProvider>
</React.StrictMode>,
);

0 comments on commit 3b2090c

Please sign in to comment.