Skip to content

Commit 957f7e8

Browse files
authored
Fix disk setup and documentation for Turnkey VMs (#141)
1 parent 4c46e94 commit 957f7e8

File tree

9 files changed

+82
-44
lines changed

9 files changed

+82
-44
lines changed

frontend/src/app/scripts/_components/ScriptAccordion.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,22 @@ export default function ScriptAccordion({
2626
undefined,
2727
);
2828
const linkRefs = useRef<{ [key: string]: HTMLAnchorElement | null }>({});
29-
29+
3030
const handleAccordionChange = (value: string | undefined) => {
3131
setExpandedItem(value);
3232
};
3333

3434
const handleSelected = useCallback(
35-
(title: string) => {
36-
setSelectedScript(title);
35+
(slug: string) => {
36+
setSelectedScript(slug);
3737
},
3838
[setSelectedScript],
3939
);
4040

4141
useEffect(() => {
4242
if (selectedScript) {
4343
const category = items.find((category) =>
44-
category.scripts.some((script) => script.name === selectedScript),
44+
category.scripts.some((script) => script.slug === selectedScript),
4545
);
4646
if (category) {
4747
setExpandedItem(category.name);
@@ -89,17 +89,17 @@ export default function ScriptAccordion({
8989
<Link
9090
href={{
9191
pathname: "/scripts",
92-
query: { id: script.name },
92+
query: { id: script.slug },
9393
}}
9494
prefetch={false}
9595
className={`flex cursor-pointer items-center justify-between gap-1 px-1 py-1 text-muted-foreground hover:rounded-lg hover:bg-accent/60 hover:dark:bg-accent/20 ${
96-
selectedScript === script.name
96+
selectedScript === script.slug
9797
? "rounded-lg bg-accent font-semibold dark:bg-accent/30 dark:text-white"
9898
: ""
9999
}`}
100-
onClick={() => handleSelected(script.name)}
100+
onClick={() => handleSelected(script.slug)}
101101
ref={(el) => {
102-
linkRefs.current[script.name] = el;
102+
linkRefs.current[script.slug] = el;
103103
}}
104104
>
105105
<div className="flex items-center">

frontend/src/app/scripts/_components/ScriptInfoBlocks.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function LatestScripts({ items }: { items: Category[] }) {
8585
<div className="min-w flex w-full flex-row flex-wrap gap-4">
8686
{latestScripts.slice(startIndex, endIndex).map((script) => (
8787
<Card
88-
key={script.name}
88+
key={script.slug}
8989
className="min-w-[250px] flex-1 flex-grow bg-accent/30"
9090
>
9191
<CardHeader>
@@ -121,7 +121,7 @@ export function LatestScripts({ items }: { items: Category[] }) {
121121
<Link
122122
href={{
123123
pathname: "/scripts",
124-
query: { id: script.name },
124+
query: { id: script.slug },
125125
}}
126126
>
127127
View Script
@@ -153,7 +153,7 @@ export function MostViewedScripts({ items }: { items: Category[] }) {
153153
<div className="min-w flex w-full flex-row flex-wrap gap-4">
154154
{mostViewedScripts.map((script) => (
155155
<Card
156-
key={script.name}
156+
key={script.slug}
157157
className="min-w-[250px] flex-1 flex-grow bg-accent/30"
158158
>
159159
<CardHeader>
@@ -189,7 +189,7 @@ export function MostViewedScripts({ items }: { items: Category[] }) {
189189
<Link
190190
href={{
191191
pathname: "/scripts",
192-
query: { id: script.name },
192+
query: { id: script.slug },
193193
}}
194194
prefetch={false}
195195
>

frontend/src/app/scripts/page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
export const dynamic = "force-static";
44

55
import ScriptItem from "@/app/scripts/_components/ScriptItem";
6+
import { fetchCategories } from "@/lib/data";
67
import { Category, Script } from "@/lib/types";
78
import { Loader2 } from "lucide-react";
8-
import { Suspense, useEffect, useState } from "react";
9-
import Sidebar from "./_components/Sidebar";
109
import { useQueryState } from "nuqs";
10+
import { Suspense, useEffect, useState } from "react";
1111
import {
1212
LatestScripts,
1313
MostViewedScripts,
1414
} from "./_components/ScriptInfoBlocks";
15-
import { fetchCategories } from "@/lib/data";
15+
import Sidebar from "./_components/Sidebar";
1616

1717
function ScriptContent() {
1818
const [selectedScript, setSelectedScript] = useQueryState("id");
@@ -24,7 +24,7 @@ function ScriptContent() {
2424
const script = links
2525
.map((category) => category.scripts)
2626
.flat()
27-
.find((script) => script.name === selectedScript);
27+
.find((script) => script.slug === selectedScript);
2828
setItem(script);
2929
}
3030
}, [selectedScript, links]);
@@ -76,4 +76,4 @@ export default function Page() {
7676
<ScriptContent />
7777
</Suspense>
7878
);
79-
}
79+
}

frontend/src/components/CommandMenu.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ export default function CommandMenu() {
9292
>
9393
{category.scripts.map((script) => (
9494
<CommandItem
95-
key={`script:${script.name}`}
96-
value={script.name}
95+
key={`script:${script.slug}`}
96+
value={script.slug}
9797
onSelect={() => {
9898
setOpen(false);
99-
router.push(`/scripts?id=${script.name}`);
99+
router.push(`/scripts?id=${script.slug}`);
100100
}}
101101
>
102102
<div className="flex gap-2" onClick={() => setOpen(false)}>

json/jellyfin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"documentation": null,
1313
"website": null,
1414
"logo": "https://github.com/home-assistant/brands/blob/master/core_integrations/jellyfin/icon.png?raw=true",
15-
"description": null,
15+
"description": "Jellyfin is a free and open-source media server and suite of multimedia applications designed to organize, manage, and share digital media files to networked devices.",
1616
"install_methods": [
1717
{
1818
"type": "default",

json/nextcloud-vm.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "Nextcloud",
3+
"slug": "nextcloud-vm",
4+
"categories": [
5+
12
6+
],
7+
"date_created": "2023-11-14",
8+
"type": "vm",
9+
"updateable": false,
10+
"privileged": false,
11+
"interface_port": "80",
12+
"documentation": null,
13+
"website": "https://www.turnkeylinux.org/nextcloud",
14+
"logo": "https://raw.githubusercontent.com/loganmarchione/homelab-svg-assets/main/assets/nextcloud.svg",
15+
"description": "TurnKey Nextcloud is an open-source file sharing server and collaboration platform that can store your personal content, like documents and pictures, in a centralized location.",
16+
"install_methods": [
17+
{
18+
"type": "default",
19+
"script": "vm/nextcloud-vm.sh",
20+
"resources": {
21+
"cpu": "2",
22+
"ram": "2048",
23+
"hdd": "12G",
24+
"os": "debian",
25+
"version": 12
26+
}
27+
}
28+
],
29+
"default_credentials": {
30+
"username": "admin",
31+
"password": null
32+
},
33+
"notes": []
34+
}

json/owncloud-vm.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
"cpu": "2",
2222
"ram": "2048",
2323
"hdd": "12G",
24-
"os": null,
25-
"version": null
24+
"os": "debian",
25+
"version": 12
2626
}
2727
}
2828
],
2929
"default_credentials": {
30-
"username": null,
30+
"username": "admin",
3131
"password": null
3232
},
3333
"notes": []

vm/nextcloud-vm.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ BFR="\\r\\033[K"
3232
HOLD="-"
3333
CM="${GN}${CL}"
3434
CROSS="${RD}${CL}"
35-
THIN="discard=on,ssd=1,"
35+
THIN="discard=on,ssd=1"
3636
set -e
3737
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
3838
trap cleanup EXIT
@@ -207,7 +207,7 @@ function advanced_settings() {
207207
exit-script
208208
fi
209209

210-
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 $HN --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
210+
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 turnkey-nextcloud-vm --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
211211
if [ -z $VM_NAME ]; then
212212
HN="$HN"
213213
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
@@ -393,7 +393,7 @@ btrfs)
393393
THIN=""
394394
;;
395395
esac
396-
for i in {0,1}; do
396+
for i in {0,1,2}; do
397397
disk="DISK$i"
398398
eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-}
399399
eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk}
@@ -403,11 +403,13 @@ msg_info "Creating a $NAME"
403403
qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios seabios${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \
404404
-name $HN -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
405405
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
406+
pvesm alloc $STORAGE $VMID $DISK1 12G 1>&/dev/null
406407
qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
407408
qm set $VMID \
408409
-efidisk0 ${DISK0_REF}${FORMAT} \
409-
-scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=12G \
410-
-boot order=scsi0 \
410+
-scsi0 ${DISK1_REF},${DISK_CACHE}${THIN} \
411+
-scsi1 ${DISK2_REF},${DISK_CACHE}${THIN} \
412+
-boot order='scsi1;scsi0' \
411413
-description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo-81x112.png'/></a>
412414
413415
# $NAME

vm/owncloud-vm.sh

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ header_info
1919
echo -e "\n Loading..."
2020
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
2121
NEXTID=$(pvesh get /cluster/nextid)
22-
22+
NAME="TurnKey ownCloud VM"
2323
YW=$(echo "\033[33m")
2424
BL=$(echo "\033[36m")
2525
HA=$(echo "\033[1;34m")
@@ -32,7 +32,7 @@ BFR="\\r\\033[K"
3232
HOLD="-"
3333
CM="${GN}${CL}"
3434
CROSS="${RD}${CL}"
35-
THIN="discard=on,ssd=1,"
35+
THIN="discard=on,ssd=1"
3636
set -e
3737
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
3838
trap cleanup EXIT
@@ -59,7 +59,7 @@ function cleanup() {
5959

6060
TEMP_DIR=$(mktemp -d)
6161
pushd $TEMP_DIR >/dev/null
62-
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "TurnKey-ownCloud VM" --yesno "This will create a New TurnKey-ownCloud VM. Proceed?" 10 58; then
62+
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "$NAME" --yesno "This will create a New $NAME. Proceed?" 10 58; then
6363
:
6464
else
6565
header_info && echo -e "⚠ User exited script \n" && exit
@@ -154,7 +154,7 @@ function default_settings() {
154154
echo -e "${DGN}Using VLAN: ${BGN}Default${CL}"
155155
echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}"
156156
echo -e "${DGN}Start VM when completed: ${BGN}no${CL}"
157-
echo -e "${BL}Creating a TurnKey ownCloud VM using the above default settings${CL}"
157+
echo -e "${BL}Creating a $NAME using the above default settings${CL}"
158158
}
159159

160160
function advanced_settings() {
@@ -313,8 +313,8 @@ function advanced_settings() {
313313
START_VM="no"
314314
fi
315315

316-
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create a TurnKey ownCloud VM?" --no-button Do-Over 10 58); then
317-
echo -e "${RD}Creating a TurnKey ownCloud VM using the above advanced settings${CL}"
316+
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create a $NAME?" --no-button Do-Over 10 58); then
317+
echo -e "${RD}Creating a $NAME using the above advanced settings${CL}"
318318
else
319319
header_info
320320
echo -e "${RD}Using Advanced Settings${CL}"
@@ -368,7 +368,7 @@ else
368368
fi
369369
msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location."
370370
msg_ok "Virtual Machine ID is ${CL}${BL}$VMID${CL}."
371-
msg_info "Retrieving the URL for the TurnKey ownCloud ISO Disk Image"
371+
msg_info "Retrieving the URL for the $NAME Disk Image"
372372
URL=http://mirror.turnkeylinux.org/turnkeylinux/images/iso/turnkey-owncloud-18.0-bookworm-amd64.iso
373373
sleep 2
374374
msg_ok "${CL}${BL}${URL}${CL}"
@@ -393,31 +393,33 @@ btrfs)
393393
THIN=""
394394
;;
395395
esac
396-
for i in {0,1}; do
396+
for i in {0,1,2}; do
397397
disk="DISK$i"
398398
eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-}
399399
eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk}
400400
done
401401

402-
msg_info "Creating a TurnKey ownCloud VM"
402+
msg_info "Creating a $NAME"
403403
qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios seabios${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \
404404
-name $HN -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
405405
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
406+
pvesm alloc $STORAGE $VMID $DISK1 12G 1>&/dev/null
406407
qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
407408
qm set $VMID \
408409
-efidisk0 ${DISK0_REF}${FORMAT} \
409-
-scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=12G \
410-
-boot order=scsi0 \
410+
-scsi0 ${DISK1_REF},${DISK_CACHE}${THIN} \
411+
-scsi1 ${DISK2_REF},${DISK_CACHE}${THIN} \
412+
-boot order='scsi1;scsi0' \
411413
-description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo-81x112.png'/></a>
412414
413-
# TurnKey ownCloud VM
415+
# $NAME
414416
415417
<a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/&#x2615;-Buy me a coffee-blue' /></a>
416418
</div>" >/dev/null
417-
msg_ok "Created a TurnKey ownCloud VM ${CL}${BL}(${HN})"
419+
msg_ok "Created a $NAME ${CL}${BL}(${HN})"
418420
if [ "$START_VM" == "yes" ]; then
419-
msg_info "Starting TurnKey ownCloud VM"
421+
msg_info "Starting $NAME"
420422
qm start $VMID
421-
msg_ok "Started TurnKey ownCloud VM"
423+
msg_ok "Started $NAME"
422424
fi
423425
msg_ok "Completed Successfully!\n"

0 commit comments

Comments
 (0)