-
Notifications
You must be signed in to change notification settings - Fork 0
/
afd-setup.ps1
87 lines (78 loc) · 2.67 KB
/
afd-setup.ps1
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
# Check for Assembly-Tools directory
if (Test-Path -Path $HOME/Assembly-Tools) {
Write-Output "Assembly-Tools directory already exists. Skipping..."
} else {
mkdir $HOME/Assembly-Tools
}
# Download AFD if not already downloaded
if (!(Test-Path -Path $HOME/Assembly-Tools/afd.exe)) {
Invoke-WebRequest "https://raw.githubusercontent.com/AbdullahBRashid/Assembly-Tools/main/afd.exe" -o $HOME/Assembly-Tools/afd.exe
if (!($?)) {
Write-Error "Error downloading AFD. Please try again."
return
}
} else {
Write-Output "AFD already exists. Skipping..."
}
# Install NASM and DOSBox-X
winget --version
if (!($?)) {
Write-Error "Winget not found. Please install Windows Package Manager (winget) first."
return
}
$nasm_path = "$HOME/APPDATA/Local/bin/NASM"
if (!(Test-Path -Path $nasm_path)) {
winget install nasm
if (!($?)) {
Write-Error "Error installing NASM. Please try again."
return
}
}
$dosbox_path = "C:\DOSBox-X"
if (!(Test-Path -Path $dosbox_path)) {
winget install dosbox-x
if (!($?)) {
Write-Error "Error installing DOSBox-X. Please try again."
return
}
}
# Add NASM, DOSBox-X to PATH
if (!(Test-Path -Path $nasm_path)) {
Write-Error "Error finding NASM path. Please try again. If changed, then change in script."
return
}
if (!(Test-Path -Path $dosbox_path)) {
Write-Error "Error finding DOSBox-X path. Please try again. If changed, then change in script."
return
}
setx Path "$env:Path;$nasm_path;$dosbox_path"
# Get afd-run.ps1
if (!(Test-Path -Path $HOME/Assembly-Tools/afd-run.ps1)) {
Invoke-WebRequest "https://raw.githubusercontent.com/AbdullahBRashid/Assembly-Tools/main/afd-run.ps1" -o $HOME/Assembly-Tools/afd-run.ps1
if (!($?)) {
Write-Error "Error downloading afd-run.ps1. Please try again."
return
}
} else {
Write-Output "afd-run.ps1 already exists. Skipping..."
}
# Check profile
if (Test-Path -Path $PROFILE) {
Write-Output "Profile exists. Adding AFD function..."
} else {
Write-Output "Profile does not exist. Creating profile..."
if (!(Test-Path -Path $HOME/Documents/WindowsPowerShell)) {
mkdir $HOME/Documents/WindowsPowerShell
}
New-Item -Path $PROFILE -ItemType File
if (!($?)) {
Write-Error "Error creating profile. Please try again."
return
}
}
Add-Content -Path $PROFILE -Value "`r`nImport-Module `"$HOME/Assembly-Tools/afd-run.ps1`""
if (!($?)) {
Write-Error "Error adding AFD function to profile. Please try again."
return
}
Write-Output "Installation complete. Please restart your terminal."