Compare commits
14 commits
03077276b4
...
24e557e95c
Author | SHA1 | Date | |
---|---|---|---|
Manuel Thalmann | 24e557e95c | ||
Manuel Thalmann | e6ea44a216 | ||
Manuel Thalmann | 84177ce47d | ||
Manuel Thalmann | 7e5915cab0 | ||
Manuel Thalmann | 15742f29e1 | ||
Manuel Thalmann | ab28605732 | ||
Manuel Thalmann | 8a445f0f71 | ||
Manuel Thalmann | 1e55435098 | ||
Manuel Thalmann | 1c9bedc9d1 | ||
Manuel Thalmann | 31410f3095 | ||
Manuel Thalmann | 78128558c9 | ||
Manuel Thalmann | d56482fbdd | ||
Manuel Thalmann | d1d686f089 | ||
Manuel Thalmann | 9b8ebf5e2d |
197
deploy.fish
Normal file
197
deploy.fish
Normal file
|
@ -0,0 +1,197 @@
|
|||
#!/bin/env fish
|
||||
begin
|
||||
set -l dir (status dirname)
|
||||
source "$dir/lib/choose-disk.fish"
|
||||
|
||||
set -q WIN11_IMAGE_PATH
|
||||
or begin
|
||||
echo "Please specify the Windows 11 ISO in the `WIN11_IMAGE_PATH` variable."
|
||||
exit 1
|
||||
end
|
||||
|
||||
set -l setupLabel "winiso-valhalla"
|
||||
set -l buildDir "$(status dirname)/build"
|
||||
set -l cacheDir ~/.cache/winiso-valhalla
|
||||
set -l isoFile "$buildDir/winiso-valhalla.iso"
|
||||
set -l winpe "$cacheDir/winpe.iso"
|
||||
set -l winPath "/media/win"
|
||||
set -l winpePath "/media/winpe"
|
||||
set -l valhallaPath "/media/winiso-valhalla"
|
||||
set -l bootPath "/media/boot"
|
||||
set -l dataPath "/media/data"
|
||||
set -l winpeOverlay (mktemp -d)
|
||||
set -l winOverlay (mktemp -d)
|
||||
set -l upperDir (mktemp -d)
|
||||
set -l workDir (mktemp -d)
|
||||
set -l editionField "Edition ID"
|
||||
set -l wimFile "sources/install.wim"
|
||||
|
||||
set -l files
|
||||
|
||||
set -l fileDefinitions \
|
||||
drivers/network/intel \
|
||||
"https://dlcdnets.asus.com/pub/ASUS/mb/04LAN/DRV_LAN_Intel_I211_UWD_TP_W10_64_VER12151841_20190306R.zip?model=ROG%20ZENITH%20EXTREME%20ALPHA" \
|
||||
zip \
|
||||
. \
|
||||
\
|
||||
drivers/network/marvell \
|
||||
"https://dlcdnets.asus.com/pub/ASUS/mb/04LAN/DRV_LAN_Marvell_TP_TSD_W11_64_V3130_20211118R.zip?model=ROG%20ZENITH%20EXTREME%20ALPHA" \
|
||||
zip \
|
||||
./x64 \
|
||||
\
|
||||
software/git \
|
||||
"https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.1/PortableGit-2.41.0-64-bit.7z.exe" \
|
||||
exe \
|
||||
. \
|
||||
\
|
||||
software/pwsh \
|
||||
"https://github.com/PowerShell/PowerShell/releases/download/v7.3.7/PowerShell-7.3.7-win-x64.zip" \
|
||||
zip \
|
||||
.
|
||||
|
||||
for i in (seq 1 4 (count $fileDefinitions))
|
||||
set -l entry $fileDefinitions[$i.."$(math "$i" + 3)"]
|
||||
set -l name "$entry[1]"
|
||||
set -l url "$entry[2]"
|
||||
set -l type "$entry[3]"
|
||||
set -l dir "$entry[4]"
|
||||
set -l file "$cacheDir/$name.$type"
|
||||
set -l target "$winpeOverlay/$name"
|
||||
|
||||
set -a files \
|
||||
"$file" \
|
||||
"$dir" \
|
||||
"$name"
|
||||
|
||||
mkdir -p (dirname "$file")
|
||||
|
||||
if [ ! -f "$file" ]
|
||||
curl -L "$url" -o "$file"
|
||||
end
|
||||
|
||||
begin
|
||||
set -l tempDir (mktemp -d)
|
||||
|
||||
switch $type
|
||||
case zip
|
||||
unzip "$file" -d "$tempDir"
|
||||
case exe
|
||||
pushd "$tempDir" > /dev/null
|
||||
7z x "$file"
|
||||
popd > /dev/null
|
||||
end
|
||||
|
||||
mkdir -p (dirname "$target")
|
||||
cp -r "$tempDir/$dir" "$target"
|
||||
rm -rf "$tempDir"
|
||||
end
|
||||
end
|
||||
|
||||
set -l intel $files[1..3]
|
||||
set -l marvell $files[4..6]
|
||||
set -l git $files[7..9]
|
||||
set -l pwsh $files[10..12]
|
||||
|
||||
cp -r "$dir/winfs"/* "$winpeOverlay"
|
||||
|
||||
mkdir -p "$(dirname "$winpe")"
|
||||
sudo mount --mkdir "$WIN11_IMAGE_PATH" "$winPath"
|
||||
mkwinpeimg --iso --arch amd64 --overlay "$winpeOverlay" --windows-dir "$winPath" "$winpe"
|
||||
rm -rf "$winpeOverlay"
|
||||
sudo mount --mkdir "$winpe" "$winpePath"
|
||||
|
||||
begin
|
||||
echo "$wimFile"
|
||||
end | rsync --files-from=/dev/stdin "$winPath" "$winOverlay"
|
||||
|
||||
begin
|
||||
set -l wimFile "$winOverlay/$wimFile"
|
||||
|
||||
while [ ! (wiminfo "$wimFile" 1 | grep "^$editionField" | cut -d ":" -f2 | string trim) = "Professional" ]
|
||||
sudo wimdelete --soft "$wimFile" 1
|
||||
end
|
||||
|
||||
while wiminfo "$wimFile" 2 &> /dev/null
|
||||
sudo wimdelete --soft "$wimFile" 2
|
||||
end
|
||||
end
|
||||
|
||||
sudo mount --mkdir -t overlay overlay -o lowerdir="$winOverlay":"$winpePath":"$winPath",upperdir="$upperDir",workdir="$workDir" "$valhallaPath"
|
||||
|
||||
if [ -z "$_flag_usb" ]
|
||||
mkisofs \
|
||||
-V "$setupLabel" \
|
||||
-no-emul-boot \
|
||||
-b "efi/microsoft/boot/efisys.bin" \
|
||||
-iso-level 4 \
|
||||
-udf \
|
||||
-joliet \
|
||||
-disable-deep-relocation \
|
||||
-omit-version-number \
|
||||
-relaxed-filenames \
|
||||
-output "$isoFile" \
|
||||
"$valhallaPath"
|
||||
else
|
||||
if [ ! -b "$WIN_DISK" ]
|
||||
chooseDisk WIN_DISK
|
||||
end
|
||||
|
||||
sudo shred -vfzn 0 -s 512 "$WIN_DISK"
|
||||
|
||||
begin
|
||||
printf %s\n \
|
||||
o \
|
||||
n \
|
||||
"" \
|
||||
"" \
|
||||
"" \
|
||||
+2G \
|
||||
y \
|
||||
t \
|
||||
c \
|
||||
a \
|
||||
"" \
|
||||
\
|
||||
n \
|
||||
"" \
|
||||
"" \
|
||||
"" \
|
||||
"" \
|
||||
y \
|
||||
t \
|
||||
"" \
|
||||
7 \
|
||||
\
|
||||
w
|
||||
end | sudo fdisk "$WIN_DISK"
|
||||
|
||||
begin
|
||||
set -l disks
|
||||
|
||||
while true
|
||||
set disks (string split -n " " (bash -c "echo $WIN_DISK*"))
|
||||
[ (count $disks) -ge 3 ] && break
|
||||
end
|
||||
|
||||
set -l bootDisk "$disks[2]"
|
||||
set -l dataDisk "$disks[3]"
|
||||
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 cp -r "$winpePath"/* "$bootPath"
|
||||
|
||||
sudo cp -r "$valhallaPath"/* "$dataPath"
|
||||
sudo cp -r "$valhallaPath/efi" "$bootPath"
|
||||
|
||||
for path in "$valhallaPath" \
|
||||
"$winPath" \
|
||||
"$winpePath" \
|
||||
"$bootPath" \
|
||||
"$dataPath"
|
||||
sudo umount -vf "$path"
|
||||
sudo rm -rf "$path"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
128
deploy.sh
128
deploy.sh
|
@ -1,10 +1,8 @@
|
|||
#!/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
|
||||
|
@ -21,131 +19,7 @@ then
|
|||
echo "Please specify the path to the Windows 11 ISO image in your .env file located at:";
|
||||
realpath --relative-to "$workingDir" "$(realpath .env)";
|
||||
else
|
||||
buildDir="build";
|
||||
mountPath="/media/wininstall";
|
||||
bootPath="/media/boot";
|
||||
dataPath="/media/data";
|
||||
setupLabel="winiso";
|
||||
intelNetworkArchive="./$buildDir/intelNetwork.zip";
|
||||
marvellNetworkArchive="./$buildDir/marvellNetwork.zip";
|
||||
gitArchive="$(realpath -m "./$buildDir/git.msi")";
|
||||
pwshArchive="./$buildDir/pwsh.zip";
|
||||
editionField="Edition ID";
|
||||
|
||||
mkdir -p "$buildDir";
|
||||
cp -r winfs/* "$overlayDir";
|
||||
|
||||
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;
|
||||
|
||||
if [ ! -f "$marvellNetworkArchive" ]
|
||||
then
|
||||
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";
|
||||
fi;
|
||||
|
||||
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;
|
||||
|
||||
if [ ! -f "$pwshArchive" ]
|
||||
then
|
||||
curl -L "https://github.com/PowerShell/PowerShell/releases/download/v7.3.7/PowerShell-7.3.7-win-x64.zip" -o "$pwshArchive";
|
||||
fi;
|
||||
|
||||
mkdir -p "$overlayDir/drivers";
|
||||
tempDir="$(mktemp -d)";
|
||||
unzip "$intelNetworkArchive" -d "$tempDir";
|
||||
cp -r "$tempDir" "$overlayDir/drivers/IntelNetwork";
|
||||
rm -rf "$tempDir";
|
||||
|
||||
tempDir="$(mktemp -d)";
|
||||
unzip "$marvellNetworkArchive" -d "$tempDir";
|
||||
cp -r "$tempDir/x64" "$overlayDir/drivers/MarvellNetwork";
|
||||
rm -rf "$tempDir";
|
||||
|
||||
mkdir -p "$overlayDir/git";
|
||||
pushd "$overlayDir/git" > /dev/null;
|
||||
7z x "$gitArchive";
|
||||
popd > /dev/null;
|
||||
|
||||
unzip "$pwshArchive" -d "$overlayDir/PowerShell";
|
||||
|
||||
sudo mount --mkdir "$WIN11_IMAGE_PATH" "$mountPath";
|
||||
isoFile="./$buildDir/win.iso";
|
||||
mkdir -p "$(dirname "$isoFile")";
|
||||
mkwinpeimg --iso --arch amd64 --overlay "$overlayDir" --windows-dir "$mountPath" "$isoFile";
|
||||
sudo umount "$mountPath";
|
||||
rm -rf "$overlayDir";
|
||||
|
||||
if [ ! -b "$WIN_DISK" ]
|
||||
then
|
||||
chooseDisk WIN_DISK;
|
||||
fi;
|
||||
|
||||
sudo shred -vfzn 0 -s 512M "$WIN_DISK";
|
||||
|
||||
{
|
||||
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";
|
||||
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;
|
||||
|
||||
sudo -- bash -c "umount -vf '$mountPath'; umount -vf '$bootPath'; umount -vf '$dataPath'; rm -rf '$mountPath' '$bootPath' '$dataPath';";
|
||||
WIN11_IMAGE_PATH="$WIN11_IMAGE_PATH" fish ./deploy.fish;
|
||||
fi;
|
||||
|
||||
popd > /dev/null;
|
||||
|
|
44
lib/choose-disk.fish
Normal file
44
lib/choose-disk.fish
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/env fish
|
||||
function chooseDisk -a result message
|
||||
set -l disks
|
||||
|
||||
lsblk -do NAME,SIZE,TYPE | while read disk
|
||||
set -l diskInfo (string split -n " " $disk)
|
||||
|
||||
if contains "$diskInfo[3]" "TYPE" "disk"
|
||||
set -a disks "$diskInfo"
|
||||
end
|
||||
end
|
||||
|
||||
set -l diskCount (count $disks)
|
||||
set -l padding (math (string length "$diskCount") + 1)
|
||||
|
||||
if [ "$diskCount" -gt 0 ]
|
||||
while true
|
||||
echo "$message"
|
||||
set -l prefix
|
||||
|
||||
for i in (seq "$diskCount")
|
||||
if [ "$i" -eq 1 ]
|
||||
set prefix ""
|
||||
else
|
||||
set prefix "$(math "$i" - 1):"
|
||||
end
|
||||
|
||||
printf "%"$padding"s %s\n" "$prefix" "$disks[$i]"
|
||||
end
|
||||
|
||||
read -lP "Your choice: " choice
|
||||
|
||||
if [ "$choice" -ge 1 ] && [ "$choice" -le "$diskCount" ]
|
||||
set -l disk (string split -n " " "$disks[$(math "$choice" + 1)]")
|
||||
set -g "$result" "/dev/$disk[1]"
|
||||
return
|
||||
else
|
||||
echo "The specified choise \"$choice\" is invalid!" >&2
|
||||
end
|
||||
end
|
||||
else
|
||||
echo "No valid disk found!" >&2
|
||||
end
|
||||
end
|
|
@ -1,59 +0,0 @@
|
|||
#!/bin/bash
|
||||
function chooseDisk() {
|
||||
local -n result="$1";
|
||||
local message="$2";
|
||||
local choice;
|
||||
local disk;
|
||||
local -a disks;
|
||||
local i;
|
||||
disks=();
|
||||
|
||||
while read disk
|
||||
do
|
||||
local -a diskInfo;
|
||||
diskInfo=($disk);
|
||||
|
||||
if [ "${diskInfo[2]}" == "TYPE" ] || [ "${diskInfo[2]}" == "disk" ]
|
||||
then
|
||||
disks+=("$disk");
|
||||
fi;
|
||||
done < <(lsblk -do NAME,SIZE,TYPE);
|
||||
|
||||
diskCount="$(expr "${#disks[@]}" - 1)";
|
||||
padding="${#diskCount}";
|
||||
|
||||
if [ "$diskCount" -gt 0 ]
|
||||
then
|
||||
while true
|
||||
do
|
||||
echo "$message";
|
||||
|
||||
for i in $(seq 0 "$(expr "$diskCount")")
|
||||
do
|
||||
local index;
|
||||
if [ "$i" -eq 0 ]
|
||||
then
|
||||
index="";
|
||||
else
|
||||
index="$i:";
|
||||
fi;
|
||||
|
||||
printf "%$(expr "${diskCount}" + 1)s ${disks[$i]}" "$index";
|
||||
echo "";
|
||||
done;
|
||||
|
||||
read -p "Your choice: " choice;
|
||||
|
||||
if [ "$choice" -ge 1 ] && [ "$choice" -le "$diskCount" ]
|
||||
then
|
||||
disk=(${disks[$choice]});
|
||||
result="/dev/${disk[0]}";
|
||||
return;
|
||||
else
|
||||
>&2 echo "The specified choice \"$choice\" is invalid!";
|
||||
fi;
|
||||
done;
|
||||
else
|
||||
>&2 echo "No valid disk found!";
|
||||
fi;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
$drives = & wmic volume get "DriveLetter,Label";
|
||||
$drive = $($($drives | Select-String -Pattern "winiso") -split "\s+")[0];
|
||||
$drive = $($($drives | Select-String -Pattern "winiso-valhalla") -split "\s+")[0];
|
||||
|
||||
Write-Warning "Attention: This program will completely wipe your current disk #1 and install Windows on it. Are you sure you want to do this?"
|
||||
Read-Host -Prompt "Hit enter to continue or CTRL+C to abort"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@echo off
|
||||
wpeutil SetKeyboardLayout 0807:00000807
|
||||
echo Launching Startup Script...
|
||||
start X:\PowerShell\pwsh.exe -NoExit -ExecutionPolicy bypass -file "X:\Scripts\Startup.ps1"
|
||||
start X:\software\pwsh\pwsh.exe -NoExit -ExecutionPolicy bypass -file "X:\Scripts\Startup.ps1"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
$null = $env:WIN_COMPUTER_NAME;
|
||||
$null = $env:SETUP_SCRIPT_NAME;
|
||||
|
||||
Set-Alias git "X:/git/bin/git.exe";
|
||||
Set-Alias git "X:/software/git/bin/git.exe";
|
||||
git clone https://git.nuth.ch/manuth/PortValhalla.git;
|
||||
Set-Location PortValhalla;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
echo Loading Drivers...
|
||||
X:\PowerShell\pwsh.exe -file "X:\Scripts\Drivers.ps1"
|
||||
X:\software\pwsh\pwsh.exe -file "X:\Scripts\Drivers.ps1"
|
||||
echo Configuring Network...
|
||||
wpeinit
|
||||
powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
|
||||
|
|
Loading…
Reference in a new issue