From f87874004be091dad5a05b53a64c8a7bf291a22e Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Mar 2025 16:33:45 +0100 Subject: [PATCH 01/22] Remove incorrect symlink --- frontend/public/json | 1 - 1 file changed, 1 deletion(-) delete mode 100644 frontend/public/json diff --git a/frontend/public/json b/frontend/public/json deleted file mode 100644 index cd80456..0000000 --- a/frontend/public/json +++ /dev/null @@ -1 +0,0 @@ -../../json \ No newline at end of file From f5d838da68273050555d42d2796f5398a4001fc9 Mon Sep 17 00:00:00 2001 From: MIckLesk Date: Tue, 11 Mar 2025 16:35:41 +0100 Subject: [PATCH 02/22] Correct symbolic link --- frontend/public/json | 1 + 1 file changed, 1 insertion(+) create mode 120000 frontend/public/json diff --git a/frontend/public/json b/frontend/public/json new file mode 120000 index 0000000..cd80456 --- /dev/null +++ b/frontend/public/json @@ -0,0 +1 @@ +../../json \ No newline at end of file From 49b524464ee594e550f85535e9b809c40edab593 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Mar 2025 16:39:25 +0100 Subject: [PATCH 03/22] Update frontend-cicd.yml --- .github/workflows/frontend-cicd.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/frontend-cicd.yml b/.github/workflows/frontend-cicd.yml index 0391a39..c4f1a64 100644 --- a/.github/workflows/frontend-cicd.yml +++ b/.github/workflows/frontend-cicd.yml @@ -27,7 +27,7 @@ concurrency: jobs: build: - runs-on: ubuntu-latest + runs-on: runner-cluster-htl-set defaults: run: working-directory: frontend # Set default working directory for all run steps @@ -45,6 +45,9 @@ jobs: - name: Install dependencies run: npm ci --prefer-offline --legacy-peer-deps + - name: Run tests + run: npm run test + - name: Configure Next.js for pages uses: actions/configure-pages@v5 with: From da16da149642213b6fee56af06b4d7f0dfb64f7e Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Mar 2025 16:41:26 +0100 Subject: [PATCH 04/22] Update frontend-cicd.yml --- .github/workflows/frontend-cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/frontend-cicd.yml b/.github/workflows/frontend-cicd.yml index c4f1a64..dd242f6 100644 --- a/.github/workflows/frontend-cicd.yml +++ b/.github/workflows/frontend-cicd.yml @@ -27,7 +27,7 @@ concurrency: jobs: build: - runs-on: runner-cluster-htl-set + runs-on: ubuntu-latest defaults: run: working-directory: frontend # Set default working directory for all run steps From 23add3314519c5ff850a1857053d7e4db4f1a47f Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Mar 2025 16:44:54 +0100 Subject: [PATCH 05/22] Update validate-json.test.ts --- .../__tests__/public/validate-json.test.ts | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/frontend/src/__tests__/public/validate-json.test.ts b/frontend/src/__tests__/public/validate-json.test.ts index ab73292..562ebe9 100644 --- a/frontend/src/__tests__/public/validate-json.test.ts +++ b/frontend/src/__tests__/public/validate-json.test.ts @@ -4,17 +4,7 @@ import path from "path"; import { ScriptSchema, type Script } from "@/app/json-editor/_schemas/schemas"; import { Metadata } from "@/lib/types"; -const publicJsonPath = path.join(process.cwd(), 'public/json'); -const getJsonDirectory = async () => { - if (!(await fs.stat(publicJsonPath).catch(() => null))) { - throw new Error(`JSON path file not found: ${publicJsonPath}`); - } - const jsonPath = (await fs.readFile(publicJsonPath, "utf-8")).trim(); - return path.resolve(process.cwd(), jsonPath); -}; - - -const jsonDir = await getJsonDirectory(); +const jsonDir = "public/json"; const metadataFileName = "metadata.json"; const encoding = "utf-8"; @@ -25,7 +15,7 @@ describe.each(fileNames)("%s", async (fileName) => { let script: Script; beforeAll(async () => { - const filePath = path.resolve(jsonDir, fileName); + const filePath = path.resolve(jsonDir, fileName); const fileContent = await fs.readFile(filePath, encoding) script = JSON.parse(fileContent); }) @@ -46,7 +36,7 @@ describe(`${metadataFileName}`, async () => { let metadata: Metadata; beforeAll(async () => { - const filePath = path.resolve(jsonDir, metadataFileName); + const filePath = path.resolve(jsonDir, metadataFileName); const fileContent = await fs.readFile(filePath, encoding) metadata = JSON.parse(fileContent); }) @@ -55,9 +45,9 @@ describe(`${metadataFileName}`, async () => { // TODO: create zod schema for metadata. Move zod schemas to /lib/types.ts assert(metadata.categories.length > 0); metadata.categories.forEach((category) => { - assert.isString(category.name) - assert.isNumber(category.id) - assert.isNumber(category.sort_order) + assert.isString(category.name) + assert.isNumber(category.id) + assert.isNumber(category.sort_order) }); }); }) From 038a8d75e0f4d84fbdc0287d43ed774a5df62820 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Mar 2025 16:48:20 +0100 Subject: [PATCH 06/22] fix syntax calibre-web --- json/calibre-web-automated.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/json/calibre-web-automated.json b/json/calibre-web-automated.json index 360cca3..0fb22ab 100644 --- a/json/calibre-web-automated.json +++ b/json/calibre-web-automated.json @@ -31,13 +31,13 @@ "password": "admin123" }, "notes": [ - { - "text": "This LXC is not interchangeable with the Calibre-Web LXC", - "type": "warning" - }, - { - "text": "Options enabled by default: Kobo sync; Goodreads author info; metadata extaction from epub, fb2, pdf; cover extraction from cbr, cbz, cbt files" - "type": "info" - } + { + "text": "This LXC is not interchangeable with the Calibre-Web LXC", + "type": "warning" + }, + { + "text": "Options enabled by default: Kobo sync; Goodreads author info; metadata extaction from epub, fb2, pdf; cover extraction from cbr, cbz, cbt files", + "type": "info" + } ] } From 96213c3f7b88872b80b2a2157ff522bb5b64654b Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Mar 2025 16:49:16 +0100 Subject: [PATCH 07/22] move --- json/{ => done}/revealjs.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename json/{ => done}/revealjs.json (100%) diff --git a/json/revealjs.json b/json/done/revealjs.json similarity index 100% rename from json/revealjs.json rename to json/done/revealjs.json From 8f0a8105117bc7880c7aebbca0aef1bd867e1e85 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Mar 2025 16:53:55 +0100 Subject: [PATCH 08/22] Update validate-json.test.ts --- frontend/src/__tests__/public/validate-json.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/__tests__/public/validate-json.test.ts b/frontend/src/__tests__/public/validate-json.test.ts index 562ebe9..32d8497 100644 --- a/frontend/src/__tests__/public/validate-json.test.ts +++ b/frontend/src/__tests__/public/validate-json.test.ts @@ -8,8 +8,11 @@ const jsonDir = "public/json"; const metadataFileName = "metadata.json"; const encoding = "utf-8"; -const fileNames = (await fs.readdir(jsonDir)) - .filter((fileName) => fileName !== metadataFileName) +const fileNames = (await fs.readdir(jsonDir)).filter(async (fileName) => { + const filePath = path.resolve(jsonDir, fileName); + const stat = await fs.stat(filePath); + return stat.isFile(); +}); describe.each(fileNames)("%s", async (fileName) => { let script: Script; From 08b09d8197c6b74f1d5eaa11b2d46d45e153fe73 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Mar 2025 16:56:15 +0100 Subject: [PATCH 09/22] Update validate-json.test.ts --- frontend/src/__tests__/public/validate-json.test.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/src/__tests__/public/validate-json.test.ts b/frontend/src/__tests__/public/validate-json.test.ts index 32d8497..7c532f2 100644 --- a/frontend/src/__tests__/public/validate-json.test.ts +++ b/frontend/src/__tests__/public/validate-json.test.ts @@ -8,10 +8,9 @@ const jsonDir = "public/json"; const metadataFileName = "metadata.json"; const encoding = "utf-8"; -const fileNames = (await fs.readdir(jsonDir)).filter(async (fileName) => { +const fileNames = (await fs.readdir(jsonDir)).filter((fileName) => { const filePath = path.resolve(jsonDir, fileName); - const stat = await fs.stat(filePath); - return stat.isFile(); + return fileName !== "done"; }); describe.each(fileNames)("%s", async (fileName) => { From 4903a422287f35627592b53248438cc9116330db Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Mar 2025 16:57:18 +0100 Subject: [PATCH 10/22] Delete json/done directory --- json/done/inventree.json | 39 ------------------------------------ json/done/revealjs.json | 43 ---------------------------------------- json/done/seafile.json | 43 ---------------------------------------- 3 files changed, 125 deletions(-) delete mode 100644 json/done/inventree.json delete mode 100644 json/done/revealjs.json delete mode 100644 json/done/seafile.json diff --git a/json/done/inventree.json b/json/done/inventree.json deleted file mode 100644 index 016d0e3..0000000 --- a/json/done/inventree.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "InvenTree", - "slug": "inventree", - "categories": [ - 25 - ], - "date_created": "2025-03-05", - "type": "ct", - "updateable": true, - "privileged": false, - "interface_port": 80, - "documentation": "https://docs.inventree.org/en/latest/", - "website": "https://inventree.org", - "logo": "https://docs.inventree.org/en/latest/assets/logo.png", - "description": "InvenTree is an open-source inventory management system which provides intuitive parts management and stock control. It is designed to be lightweight and easy to use for SME or hobbyist applications.", - "install_methods": [ - { - "type": "default", - "script": "ct/inventree.sh", - "resources": { - "cpu": 2, - "ram": 2048, - "hdd": 6, - "os": "debian", - "version": "12" - } - } - ], - "default_credentials": { - "username": "admin", - "password": "`cat /etc/inventree/admin_password.txt`" - }, - "notes": [ - { - "text": "Please read the documentation for your configuration needs.", - "type": "info" - } - ] -} diff --git a/json/done/revealjs.json b/json/done/revealjs.json deleted file mode 100644 index 004b2b2..0000000 --- a/json/done/revealjs.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "RevealJS", - "slug": "revealjs", - "categories": [ - 12 - ], - "date_created": "2025-03-03", - "type": "ct", - "updateable": true, - "privileged": false, - "interface_port": 8000, - "documentation": "https://github.com/hakimel/reveal.js/wiki", - "website": "https://github.com/hakimel/reveal.js", - "logo": "https://static.slid.es/reveal/logo-v1/reveal-white-text.svg", - "description": "reveal.js is an open source HTML presentation framework. It's a tool that enables anyone with a web browser to create fully-featured and beautiful presentations for free.", - "install_methods": [ - { - "type": "default", - "script": "ct/revealjs.sh", - "resources": { - "cpu": 1, - "ram": 1024, - "hdd": 4, - "os": "debian", - "version": "12" - } - } - ], - "default_credentials": { - "username": null, - "password": null - }, - "notes": [ - { - "text": "Config file is at `/opt/revealjs/gulpfile.js`. Check the documentation for more information.", - "type": "info" - }, - { - "text": "LiveReload is on port: 35729", - "type": "info" - } - ] -} diff --git a/json/done/seafile.json b/json/done/seafile.json deleted file mode 100644 index 7614fa8..0000000 --- a/json/done/seafile.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "Seafile", - "slug": "Seafile", - "categories": [ - 12 - ], - "date_created": "2025-02-25", - "type": "ct", - "updateable": false, - "privileged": false, - "interface_port": 8000, - "documentation": "https://manual.seafile.com/11.0/deploy", - "website": "https://seafile.com", - "logo": "https://manual.seafile.com/11.0/media/seafile-transparent-1024.png", - "description": "Seafile is an open source file sync and share platform, focusing on reliability and performance.", - "install_methods": [ - { - "type": "default", - "script": "ct/seafile.sh", - "resources": { - "cpu": 2, - "ram": 2048, - "hdd": 20, - "os": "debian", - "version": "12" - } - } - ], - "default_credentials": { - "username": null, - "password": null - }, - "notes": [ - { - "text": "Application credentials: `cat ~/seafile.creds`", - "type": "info" - }, - { - "text": "Change STORAGE_DIR value in `external-storage.sh` and run `bash external-storage.sh` to use your defined storage instead of internal.", - "type": "info" - } - ] -} \ No newline at end of file From f5e2a2f54bfd4ba4a10b1774585c622b5fc05e5d Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Mar 2025 16:57:56 +0100 Subject: [PATCH 11/22] Update validate-json.test.ts --- frontend/src/__tests__/public/validate-json.test.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/frontend/src/__tests__/public/validate-json.test.ts b/frontend/src/__tests__/public/validate-json.test.ts index 7c532f2..562ebe9 100644 --- a/frontend/src/__tests__/public/validate-json.test.ts +++ b/frontend/src/__tests__/public/validate-json.test.ts @@ -8,10 +8,8 @@ const jsonDir = "public/json"; const metadataFileName = "metadata.json"; const encoding = "utf-8"; -const fileNames = (await fs.readdir(jsonDir)).filter((fileName) => { - const filePath = path.resolve(jsonDir, fileName); - return fileName !== "done"; -}); +const fileNames = (await fs.readdir(jsonDir)) + .filter((fileName) => fileName !== metadataFileName) describe.each(fileNames)("%s", async (fileName) => { let script: Script; From c9030b34bb8d628c0802ef62cc81d8222d6b650e Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Mar 2025 17:00:16 +0100 Subject: [PATCH 12/22] remove api --- frontend/src/app/api/categories/route.ts | 65 -------- frontend/src/app/data/page.tsx | 198 ----------------------- 2 files changed, 263 deletions(-) delete mode 100644 frontend/src/app/api/categories/route.ts delete mode 100644 frontend/src/app/data/page.tsx diff --git a/frontend/src/app/api/categories/route.ts b/frontend/src/app/api/categories/route.ts deleted file mode 100644 index b603d9c..0000000 --- a/frontend/src/app/api/categories/route.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { Metadata, Script } from "@/lib/types"; -import { promises as fs } from "fs"; -import { NextResponse } from "next/server"; -import path from "path"; - -export const dynamic = "force-static"; - -const publicJsonPath = path.join(process.cwd(), 'public/json'); -const getJsonDirectory = async () => { - if (!(await fs.stat(publicJsonPath).catch(() => null))) { - throw new Error(`JSON path file not found: ${publicJsonPath}`); - } - const jsonPath = (await fs.readFile(publicJsonPath, "utf-8")).trim(); - return path.resolve(process.cwd(), jsonPath); -}; - -const jsonDir = await getJsonDirectory(); -const metadataFileName = "metadata.json"; -const encoding = "utf-8"; - -const getMetadata = async () => { - const filePath = path.resolve(jsonDir, metadataFileName); - const fileContent = await fs.readFile(filePath, encoding); - const metadata: Metadata = JSON.parse(fileContent); - return metadata; -}; - -const getScripts = async () => { - const filePaths = (await fs.readdir(jsonDir)) - .filter((fileName) => fileName !== metadataFileName) - .map((fileName) => path.resolve(jsonDir, fileName)); - - const scripts = await Promise.all( - filePaths.map(async (filePath) => { - const fileContent = await fs.readFile(filePath, encoding); - const script: Script = JSON.parse(fileContent); - return script; - }), - ); - return scripts; -}; - -export async function GET() { - try { - const metadata = await getMetadata(); - const scripts = await getScripts(); - - const categories = metadata.categories - .map((category) => { - category.scripts = scripts.filter((script) => - script.categories.includes(category.id), - ); - return category; - }) - .sort((a, b) => a.sort_order - b.sort_order); - - return NextResponse.json(categories); - } catch (error) { - console.error(error as Error); - return NextResponse.json( - { error: "Failed to fetch categories" }, - { status: 500 }, - ); - } -} diff --git a/frontend/src/app/data/page.tsx b/frontend/src/app/data/page.tsx deleted file mode 100644 index b752464..0000000 --- a/frontend/src/app/data/page.tsx +++ /dev/null @@ -1,198 +0,0 @@ -"use client"; - -import React, { JSX, useEffect, useState } from "react"; -import DatePicker from 'react-datepicker'; -import 'react-datepicker/dist/react-datepicker.css'; -import ApplicationChart from "../../components/ApplicationChart"; - -interface DataModel { - id: number; - ct_type: number; - disk_size: number; - core_count: number; - ram_size: number; - os_type: string; - os_version: string; - disableip6: string; - nsapp: string; - created_at: string; - method: string; - pve_version: string; - status: string; - error: string; - type: string; - [key: string]: any; -} - -interface SummaryData { - total_entries: number; - status_count: Record; - nsapp_count: Record; -} - -const DataFetcher: React.FC = () => { - const [data, setData] = useState([]); - const [summary, setSummary] = useState(null); - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - const [currentPage, setCurrentPage] = useState(1); - const [itemsPerPage, setItemsPerPage] = useState(25); - const [sortConfig, setSortConfig] = useState<{ key: string; direction: 'ascending' | 'descending' } | null>(null); - - useEffect(() => { - const fetchSummary = async () => { - try { - const response = await fetch("https://api.htl-braunau.at/data/summary"); - if (!response.ok) throw new Error(`Failed to fetch summary: ${response.statusText}`); - const result: SummaryData = await response.json(); - setSummary(result); - } catch (err) { - setError((err as Error).message); - } - }; - - fetchSummary(); - }, []); - - useEffect(() => { - const fetchPaginatedData = async () => { - setLoading(true); - try { - const response = await fetch(`https://api.htl-braunau.at/data/paginated?page=${currentPage}&limit=${itemsPerPage === 0 ? '' : itemsPerPage}`); - if (!response.ok) throw new Error(`Failed to fetch data: ${response.statusText}`); - const result: DataModel[] = await response.json(); - setData(result); - } catch (err) { - setError((err as Error).message); - } finally { - setLoading(false); - } - }; - - fetchPaginatedData(); - }, [currentPage, itemsPerPage]); - - const sortedData = React.useMemo(() => { - if (!sortConfig) return data; - const sorted = [...data].sort((a, b) => { - if (a[sortConfig.key] < b[sortConfig.key]) { - return sortConfig.direction === 'ascending' ? -1 : 1; - } - if (a[sortConfig.key] > b[sortConfig.key]) { - return sortConfig.direction === 'ascending' ? 1 : -1; - } - return 0; - }); - return sorted; - }, [data, sortConfig]); - - if (loading) return

