2023-06-12 17:12:21 +00:00
|
|
|
#!/bin/bash
|
|
|
|
WIN_DISK="${WIN_DISK}";
|
|
|
|
workingDir="$(pwd)";
|
|
|
|
overlayDir="$(mktemp -d)";
|
|
|
|
pushd "${BASH_SOURCE%/*}" > /dev/null;
|
|
|
|
. "./.env" > /dev/null 2>&1;
|
|
|
|
. "./lib/choose-disk.sh";
|
|
|
|
|
|
|
|
if [ ! -z "$WIN11_IMAGE_PATH" ]
|
|
|
|
then
|
|
|
|
WIN11_IMAGE_PATH="$(bash -c "realpath $WIN11_IMAGE_PATH")";
|
|
|
|
fi;
|
|
|
|
|
|
|
|
if [ ! -f "$WIN11_IMAGE_PATH" ]
|
|
|
|
then
|
|
|
|
if [ ! -f "./.env" ]
|
|
|
|
then
|
|
|
|
cp .env.template .env;
|
|
|
|
fi;
|
|
|
|
|
|
|
|
echo "Please specify the path to the Windows 11 ISO image in your .env file located at:";
|
|
|
|
realpath --relative-to "$workingDir" "$(realpath .env)";
|
|
|
|
else
|
2023-06-21 20:14:41 +00:00
|
|
|
buildDir="build";
|
2023-06-12 17:12:21 +00:00
|
|
|
mountPath="/media/wininstall";
|
|
|
|
bootPath="/media/boot";
|
|
|
|
dataPath="/media/data";
|
|
|
|
setupLabel="winiso";
|
2023-07-27 21:16:32 +00:00
|
|
|
intelNetworkArchive="./$buildDir/intelNetwork.zip";
|
2023-07-27 21:09:22 +00:00
|
|
|
marvellNetworkArchive="./$buildDir/marvellNetwork.zip";
|
2023-09-27 10:06:24 +00:00
|
|
|
gitArchive="$(realpath -m "./$buildDir/git.msi")";
|
2023-06-21 20:14:41 +00:00
|
|
|
pwshArchive="./$buildDir/pwsh.zip";
|
2023-06-12 17:12:21 +00:00
|
|
|
editionField="Edition ID";
|
|
|
|
|
2023-06-21 20:14:41 +00:00
|
|
|
mkdir -p "$buildDir";
|
2023-06-12 17:12:21 +00:00
|
|
|
cp -r winfs/* "$overlayDir";
|
|
|
|
|
2023-07-27 21:16:32 +00:00
|
|
|
if [ ! -f "$intelNetworkArchive" ]
|
|
|
|
then
|
|
|
|
curl -L "https://dlcdnets.asus.com/pub/ASUS/mb/04LAN/DRV_LAN_Intel_I211_UWD_TP_W10_64_VER12151841_20190306R.zip?model=ROG%20ZENITH%20EXTREME%20ALPHA" -o "$intelNetworkArchive";
|
|
|
|
fi;
|
|
|
|
|
2023-07-27 21:09:22 +00:00
|
|
|
if [ ! -f "$marvellNetworkArchive" ]
|
2023-07-27 20:08:05 +00:00
|
|
|
then
|
2023-07-27 21:19:11 +00:00
|
|
|
curl -L "https://dlcdnets.asus.com/pub/ASUS/mb/04LAN/DRV_LAN_Marvell_TP_TSD_W11_64_V3130_20211118R.zip?model=ROG%20ZENITH%20EXTREME%20ALPHA" -o "$marvellNetworkArchive";
|
2023-07-27 20:08:05 +00:00
|
|
|
fi;
|
|
|
|
|
2023-06-22 13:20:02 +00:00
|
|
|
if [ ! -f "$gitArchive" ]
|
|
|
|
then
|
|
|
|
curl -L "https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.1/PortableGit-2.41.0-64-bit.7z.exe" -o "$gitArchive";
|
|
|
|
fi;
|
|
|
|
|
2023-06-12 17:12:21 +00:00
|
|
|
if [ ! -f "$pwshArchive" ]
|
|
|
|
then
|
2023-09-27 10:06:24 +00:00
|
|
|
curl -L "https://github.com/PowerShell/PowerShell/releases/download/v7.3.7/PowerShell-7.3.7-win-x64.zip" -o "$pwshArchive";
|
2023-06-12 17:12:21 +00:00
|
|
|
fi;
|
|
|
|
|
2023-07-27 20:16:41 +00:00
|
|
|
mkdir -p "$overlayDir/drivers";
|
2023-07-27 21:16:32 +00:00
|
|
|
tempDir="$(mktemp -d)";
|
|
|
|
unzip "$intelNetworkArchive" -d "$tempDir";
|
2023-07-27 21:22:44 +00:00
|
|
|
cp -r "$tempDir" "$overlayDir/drivers/IntelNetwork";
|
2023-07-27 21:16:32 +00:00
|
|
|
rm -rf "$tempDir";
|
|
|
|
|
2023-07-27 21:14:05 +00:00
|
|
|
tempDir="$(mktemp -d)";
|
|
|
|
unzip "$marvellNetworkArchive" -d "$tempDir";
|
|
|
|
cp -r "$tempDir/x64" "$overlayDir/drivers/MarvellNetwork";
|
|
|
|
rm -rf "$tempDir";
|
2023-07-27 20:08:05 +00:00
|
|
|
|
2023-06-22 13:34:27 +00:00
|
|
|
mkdir -p "$overlayDir/git";
|
|
|
|
pushd "$overlayDir/git" > /dev/null;
|
|
|
|
7z x "$gitArchive";
|
|
|
|
popd > /dev/null;
|
|
|
|
|
2023-06-12 17:12:21 +00:00
|
|
|
unzip "$pwshArchive" -d "$overlayDir/PowerShell";
|
|
|
|
|
|
|
|
sudo mount --mkdir "$WIN11_IMAGE_PATH" "$mountPath";
|
2023-06-21 20:14:41 +00:00
|
|
|
isoFile="./$buildDir/win.iso";
|
2023-06-12 17:12:21 +00:00
|
|
|
mkdir -p "$(dirname "$isoFile")";
|
|
|
|
mkwinpeimg --iso --arch amd64 --overlay "$overlayDir" --windows-dir "$mountPath" "$isoFile";
|
|
|
|
sudo umount "$mountPath";
|
2023-07-30 10:54:44 +00:00
|
|
|
rm -rf "$overlayDir";
|
2023-06-12 17:12:21 +00:00
|
|
|
|
|
|
|
if [ ! -b "$WIN_DISK" ]
|
|
|
|
then
|
|
|
|
chooseDisk WIN_DISK;
|
|
|
|
fi;
|
|
|
|
|
2023-07-27 21:26:28 +00:00
|
|
|
sudo shred -vfzn 0 -s 512M "$WIN_DISK";
|
2023-07-09 22:03:05 +00:00
|
|
|
|
2023-06-12 17:12:21 +00:00
|
|
|
{
|
|
|
|
echo "o";
|
|
|
|
|
|
|
|
echo "n";
|
|
|
|
echo "";
|
|
|
|
echo "";
|
|
|
|
echo "";
|
|
|
|
echo "+2G";
|
|
|
|
echo "y";
|
|
|
|
echo "t";
|
|
|
|
echo "c";
|
|
|
|
echo "a";
|
|
|
|
echo "";
|
|
|
|
|
|
|
|
echo "n";
|
|
|
|
echo "";
|
|
|
|
echo "";
|
|
|
|
echo "";
|
|
|
|
echo "";
|
|
|
|
echo "y";
|
|
|
|
echo "t";
|
|
|
|
echo "";
|
|
|
|
echo "7";
|
|
|
|
|
|
|
|
echo "w";
|
|
|
|
} | sudo fdisk "$WIN_DISK";
|
|
|
|
|
|
|
|
while true
|
|
|
|
do
|
|
|
|
disks=($(bash -c "echo $WIN_DISK*"));
|
|
|
|
[ "${#disks[@]}" -ge 3 ] && break;
|
|
|
|
done;
|
|
|
|
|
|
|
|
bootDisk="${disks[1]}";
|
|
|
|
dataDisk="${disks[2]}";
|
|
|
|
sudo mkfs.fat -F 32 -n "BOOT" "$bootDisk";
|
|
|
|
sudo mkfs.ntfs -fFL "$setupLabel" "$dataDisk";
|
|
|
|
sudo mount --mkdir "$bootDisk" "$bootPath";
|
|
|
|
sudo mount --mkdir "$dataDisk" "$dataPath";
|
|
|
|
sudo mount --mkdir "$isoFile" "$mountPath";
|
|
|
|
sudo cp -r "$mountPath"/* "$bootPath";
|
|
|
|
sudo umount "$mountPath";
|
|
|
|
|
|
|
|
sudo mount "$WIN11_IMAGE_PATH" "$mountPath";
|
|
|
|
sudo cp -r "$mountPath"/* "$dataPath";
|
2023-06-22 12:50:29 +00:00
|
|
|
sudo cp Autounattend.template.xml "$dataPath";
|
2023-06-12 17:12:21 +00:00
|
|
|
sudo cp -r "$mountPath/efi" "$bootPath";
|
|
|
|
wimFile="$dataPath/sources/install.wim";
|
|
|
|
|
|
|
|
while [ ! "$(echo $(wiminfo "$wimFile" 1 | grep "^$editionField" | cut -d ":" -f2))" == "Professional" ]
|
|
|
|
do
|
|
|
|
sudo wimdelete --soft "$wimFile" 1;
|
|
|
|
done;
|
|
|
|
|
|
|
|
while wiminfo "$wimFile" 2 2>&1 > /dev/null
|
|
|
|
do
|
|
|
|
sudo wimdelete --soft "$wimFile" 2;
|
|
|
|
done;
|
|
|
|
|
2023-07-09 22:00:51 +00:00
|
|
|
sudo -- bash -c "umount -vf '$mountPath'; umount -vf '$bootPath'; umount -vf '$dataPath'; rm -rf '$mountPath' '$bootPath' '$dataPath';";
|
2023-06-12 17:12:21 +00:00
|
|
|
fi;
|
|
|
|
|
|
|
|
popd > /dev/null;
|