Automatische Installation

Aus Xinux Wiki
Version vom 26. Oktober 2021, 12:35 Uhr von Mario.zimmermann (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „<syntaxhighlight lang=bash> #!/bin/bash Basepath=$PWD GNS3_IMAGE_PATH=$(python3 $Basepath/get_gns3_path.py 2>&1)…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen
#!/bin/bash

Basepath=$PWD
GNS3_IMAGE_PATH=$(python3 $Basepath/get_gns3_path.py 2>&1)                                                                                                                    


function donwload () {
    if [ -f "$GNS3_IMAGE_PATH/OVMF_CODE.fd" ]; then
        echo "Die Datei OVMF_CODE.fd existiert bereits"
    else
        wget -O $GNS3_IMAGE_PATH/OVMF_CODE.fd https://raw.githubusercontent.com/kholia/OSX-KVM/master/OVMF_CODE.fd 
    fi
    if [ -f "$GNS3_IMAGE_PATH/OpenCore.qcow2" ]; then
        echo "Die Datei OVMF_CODE.fd existiert bereits"
    else
        wget -O $GNS3_IMAGE_PATH/OpenCore.qcow2 https://raw.githubusercontent.com/kholia/OSX-KVM/master/OpenCore/OpenCore.qcow2
    fi

    git clone https://github.com/kholia/OSX-KVM.git
}

function prepare () {
    cd OSX-KVM

    if [ -f "BaseSystem.dmg" ]; then
        
        echo "Die Datei \"BaseSystem.dmg\" exisitiert schon"
        
        else
        python3 fetch-macOS-v2.py

    fi
    if [ -f "BaseSystem.img" ]; then
        
        echo "Die Datei \"BaseSystem.img\" exisitiert schon"
    else
        qemu-img convert BaseSystem.dmg -O raw BaseSystem.img
        
    fi

    qemu-img create -f qcow2 mac_hdd_ng.img 128G
}


function get_checksum () {
    for Name in $1 $2 $3
        do
        echo $GNS3_IMAGE_PATH$Name
            if [ -f "$GNS3_IMAGE_PATH$Name" ]; then
                Name=${Name##*/}
                md5sum=$(md5sum $GNS3_IMAGE_PATH$Name)
                echo $Name
                if [ $Name == $1 ]; then
                    OVMF_CODE=("$Name $md5sum")
                fi
                if [ $Name == $2 ]; then
                    OpenCore=("$Name $md5sum")
                fi
                if [ $Name == $3 ]; then
                    MacOS=("$Name $md5sum")
                fi
                echo $NameChecksum

            fi
            
            
    done
}



sudo apt-get install qemu uml-utilities virt-manager git \
    wget libguestfs-tools p7zip-full make -y

sudo usermod -aG kvm $(whoami)
donwload
prepare
./OpenCore-Boot.sh

mv mac_hdd_ng.img MacOS.img
mv -v  MacOS.img $GNS3_IMAGE_PATH
sleep 30
if [ -f "$GNS3_IMAGE_PATH/MacOS.img" ]; then
    get_checksum OVMF_CODE.fd OpenCore.qcow2 MacOS.img
fi
 

echo "$OVMF_CODE" 
echo "$OpenCore" 
echo "$MacOS"

python3 $Basepath/replace_arguments.py ["$OVMF_CODE", "$OpenCore", "$MacOS"]
sleep 5
cd ..
gns3 Macosx.gns3a