-
Notifications
You must be signed in to change notification settings - Fork 0
/
createSHR.bash
95 lines (68 loc) · 2.55 KB
/
createSHR.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
apt update
mkdir install-tmp
mv createSHR.bash install-tmp
cd install-tmp
combustion-ISO () {
curl -O https://raw.githubusercontent.com/HPPinata/shareVM/proxmox/combustion.bash
local passvar=1; local passvar2=2
while [ "$passvar" != "$passvar2" ]; do echo "VM/SMB password previously unset or input inconsistent."; \
read -sp 'Password: ' passvar
echo
read -sp 'Confirm: ' passvar2
echo
done
linux_password="$(openssl passwd -6 $passvar)"
sed -i "s+HASHchangeME+$linux_password+g" combustion.bash
smb_password="$(iconv -f ASCII -t UTF-16LE <(printf $passvar) | openssl dgst -md4 -provider legacy | awk -F '= ' {'print $2'})"
sed -i "s+SMBchangeME+$smb_password+g" combustion.bash
mkdir -p disk/combustion
mv combustion.bash disk/combustion/script
mkisofs -l -o netshare_combustion.iso -V combustion disk
cp netshare_combustion.iso /var/lib/pve/local-btrfs/template/iso
}
create-TEMPLATE () {
tpID=10001
vmNAME=microos
vmDESC="openSUSE MicroOS base template"
qm create $tpID \
--name $vmNAME --description "$vmDESC" --cores 1 --cpu cputype=host --memory 1024 --balloon 1024 --net0 model=virtio,bridge=vmbr0 --bios ovmf --ostype l26 \
--machine q35 --scsihw virtio-scsi-single --onboot 0 --cdrom none --agent enabled=1 --boot order=virtio0 --efidisk0 local-btrfs:4,efitype=4m,pre-enrolled-keys=1
curl -O https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-kvm-and-xen.qcow2
qm disk import $tpID openSUSE-MicroOS.x86_64-kvm-and-xen.qcow2 local-btrfs
qm set $tpID --virtio0 local-btrfs:$tpID/vm-$tpID-disk-1.raw,cache=writeback,discard=on,iothread=1
qm disk resize $tpID virtio0 25G
qm set $tpID --template 1
}
create-VM () {
create-TEMPLATE
vmID=100
qm clone $tpID $vmID --name netshare --description "NAS Server VM"
qm set $vmID --cores 4 --memory 8192 --balloon 1024 --net0 model=virtio,bridge=vmbr0,macaddr=DE:AD:2B:AD:01:00 --startup order=0,up=60
N=1
cache=( /dev/nvme0n1 /dev/nvme1n1 )
for blk in ${pass[@]}; do
qm set $vmID --virtio$N $blk,discard=on,iothread=1
let N++
done
N=0
drive=$(ls /dev/sd*)
for blk in ${pass[@]}; do
qm set $vmID --scsi$N $blk,discard=on,iothread=1
let N++
done
qm set $vmID --cdrom local-btrfs:iso/netshare_combustion.iso
qm set $vmID --onboot 1
}
cleanup () {
cd .. && rm -rf install-tmp
apt install -y pv
yes | pv -SpeL1 -s 300 > /dev/null
apt remove -y pv && apt autoremove -y
qm shutdown $vmID
qm set $vmID --cdrom none
}
combustion-ISO
create-VM
qm start $vmID
cleanup