Loading...

; - if (error) return

Error: {error}

; - - const requestSort = (key: string) => { - let direction: 'ascending' | 'descending' = 'ascending'; - if (sortConfig && sortConfig.key === key && sortConfig.direction === 'ascending') { - direction = 'descending'; - } - setSortConfig({ key, direction }); - }; - - const formatDate = (dateString: string): string => { - const date = new Date(dateString); - const year = date.getFullYear(); - const month = date.getMonth() + 1; - const day = date.getDate(); - const hours = String(date.getHours()).padStart(2, '0'); - const minutes = String(date.getMinutes()).padStart(2, '0'); - const timezoneOffset = dateString.slice(-6); - return `${day}.${month}.${year} ${hours}:${minutes} ${timezoneOffset} GMT`; - }; - - return ( -
-

Created LXCs

- -

-
-

{summary?.total_entries} results found

-

Status Legend: 🔄 installing {summary?.status_count["installing"] ?? 0} | ✔️ completed {summary?.status_count["done"] ?? 0} | ❌ failed {summary?.status_count["failed"] ?? 0} | ❓ unknown

-
-
-
- - - - - - - - - - - - - - - - - - - {sortedData.map((item, index) => ( - - - - - - - - - - - - - - - ))} - -
requestSort('status')}>Status requestSort('type')}>Type requestSort('nsapp')}>Application requestSort('os_type')}>OS requestSort('os_version')}>OS Version requestSort('disk_size')}>Disk Size requestSort('core_count')}>Core Count requestSort('ram_size')}>RAM Size requestSort('method')}>Method requestSort('pve_version')}>PVE Version requestSort('error')}>Error Message requestSort('created_at')}>Created At
- {item.status === "done" ? ( - "✔️" - ) : item.status === "failed" ? ( - "❌" - ) : item.status === "installing" ? ( - "🔄" - ) : ( - item.status - )} - {item.type === "lxc" ? ( - "📦" - ) : item.type === "vm" ? ( - "🖥️" - ) : ( - item.type - )}{item.nsapp}{item.os_type}{item.os_version}{item.disk_size}{item.core_count}{item.ram_size}{item.method}{item.pve_version}{item.error}{formatDate(item.created_at)}
-
-
-
- - Page {currentPage} - - -
-
- ); -}; - -export default DataFetcher; From 8f638d3828e0770456eae04833e7a58b9a08a724 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Mar 2025 17:03:34 +0100 Subject: [PATCH 13/22] readd route.ts --- frontend/src/app/api/categories/route.ts | 56 ++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 frontend/src/app/api/categories/route.ts diff --git a/frontend/src/app/api/categories/route.ts b/frontend/src/app/api/categories/route.ts new file mode 100644 index 0000000..2d33a3a --- /dev/null +++ b/frontend/src/app/api/categories/route.ts @@ -0,0 +1,56 @@ +import { Metadata, Script } from "@/lib/types"; +import { promises as fs } from "fs"; +import { NextResponse } from "next/server"; +import path from "path"; + +export const dynamic = "force-static"; + +const jsonDir = "public/json"; +const metadataFileName = "metadata.json"; +const encoding = "utf-8"; + +const getMetadata = async () => { + const filePath = path.resolve(jsonDir, metadataFileName); + const fileContent = await fs.readFile(filePath, encoding); + const metadata: Metadata = JSON.parse(fileContent); + return metadata; +}; + +const getScripts = async () => { + const filePaths = (await fs.readdir(jsonDir)) + .filter((fileName) => fileName !== metadataFileName) + .map((fileName) => path.resolve(jsonDir, fileName)); + + const scripts = await Promise.all( + filePaths.map(async (filePath) => { + const fileContent = await fs.readFile(filePath, encoding); + const script: Script = JSON.parse(fileContent); + return script; + }), + ); + return scripts; +}; + +export async function GET() { + try { + const metadata = await getMetadata(); + const scripts = await getScripts(); + + const categories = metadata.categories + .map((category) => { + category.scripts = scripts.filter((script) => + script.categories.includes(category.id), + ); + return category; + }) + .sort((a, b) => a.sort_order - b.sort_order); + + return NextResponse.json(categories); + } catch (error) { + console.error(error as Error); + return NextResponse.json( + { error: "Failed to fetch categories" }, + { status: 500 }, + ); + } +} From 522fd2b0eb4cf874624146d8fda8a63b03ef3e70 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 12 Mar 2025 08:34:57 +0100 Subject: [PATCH 14/22] add dev hostname --- misc/build.func | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/misc/build.func b/misc/build.func index 4b61dd8..5f61e31 100644 --- a/misc/build.func +++ b/misc/build.func @@ -330,7 +330,7 @@ base_settings() { VERBOSE="${1:-no}" PW="" CT_ID=$NEXTID - HN=$NSAPP + HN="dev_${NSAPP}" BRG="vmbr0" NET="dhcp" IPv6="auto" @@ -602,11 +602,12 @@ advanced_settings() { exit fi - if CT_NAME=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then +if CT_NAME=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 "dev_${NSAPP}" --title "HOSTNAME" 3>&1 1>&2 2>&3); then if [ -z "$CT_NAME" ]; then - HN="$NSAPP" + HN="dev_${NSAPP}" else HN=$(echo ${CT_NAME,,} | tr -d ' ') + [[ $HN != dev_* ]] && HN="dev_${HN}" fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else From 64a4842e863fd183c63f059436ec4ec043f6cb03 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 12 Mar 2025 08:55:23 +0100 Subject: [PATCH 15/22] Update build.func --- misc/build.func | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/misc/build.func b/misc/build.func index 5f61e31..4b61dd8 100644 --- a/misc/build.func +++ b/misc/build.func @@ -330,7 +330,7 @@ base_settings() { VERBOSE="${1:-no}" PW="" CT_ID=$NEXTID - HN="dev_${NSAPP}" + HN=$NSAPP BRG="vmbr0" NET="dhcp" IPv6="auto" @@ -602,12 +602,11 @@ advanced_settings() { exit fi -if CT_NAME=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 "dev_${NSAPP}" --title "HOSTNAME" 3>&1 1>&2 2>&3); then + if CT_NAME=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then if [ -z "$CT_NAME" ]; then - HN="dev_${NSAPP}" + HN="$NSAPP" else HN=$(echo ${CT_NAME,,} | tr -d ' ') - [[ $HN != dev_* ]] && HN="dev_${HN}" fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else From 69b0aa9af9e9d0e9f0257da53303668a63c39629 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 12 Mar 2025 10:12:11 +0100 Subject: [PATCH 16/22] Switch Script --- misc/switch_from_VED_to_VE.sh | 123 ++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 misc/switch_from_VED_to_VE.sh diff --git a/misc/switch_from_VED_to_VE.sh b/misc/switch_from_VED_to_VE.sh new file mode 100644 index 0000000..4562ac0 --- /dev/null +++ b/misc/switch_from_VED_to_VE.sh @@ -0,0 +1,123 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts +# Author: MickLesk +# License: MIT +# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE + +set -eEuo pipefail +BL=$(echo "\033[36m") +RD=$(echo "\033[01;31m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") + +function header_info { + clear + cat <<"EOF" + ____ _ ____________ __ ____ _ ________ + / __ \_________ _ ______ ___ ____ _ _| | / / ____/ __ \ / /_____ / __ \_________ _ ______ ___ ____ _ _| | / / ____/ + / /_/ / ___/ __ \| |/_/ __ `__ \/ __ \| |/_/ | / / __/ / / / / / __/ __ \ / /_/ / ___/ __ \| |/_/ __ `__ \/ __ \| |/_/ | / / __/ + / ____/ / / /_/ /> < | |/ / /___/ /_/ / / /_/ /_/ / / ____/ / / /_/ /> < | |/ / /___ +/_/ /_/ \____/_/|_/_/ /_/ /_/\____/_/|_| |___/_____/_____/ \__/\____/ /_/ /_/ \____/_/|_/_/ /_/ /_/\____/_/|_| |___/_____/ + +EOF +} + +function update_container() { + container=$1 + os=$(pct config "$container" | awk '/^ostype/ {print $2}') + + if [[ "$os" == "ubuntu" || "$os" == "debian" || "$os" == "alpine" ]]; then + echo -e "${BL}[Info]${GN} Checking /usr/bin/update in ${BL}$container${CL} (OS: ${GN}$os${CL})" + + if pct exec "$container" -- [ -e /usr/bin/update ]; then + pct exec "$container" -- bash -c "sed -i 's/ProxmoxVED/ProxmoxVE/g' /usr/bin/update" + + if pct exec "$container" -- grep -q "ProxmoxVE" /usr/bin/update; then + echo -e "${GN}[Success]${CL} /usr/bin/update updated in ${BL}$container${CL}.\n" + else + echo -e "${RD}[Error]${CL} /usr/bin/update in ${BL}$container${CL} could not be updated properly.\n" + fi + else + echo -e "${RD}[Error]${CL} /usr/bin/update not found in container ${BL}$container${CL}.\n" + fi + else + echo -e "${BL}[Info]${GN} Skipping ${BL}$container${CL} (not Debian/Ubuntu/Alpine)\n" + fi +} + +function update_motd() { + container=$1 + os=$(pct config "$container" | awk '/^ostype/ {print $2}') + + if [[ "$os" == "ubuntu" || "$os" == "debian" ]]; then + echo -e "${BL}[Info]${GN} Updating MOTD in ${BL}$container${CL} (OS: ${GN}$os${CL})" + + pct exec "$container" -- bash -c " + YW='\033[33m' + GN='\033[1;92m' + CL='\033[m' + TAB=' ' + GATEWAY='🌐' + OS='🖥️' + HOSTNAME='🏠' + INFO='💡' + PROFILE_FILE='/etc/profile.d/00_motd.sh' + + echo 'echo -e \"\"' > \"\$PROFILE_FILE\" + echo 'echo -e \"${TAB}\$GATEWAY${TAB}\$YW Provided by: \$GN community-scripts ORG \$YW | GitHub: \$GN https://github.com/community-scripts/ProxmoxVE \$CL\"' >> \"\$PROFILE_FILE\" + echo 'echo \"\"' >> \"\$PROFILE_FILE\" + echo 'echo -e \"${TAB}\$OS${TAB}\$YW OS: \$GN \$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"') \$CL\"' >> \"\$PROFILE_FILE\" + echo 'echo -e \"${TAB}\$HOSTNAME${TAB}\$YW Hostname: \$GN \$(hostname) \$CL\"' >> \"\$PROFILE_FILE\" + echo 'echo -e \"${TAB}\$INFO${TAB}\$YW IP Address: \$GN \$(hostname -I | awk '{print \$1}') \$CL\"' >> \"\$PROFILE_FILE\" + chmod -x /etc/update-motd.d/* + " + elif [[ "$os" == "alpine" ]]; then + echo -e "${BL}[Info]${GN} Updating MOTD in ${BL}$container${CL} (OS: ${GN}$os${CL})" + + pct exec "$container" -- bash -c " + echo \"export TERM='xterm-256color'\" >> /root/.bashrc + IP=\$(ip -4 addr show eth0 | awk '/inet / {print \$2}' | cut -d/ -f1 | head -n 1) + PROFILE_FILE='/etc/profile.d/00_lxc-details.sh' + + echo 'echo -e \"\"' > \"\$PROFILE_FILE\" + echo 'echo -e \" LXC Container\"' >> \"\$PROFILE_FILE\" + echo 'echo -e \" 🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE \"' >> \"\$PROFILE_FILE\" + echo 'echo \"\"' >> \"\$PROFILE_FILE\" + echo 'echo -e \" 🖥️ OS: \$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"') \"' >> \"\$PROFILE_FILE\" + echo 'echo -e \" 🏠 Hostname: \$(hostname) \"' >> \"\$PROFILE_FILE\" + echo 'echo -e \" 💡 IP Address: \$IP \"' >> \"\$PROFILE_FILE\" + " + fi +} + +function remove_dev_tag() { + container=$1 + current_tags=$(pct config "$container" | awk '/^tags/ {print $2}') + + if [[ "$current_tags" == *"dev"* ]]; then + new_tags=$(echo "$current_tags" | sed 's/,*dev,*//g' | sed 's/^,//' | sed 's/,$//') + + if [[ -z "$new_tags" ]]; then + pct set "$container" -delete tags + else + pct set "$container" -tags "$new_tags" + fi + + echo -e "${GN}[Success]${CL} 'dev' tag removed from ${BL}$container${CL}.\n" + fi +} + +header_info +echo "Searching for containers with 'dev' tag..." +for container in $(pct list | awk '{if(NR>1) print $1}'); do + tags=$(pct config "$container" | awk '/^tags/ {print $2}') + if [[ "$tags" == *"dev"* ]]; then + update_container "$container" + update_motd "$container" + remove_dev_tag "$container" + fi +done + +header_info +echo -e "${GN}The process is complete.${CL}\n" From 0a841a949a10e27f42229e1d86f7e0dd2028bbbb Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 12 Mar 2025 10:16:53 +0100 Subject: [PATCH 17/22] Update switch_from_VED_to_VE.sh --- misc/switch_from_VED_to_VE.sh | 65 +++++++++++++++++------------------ 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/misc/switch_from_VED_to_VE.sh b/misc/switch_from_VED_to_VE.sh index 4562ac0..61d04ba 100644 --- a/misc/switch_from_VED_to_VE.sh +++ b/misc/switch_from_VED_to_VE.sh @@ -19,7 +19,6 @@ function header_info { / /_/ / ___/ __ \| |/_/ __ `__ \/ __ \| |/_/ | / / __/ / / / / / __/ __ \ / /_/ / ___/ __ \| |/_/ __ `__ \/ __ \| |/_/ | / / __/ / ____/ / / /_/ /> < | |/ / /___/ /_/ / / /_/ /_/ / / ____/ / / /_/ /> < | |/ / /___ /_/ /_/ \____/_/|_/_/ /_/ /_/\____/_/|_| |___/_____/_____/ \__/\____/ /_/ /_/ \____/_/|_/_/ /_/ /_/\____/_/|_| |___/_____/ - EOF } @@ -41,8 +40,6 @@ function update_container() { else echo -e "${RD}[Error]${CL} /usr/bin/update not found in container ${BL}$container${CL}.\n" fi - else - echo -e "${BL}[Info]${GN} Skipping ${BL}$container${CL} (not Debian/Ubuntu/Alpine)\n" fi } @@ -53,41 +50,43 @@ function update_motd() { if [[ "$os" == "ubuntu" || "$os" == "debian" ]]; then echo -e "${BL}[Info]${GN} Updating MOTD in ${BL}$container${CL} (OS: ${GN}$os${CL})" - pct exec "$container" -- bash -c " - YW='\033[33m' - GN='\033[1;92m' - CL='\033[m' - TAB=' ' - GATEWAY='🌐' - OS='🖥️' - HOSTNAME='🏠' - INFO='💡' - PROFILE_FILE='/etc/profile.d/00_motd.sh' + pct exec "$container" -- bash -c ' + YW="\033[33m" + GN="\033[1;92m" + CL="\033[m" + TAB=" " + GATEWAY="🌐" + OS="🖥️" + HOSTNAME="🏠" + INFO="💡" + PROFILE_FILE="/etc/profile.d/00_motd.sh" + + echo "echo -e \"\"" > "$PROFILE_FILE" + echo "echo -e \"${TAB}${GATEWAY}${TAB}${YW} Provided by: ${GN}community-scripts ORG ${YW}| GitHub: ${GN}https://github.com/community-scripts/ProxmoxVE${CL}\"" >> "$PROFILE_FILE" + echo "echo \"\"" >> "$PROFILE_FILE" + echo "echo -e \"${TAB}${OS}${TAB}${YW} OS: ${GN}$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: $(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')${CL}\"" >> "$PROFILE_FILE" + echo "echo -e \"${TAB}${HOSTNAME}${TAB}${YW} Hostname: ${GN}$(hostname)${CL}\"" >> "$PROFILE_FILE" + echo "echo -e \"${TAB}${INFO}${TAB}${YW} IP Address: ${GN}$(hostname -I | awk '\''{print $1}'\'')${CL}\"" >> "$PROFILE_FILE" + + chmod -x /etc/update-motd.d/* + ' - echo 'echo -e \"\"' > \"\$PROFILE_FILE\" - echo 'echo -e \"${TAB}\$GATEWAY${TAB}\$YW Provided by: \$GN community-scripts ORG \$YW | GitHub: \$GN https://github.com/community-scripts/ProxmoxVE \$CL\"' >> \"\$PROFILE_FILE\" - echo 'echo \"\"' >> \"\$PROFILE_FILE\" - echo 'echo -e \"${TAB}\$OS${TAB}\$YW OS: \$GN \$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"') \$CL\"' >> \"\$PROFILE_FILE\" - echo 'echo -e \"${TAB}\$HOSTNAME${TAB}\$YW Hostname: \$GN \$(hostname) \$CL\"' >> \"\$PROFILE_FILE\" - echo 'echo -e \"${TAB}\$INFO${TAB}\$YW IP Address: \$GN \$(hostname -I | awk '{print \$1}') \$CL\"' >> \"\$PROFILE_FILE\" - chmod -x /etc/update-motd.d/* - " elif [[ "$os" == "alpine" ]]; then echo -e "${BL}[Info]${GN} Updating MOTD in ${BL}$container${CL} (OS: ${GN}$os${CL})" - pct exec "$container" -- bash -c " - echo \"export TERM='xterm-256color'\" >> /root/.bashrc - IP=\$(ip -4 addr show eth0 | awk '/inet / {print \$2}' | cut -d/ -f1 | head -n 1) - PROFILE_FILE='/etc/profile.d/00_lxc-details.sh' + pct exec "$container" -- bash -c ' + echo "export TERM='\''xterm-256color'\''" >> /root/.bashrc + IP=$(ip -4 addr show eth0 | awk "/inet / {print $2}" | cut -d/ -f1 | head -n 1) + PROFILE_FILE="/etc/profile.d/00_lxc-details.sh" - echo 'echo -e \"\"' > \"\$PROFILE_FILE\" - echo 'echo -e \" LXC Container\"' >> \"\$PROFILE_FILE\" - echo 'echo -e \" 🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE \"' >> \"\$PROFILE_FILE\" - echo 'echo \"\"' >> \"\$PROFILE_FILE\" - echo 'echo -e \" 🖥️ OS: \$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"') \"' >> \"\$PROFILE_FILE\" - echo 'echo -e \" 🏠 Hostname: \$(hostname) \"' >> \"\$PROFILE_FILE\" - echo 'echo -e \" 💡 IP Address: \$IP \"' >> \"\$PROFILE_FILE\" - " + echo "echo -e \"\"" > "$PROFILE_FILE" + echo "echo -e \" LXC Container\"" >> "$PROFILE_FILE" + echo "echo -e \" 🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE \"" >> "$PROFILE_FILE" + echo "echo \"\"" >> "$PROFILE_FILE" + echo "echo -e \" 🖥️ OS: $(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: $(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"') \"" >> "$PROFILE_FILE" + echo "echo -e \" 🏠 Hostname: $(hostname) \"" >> "$PROFILE_FILE" + echo "echo -e \" 💡 IP Address: $IP \"" >> "$PROFILE_FILE" + ' fi } From aa4ff86ccc0d2c7ac84213c5a4e4df5f56d31f54 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 12 Mar 2025 10:25:56 +0100 Subject: [PATCH 18/22] Update switch_from_VED_to_VE.sh --- misc/switch_from_VED_to_VE.sh | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/misc/switch_from_VED_to_VE.sh b/misc/switch_from_VED_to_VE.sh index 61d04ba..47a3a72 100644 --- a/misc/switch_from_VED_to_VE.sh +++ b/misc/switch_from_VED_to_VE.sh @@ -51,30 +51,20 @@ function update_motd() { echo -e "${BL}[Info]${GN} Updating MOTD in ${BL}$container${CL} (OS: ${GN}$os${CL})" pct exec "$container" -- bash -c ' - YW="\033[33m" - GN="\033[1;92m" - CL="\033[m" - TAB=" " - GATEWAY="🌐" - OS="🖥️" - HOSTNAME="🏠" - INFO="💡" PROFILE_FILE="/etc/profile.d/00_motd.sh" - echo "echo -e \"\"" > "$PROFILE_FILE" - echo "echo -e \"${TAB}${GATEWAY}${TAB}${YW} Provided by: ${GN}community-scripts ORG ${YW}| GitHub: ${GN}https://github.com/community-scripts/ProxmoxVE${CL}\"" >> "$PROFILE_FILE" + echo "echo -e \" 🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE \"" >> "$PROFILE_FILE" echo "echo \"\"" >> "$PROFILE_FILE" - echo "echo -e \"${TAB}${OS}${TAB}${YW} OS: ${GN}$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: $(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')${CL}\"" >> "$PROFILE_FILE" - echo "echo -e \"${TAB}${HOSTNAME}${TAB}${YW} Hostname: ${GN}$(hostname)${CL}\"" >> "$PROFILE_FILE" - echo "echo -e \"${TAB}${INFO}${TAB}${YW} IP Address: ${GN}$(hostname -I | awk '\''{print $1}'\'')${CL}\"" >> "$PROFILE_FILE" - + echo "echo -e \" 🖥️ OS: $(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: $(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"') \"" >> "$PROFILE_FILE" + echo "echo -e \" 🏠 Hostname: $(hostname) \"" >> "$PROFILE_FILE" + echo "echo -e \" 💡 IP Address: $(hostname -I | awk '\''{print $1}'\'') \"" >> "$PROFILE_FILE" chmod -x /etc/update-motd.d/* ' elif [[ "$os" == "alpine" ]]; then echo -e "${BL}[Info]${GN} Updating MOTD in ${BL}$container${CL} (OS: ${GN}$os${CL})" - pct exec "$container" -- bash -c ' + pct exec "$container" -- /bin/sh -c ' echo "export TERM='\''xterm-256color'\''" >> /root/.bashrc IP=$(ip -4 addr show eth0 | awk "/inet / {print $2}" | cut -d/ -f1 | head -n 1) PROFILE_FILE="/etc/profile.d/00_lxc-details.sh" From f461f441facb3efc7085ffbd961f08dbe697181f Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 12 Mar 2025 10:31:10 +0100 Subject: [PATCH 19/22] Update switch_from_VED_to_VE.sh --- misc/switch_from_VED_to_VE.sh | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/misc/switch_from_VED_to_VE.sh b/misc/switch_from_VED_to_VE.sh index 47a3a72..d7ba3c2 100644 --- a/misc/switch_from_VED_to_VE.sh +++ b/misc/switch_from_VED_to_VE.sh @@ -50,33 +50,33 @@ function update_motd() { if [[ "$os" == "ubuntu" || "$os" == "debian" ]]; then echo -e "${BL}[Info]${GN} Updating MOTD in ${BL}$container${CL} (OS: ${GN}$os${CL})" - pct exec "$container" -- bash -c ' - PROFILE_FILE="/etc/profile.d/00_motd.sh" - echo "echo -e \"\"" > "$PROFILE_FILE" - echo "echo -e \" 🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE \"" >> "$PROFILE_FILE" - echo "echo \"\"" >> "$PROFILE_FILE" - echo "echo -e \" 🖥️ OS: $(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: $(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"') \"" >> "$PROFILE_FILE" - echo "echo -e \" 🏠 Hostname: $(hostname) \"" >> "$PROFILE_FILE" - echo "echo -e \" 💡 IP Address: $(hostname -I | awk '\''{print $1}'\'') \"" >> "$PROFILE_FILE" + pct exec "$container" -- bash -c " + PROFILE_FILE='/etc/profile.d/00_motd.sh' + echo 'echo -e \"\"' > \"\$PROFILE_FILE\" + echo 'echo -e \"🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE\"' >> \"\$PROFILE_FILE\" + echo 'echo \"\"' >> \"\$PROFILE_FILE\" + echo 'echo -e \"🖥️ OS: \$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')\"' >> \"\$PROFILE_FILE\" + echo 'echo -e \"🏠 Hostname: \$(hostname)\"' >> \"\$PROFILE_FILE\" + echo 'echo -e \"💡 IP Address: \$(hostname -I | awk '\''{print \$1}'\'')\"' >> \"\$PROFILE_FILE\" chmod -x /etc/update-motd.d/* - ' + " elif [[ "$os" == "alpine" ]]; then echo -e "${BL}[Info]${GN} Updating MOTD in ${BL}$container${CL} (OS: ${GN}$os${CL})" - pct exec "$container" -- /bin/sh -c ' - echo "export TERM='\''xterm-256color'\''" >> /root/.bashrc - IP=$(ip -4 addr show eth0 | awk "/inet / {print $2}" | cut -d/ -f1 | head -n 1) - PROFILE_FILE="/etc/profile.d/00_lxc-details.sh" + pct exec "$container" -- /bin/sh -c " + echo 'export TERM=\"xterm-256color\"' >> /root/.bashrc + IP=\$(ip -4 addr show eth0 | awk '/inet / {print \$2}' | cut -d/ -f1 | head -n 1) + PROFILE_FILE='/etc/profile.d/00_lxc-details.sh' - echo "echo -e \"\"" > "$PROFILE_FILE" - echo "echo -e \" LXC Container\"" >> "$PROFILE_FILE" - echo "echo -e \" 🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE \"" >> "$PROFILE_FILE" - echo "echo \"\"" >> "$PROFILE_FILE" - echo "echo -e \" 🖥️ OS: $(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: $(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"') \"" >> "$PROFILE_FILE" - echo "echo -e \" 🏠 Hostname: $(hostname) \"" >> "$PROFILE_FILE" - echo "echo -e \" 💡 IP Address: $IP \"" >> "$PROFILE_FILE" - ' + echo 'echo -e \"\"' > \"\$PROFILE_FILE\" + echo 'echo -e \" LXC Container\"' >> \"\$PROFILE_FILE\" + echo 'echo -e \" 🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE\"' >> \"\$PROFILE_FILE\" + echo 'echo \"\"' >> \"\$PROFILE_FILE\" + echo 'echo -e \" 🖥️ OS: \$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')\"' >> \"\$PROFILE_FILE\" + echo 'echo -e \"🏠 Hostname: \$(hostname)\"' >> \"\$PROFILE_FILE\" + echo 'echo -e \"💡 IP Address: \$IP\"' >> \"\$PROFILE_FILE\" + " fi } From 184c2dd2cf488450552e2f416e30495579deec64 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 12 Mar 2025 10:34:15 +0100 Subject: [PATCH 20/22] Update switch_from_VED_to_VE.sh --- misc/switch_from_VED_to_VE.sh | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/misc/switch_from_VED_to_VE.sh b/misc/switch_from_VED_to_VE.sh index d7ba3c2..7b16977 100644 --- a/misc/switch_from_VED_to_VE.sh +++ b/misc/switch_from_VED_to_VE.sh @@ -47,39 +47,58 @@ function update_motd() { container=$1 os=$(pct config "$container" | awk '/^ostype/ {print $2}') + echo -e "${BL}[Debug]${GN} Processing container: ${BL}$container${CL} (OS: ${GN}$os${CL})" + if [[ "$os" == "ubuntu" || "$os" == "debian" ]]; then - echo -e "${BL}[Info]${GN} Updating MOTD in ${BL}$container${CL} (OS: ${GN}$os${CL})" + echo -e "${BL}[Debug]${GN} Entering Debian/Ubuntu MOTD update for container ${BL}$container${CL}" pct exec "$container" -- bash -c " PROFILE_FILE='/etc/profile.d/00_motd.sh' - echo 'echo -e \"\"' > \"\$PROFILE_FILE\" + echo '[Debug] Creating MOTD file' > /tmp/motd_debug.log + echo 'echo -e \"\"" > \"\$PROFILE_FILE\"' >> /tmp/motd_debug.log echo 'echo -e \"🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE\"' >> \"\$PROFILE_FILE\" - echo 'echo \"\"' >> \"\$PROFILE_FILE\" + echo '[Debug] Writing OS details' >> /tmp/motd_debug.log echo 'echo -e \"🖥️ OS: \$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')\"' >> \"\$PROFILE_FILE\" - echo 'echo -e \"🏠 Hostname: \$(hostname)\"' >> \"\$PROFILE_FILE\" + echo '[Debug] Writing IP details' >> /tmp/motd_debug.log echo 'echo -e \"💡 IP Address: \$(hostname -I | awk '\''{print \$1}'\'')\"' >> \"\$PROFILE_FILE\" chmod -x /etc/update-motd.d/* " + echo -e "${GN}[Debug] Finished Debian/Ubuntu MOTD update for ${BL}$container${CL}" + elif [[ "$os" == "alpine" ]]; then - echo -e "${BL}[Info]${GN} Updating MOTD in ${BL}$container${CL} (OS: ${GN}$os${CL})" + echo -e "${BL}[Debug]${GN} Entering Alpine MOTD update for container ${BL}$container${CL}" pct exec "$container" -- /bin/sh -c " + echo '[Debug] Alpine: Start updating MOTD' > /tmp/motd_debug.log echo 'export TERM=\"xterm-256color\"' >> /root/.bashrc + echo '[Debug] Alpine: Set TERM variable' >> /tmp/motd_debug.log + IP=\$(ip -4 addr show eth0 | awk '/inet / {print \$2}' | cut -d/ -f1 | head -n 1) + echo '[Debug] Alpine: Fetched IP: '\$IP'' >> /tmp/motd_debug.log + PROFILE_FILE='/etc/profile.d/00_lxc-details.sh' + echo '[Debug] Alpine: Writing to profile file' >> /tmp/motd_debug.log echo 'echo -e \"\"' > \"\$PROFILE_FILE\" echo 'echo -e \" LXC Container\"' >> \"\$PROFILE_FILE\" echo 'echo -e \" 🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE\"' >> \"\$PROFILE_FILE\" + echo '[Debug] Alpine: Wrote MOTD header' >> /tmp/motd_debug.log + echo 'echo \"\"' >> \"\$PROFILE_FILE\" echo 'echo -e \" 🖥️ OS: \$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')\"' >> \"\$PROFILE_FILE\" + echo '[Debug] Alpine: Wrote OS details' >> /tmp/motd_debug.log + echo 'echo -e \"🏠 Hostname: \$(hostname)\"' >> \"\$PROFILE_FILE\" echo 'echo -e \"💡 IP Address: \$IP\"' >> \"\$PROFILE_FILE\" + echo '[Debug] Alpine: Wrote hostname & IP' >> /tmp/motd_debug.log " + + echo -e "${GN}[Debug] Finished Alpine MOTD update for ${BL}$container${CL}" fi } + function remove_dev_tag() { container=$1 current_tags=$(pct config "$container" | awk '/^tags/ {print $2}') From 0d741eb363935066ceba3341cab53152f6cd102c Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 12 Mar 2025 11:14:23 +0100 Subject: [PATCH 21/22] Update switch_from_VED_to_VE.sh --- misc/switch_from_VED_to_VE.sh | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/misc/switch_from_VED_to_VE.sh b/misc/switch_from_VED_to_VE.sh index 7b16977..ab0def9 100644 --- a/misc/switch_from_VED_to_VE.sh +++ b/misc/switch_from_VED_to_VE.sh @@ -50,16 +50,14 @@ function update_motd() { echo -e "${BL}[Debug]${GN} Processing container: ${BL}$container${CL} (OS: ${GN}$os${CL})" if [[ "$os" == "ubuntu" || "$os" == "debian" ]]; then - echo -e "${BL}[Debug]${GN} Entering Debian/Ubuntu MOTD update for container ${BL}$container${CL}" + echo -e "${BL}[Debug]${GN} Updating Debian/Ubuntu MOTD in ${BL}$container${CL}" pct exec "$container" -- bash -c " PROFILE_FILE='/etc/profile.d/00_motd.sh' - echo '[Debug] Creating MOTD file' > /tmp/motd_debug.log - echo 'echo -e \"\"" > \"\$PROFILE_FILE\"' >> /tmp/motd_debug.log + echo 'echo -e \"\"' > \"\$PROFILE_FILE\" echo 'echo -e \"🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE\"' >> \"\$PROFILE_FILE\" - echo '[Debug] Writing OS details' >> /tmp/motd_debug.log echo 'echo -e \"🖥️ OS: \$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')\"' >> \"\$PROFILE_FILE\" - echo '[Debug] Writing IP details' >> /tmp/motd_debug.log + echo 'echo -e \"🏠 Hostname: \$(hostname)\"' >> \"\$PROFILE_FILE\" echo 'echo -e \"💡 IP Address: \$(hostname -I | awk '\''{print \$1}'\'')\"' >> \"\$PROFILE_FILE\" chmod -x /etc/update-motd.d/* " @@ -67,7 +65,7 @@ function update_motd() { echo -e "${GN}[Debug] Finished Debian/Ubuntu MOTD update for ${BL}$container${CL}" elif [[ "$os" == "alpine" ]]; then - echo -e "${BL}[Debug]${GN} Entering Alpine MOTD update for container ${BL}$container${CL}" + echo -e "${BL}[Debug]${GN} Updating Alpine MOTD in ${BL}$container${CL}" pct exec "$container" -- /bin/sh -c " echo '[Debug] Alpine: Start updating MOTD' > /tmp/motd_debug.log @@ -83,22 +81,16 @@ function update_motd() { echo 'echo -e \"\"' > \"\$PROFILE_FILE\" echo 'echo -e \" LXC Container\"' >> \"\$PROFILE_FILE\" echo 'echo -e \" 🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE\"' >> \"\$PROFILE_FILE\" - echo '[Debug] Alpine: Wrote MOTD header' >> /tmp/motd_debug.log - - echo 'echo \"\"' >> \"\$PROFILE_FILE\" - echo 'echo -e \" 🖥️ OS: \$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')\"' >> \"\$PROFILE_FILE\" - echo '[Debug] Alpine: Wrote OS details' >> /tmp/motd_debug.log - + echo 'echo -e \"🖥️ OS: \$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')\"' >> \"\$PROFILE_FILE\" echo 'echo -e \"🏠 Hostname: \$(hostname)\"' >> \"\$PROFILE_FILE\" - echo 'echo -e \"💡 IP Address: \$IP\"' >> \"\$PROFILE_FILE\" - echo '[Debug] Alpine: Wrote hostname & IP' >> /tmp/motd_debug.log + echo 'echo -e \"💡 IP Address: '\$IP'\"' >> \"\$PROFILE_FILE\" + echo '[Debug] Alpine: Finished writing MOTD' >> /tmp/motd_debug.log " echo -e "${GN}[Debug] Finished Alpine MOTD update for ${BL}$container${CL}" fi } - function remove_dev_tag() { container=$1 current_tags=$(pct config "$container" | awk '/^tags/ {print $2}') From 37c7b21b99db347aa70f4a156219554f0ca86a0b Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 12 Mar 2025 11:17:33 +0100 Subject: [PATCH 22/22] Update switch_from_VED_to_VE.sh --- misc/switch_from_VED_to_VE.sh | 37 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/misc/switch_from_VED_to_VE.sh b/misc/switch_from_VED_to_VE.sh index ab0def9..8496358 100644 --- a/misc/switch_from_VED_to_VE.sh +++ b/misc/switch_from_VED_to_VE.sh @@ -67,25 +67,30 @@ function update_motd() { elif [[ "$os" == "alpine" ]]; then echo -e "${BL}[Debug]${GN} Updating Alpine MOTD in ${BL}$container${CL}" - pct exec "$container" -- /bin/sh -c " - echo '[Debug] Alpine: Start updating MOTD' > /tmp/motd_debug.log - echo 'export TERM=\"xterm-256color\"' >> /root/.bashrc - echo '[Debug] Alpine: Set TERM variable' >> /tmp/motd_debug.log + pct exec "$container" -- /bin/sh -c ' + echo "[Debug] Alpine: Start updating MOTD" > /tmp/motd_debug.log + echo "export TERM=\"xterm-256color\"" >> /root/.bashrc + echo "[Debug] Alpine: Set TERM variable" >> /tmp/motd_debug.log - IP=\$(ip -4 addr show eth0 | awk '/inet / {print \$2}' | cut -d/ -f1 | head -n 1) - echo '[Debug] Alpine: Fetched IP: '\$IP'' >> /tmp/motd_debug.log + IP=$(ip -4 addr show eth0 | awk "/inet / {print \$2}" | cut -d/ -f1 | head -n 1) + echo "[Debug] Alpine: Fetched IP: $IP" >> /tmp/motd_debug.log - PROFILE_FILE='/etc/profile.d/00_lxc-details.sh' - echo '[Debug] Alpine: Writing to profile file' >> /tmp/motd_debug.log + PROFILE_FILE="/etc/profile.d/00_lxc-details.sh" + echo "[Debug] Alpine: Writing to profile file" >> /tmp/motd_debug.log - echo 'echo -e \"\"' > \"\$PROFILE_FILE\" - echo 'echo -e \" LXC Container\"' >> \"\$PROFILE_FILE\" - echo 'echo -e \" 🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE\"' >> \"\$PROFILE_FILE\" - echo 'echo -e \"🖥️ OS: \$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')\"' >> \"\$PROFILE_FILE\" - echo 'echo -e \"🏠 Hostname: \$(hostname)\"' >> \"\$PROFILE_FILE\" - echo 'echo -e \"💡 IP Address: '\$IP'\"' >> \"\$PROFILE_FILE\" - echo '[Debug] Alpine: Finished writing MOTD' >> /tmp/motd_debug.log - " + echo "echo -e \"\"" > \"$PROFILE_FILE\" + echo "echo -e \" LXC Container\"" >> \"$PROFILE_FILE\" + echo "echo -e \" 🌐 Provided by: community-scripts ORG | GitHub: https://github.com/community-scripts/ProxmoxVE\"" >> \"$PROFILE_FILE\" + echo "[Debug] Alpine: Wrote MOTD header" >> /tmp/motd_debug.log + + echo "echo \"\"" >> \"$PROFILE_FILE\" + echo "echo -e \" 🖥️ OS: $(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: $(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')\"" >> \"$PROFILE_FILE\" + echo "[Debug] Alpine: Wrote OS details" >> /tmp/motd_debug.log + + echo "echo -e \"🏠 Hostname: $(hostname)\"" >> \"$PROFILE_FILE\" + echo "echo -e \"💡 IP Address: $IP\"" >> \"$PROFILE_FILE\" + echo "[Debug] Alpine: Wrote hostname & IP" >> /tmp/motd_debug.log + ' echo -e "${GN}[Debug] Finished Alpine MOTD update for ${BL}$container${CL}" fi