Use two-space indentation everywhere

This commit is contained in:
2Shirt 2020-01-13 16:24:56 -07:00
parent 6c66473209
commit 24a2e60f02
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
9 changed files with 1277 additions and 1277 deletions

View file

@ -14,12 +14,12 @@ call :SetTitle Tools Copier
rem Set variables using settings\main.py file
set "SETTINGS=%bin%\Scripts\settings\main.py"
for %%v in (ARCHIVE_PASSWORD KIT_NAME_FULL) do (
set "var=%%v"
for /f "tokens=* usebackq" %%f in (`findstr "!var!=" "%SETTINGS%"`) do (
set "_v=%%f"
set "_v=!_v:*'=!"
set "%%v=!_v:~0,-1!"
)
set "var=%%v"
for /f "tokens=* usebackq" %%f in (`findstr "!var!=" "%SETTINGS%"`) do (
set "_v=%%f"
set "_v=!_v:*'=!"
set "%%v=!_v:~0,-1!"
)
)
rem Set ARCH to 32 as a gross assumption and check for x86_64 status
set ARCH=32
@ -28,9 +28,9 @@ set "SEVEN_ZIP=%bin%\7-Zip\7za.exe"
set "CON=%bin%\ConEmu\ConEmu.exe"
set "FASTCOPY=%bin%\FastCopy\FastCopy.exe"
if %ARCH% equ 64 (
set "SEVEN_ZIP=%bin%\7-Zip\7za64.exe"
set "CON=%bin%\ConEmu\ConEmu64.exe"
set "FASTCOPY=%bin%\FastCopy\FastCopy64.exe"
set "SEVEN_ZIP=%bin%\7-Zip\7za64.exe"
set "CON=%bin%\ConEmu\ConEmu64.exe"
set "FASTCOPY=%bin%\FastCopy\FastCopy64.exe"
)
set "fastcopy_args=/cmd=diff /no_ui /auto_close"
rem Set %client_dir%
@ -42,14 +42,14 @@ set "dest=%client_dir%\Tools"
:RelaunchInConEmu
if not defined IN_CONEMU (
if not defined L_NCMD (
set "con_args=-new_console:n"
rem If in DEBUG state then force ConEmu to stay open
if defined DEBUG (set "con_args=!con_args! -new_console:c")
set IN_CONEMU=True
start "" "%CON%" -run ""%~0" %*" !con_args! || goto ErrorUnknown
exit /b 0
)
if not defined L_NCMD (
set "con_args=-new_console:n"
rem If in DEBUG state then force ConEmu to stay open
if defined DEBUG (set "con_args=!con_args! -new_console:c")
set IN_CONEMU=True
start "" "%CON%" -run ""%~0" %*" !con_args! || goto ErrorUnknown
exit /b 0
)
)
:CopyBin
echo Copying .bin...
@ -102,7 +102,7 @@ goto Exit
rem Loops through all arguments to check for accepted flags
set DEBUG=
for %%f in (%*) do (
if /i "%%f" == "/DEBUG" (@echo on & set "DEBUG=/DEBUG")
if /i "%%f" == "/DEBUG" (@echo on & set "DEBUG=/DEBUG")
)
@exit /b 0

View file

@ -21,12 +21,12 @@ call :DeQuote L_TYPE
rem Set variables using settings\main.py file
set "SETTINGS=%bin%\Scripts\settings\main.py"
for %%v in (ARCHIVE_PASSWORD KIT_NAME_FULL OFFICE_SERVER_IP QUICKBOOKS_SERVER_IP) do (
set "var=%%v"
for /f "tokens=* usebackq" %%f in (`findstr "!var!=" "%SETTINGS%"`) do (
set "_v=%%f"
set "_v=!_v:*'=!"
set "%%v=!_v:~0,-1!"
)
set "var=%%v"
for /f "tokens=* usebackq" %%f in (`findstr "!var!=" "%SETTINGS%"`) do (
set "_v=%%f"
set "_v=!_v:*'=!"
set "%%v=!_v:~0,-1!"
)
)
rem Set ARCH to 32 as a gross assumption and check for x86_64 status
set ARCH=32
@ -37,21 +37,21 @@ set "FASTCOPY=%bin%\FastCopy\FastCopy.exe"
set "POWERSHELL=%systemroot%\system32\WindowsPowerShell\v1.0\powershell.exe"
set "PYTHON=%bin%\Python\x32\python.exe"
if %ARCH% equ 64 (
set "SEVEN_ZIP=%bin%\7-Zip\7za64.exe"
set "CON=%bin%\ConEmu\ConEmu64.exe"
set "FASTCOPY=%bin%\FastCopy\FastCopy64.exe"
set "PYTHON=%bin%\Python\x64\python.exe"
set "SEVEN_ZIP=%bin%\7-Zip\7za64.exe"
set "CON=%bin%\ConEmu\ConEmu64.exe"
set "FASTCOPY=%bin%\FastCopy\FastCopy64.exe"
set "PYTHON=%bin%\Python\x64\python.exe"
)
:UpdateTitle
rem Sets title using KIT_NAME_FULL from settings\main.py (unless %window_title% already set)
if defined window_title (
title %window_title%
title %window_title%
) else (
set "window_title=%*"
if not defined window_title set "window_title=Launcher"
set "window_title=%KIT_NAME_FULL%: %window_title%"
title %window_title%
set "window_title=%*"
if not defined window_title set "window_title=Launcher"
set "window_title=%KIT_NAME_FULL%: %window_title%"
title %window_title%
)
:CheckUsage
@ -66,28 +66,28 @@ if /i not "%L__CLI%" == "True" (set "L__CLI=")
:RelaunchInConEmu
set RELOAD_IN_CONEMU=True
if defined ConEmuBuild set "RELOAD_IN_CONEMU="
if defined L_NCMD set "RELOAD_IN_CONEMU="
if "%L_TYPE%" == "Executable" set "RELOAD_IN_CONEMU="
if "%L_TYPE%" == "PSScript" set "RELOAD_IN_CONEMU="
if "%L_TYPE%" == "PyScript" set "RELOAD_IN_CONEMU="
if defined ConEmuBuild set "RELOAD_IN_CONEMU="
if defined L_NCMD set "RELOAD_IN_CONEMU="
if "%L_TYPE%" == "Executable" set "RELOAD_IN_CONEMU="
if "%L_TYPE%" == "PSScript" set "RELOAD_IN_CONEMU="
if "%L_TYPE%" == "PyScript" set "RELOAD_IN_CONEMU="
if defined RELOAD_IN_CONEMU (
set "con_args=-new_console:n"
rem If in DEBUG state then force ConEmu to stay open
if defined DEBUG (set "con_args=!con_args! -new_console:c")
start "" "%CON%" -run ""%~0" %*" !con_args! || goto ErrorUnknown
exit /b 0
set "con_args=-new_console:n"
rem If in DEBUG state then force ConEmu to stay open
if defined DEBUG (set "con_args=!con_args! -new_console:c")
start "" "%CON%" -run ""%~0" %*" !con_args! || goto ErrorUnknown
exit /b 0
)
:CheckLaunchType
rem Jump to the selected launch type or show usage
if /i "%L_TYPE%" == "Executable" (goto LaunchExecutable)
if /i "%L_TYPE%" == "Folder" (goto LaunchFolder)
if /i "%L_TYPE%" == "Office" (goto LaunchOffice)
if /i "%L_TYPE%" == "PSScript" (goto LaunchPSScript)
if /i "%L_TYPE%" == "PyScript" (goto LaunchPyScript)
if /i "%L_TYPE%" == "QuickBooks" (goto LaunchQuickBooksSetup)
if /i "%L_TYPE%" == "Executable" (goto LaunchExecutable)
if /i "%L_TYPE%" == "Folder" (goto LaunchFolder)
if /i "%L_TYPE%" == "Office" (goto LaunchOffice)
if /i "%L_TYPE%" == "PSScript" (goto LaunchPSScript)
if /i "%L_TYPE%" == "PyScript" (goto LaunchPyScript)
if /i "%L_TYPE%" == "QuickBooks" (goto LaunchQuickBooksSetup)
goto Usage
:LaunchExecutable
@ -97,7 +97,7 @@ call :ExtractOrFindPath || goto ErrorProgramNotFound
rem Check for 64-bit prog (if running on 64-bit system)
set "prog=%_path%\%L_ITEM%"
if %ARCH% equ 64 (
if exist "%_path%\%L_ITEM:.=64.%" set "prog=%_path%\%L_ITEM:.=64.%"
if exist "%_path%\%L_ITEM:.=64.%" set "prog=%_path%\%L_ITEM:.=64.%"
)
if not exist "%prog%" goto ErrorProgramNotFound
@ -105,9 +105,9 @@ rem Run
popd && pushd "%_path%"
if defined L__CLI goto LaunchExecutableCLI
if defined L_ELEV (
goto LaunchExecutableElev
goto LaunchExecutableElev
) else (
goto LaunchExecutableUser
goto LaunchExecutableUser
)
:LaunchExecutableCLI
@ -153,9 +153,9 @@ set "_odt=False"
if %L_PATH% equ 2016 (set "_odt=True")
if %L_PATH% equ 2019 (set "_odt=True")
if "%_odt%" == "True" (
goto LaunchOfficeODT
goto LaunchOfficeODT
) else (
goto LaunchOfficeSetup
goto LaunchOfficeSetup
)
:LaunchOfficeODT
@ -202,14 +202,14 @@ start "" /wait "%FASTCOPY%" %fastcopy_args% "%source%" /to="%dest%\"
rem Run
if exist "%dest%\%product_name%\setup.exe" (
start "" "%dest%\%product_name%\setup.exe" || goto ErrorUnknown
start "" "%dest%\%product_name%\setup.exe" || goto ErrorUnknown
) else if "%product_name:~-3,3%" == "exe" (
start "" "%dest%\%product_name%" || goto ErrorUnknown
start "" "%dest%\%product_name%" || goto ErrorUnknown
) else if "%product_name:~-3,3%" == "msi" (
start "" "%dest%\%product_name%" || goto ErrorUnknown
start "" "%dest%\%product_name%" || goto ErrorUnknown
) else (
rem Office source not supported by this script
goto ErrorOfficeUnsupported
rem Office source not supported by this script
goto ErrorOfficeUnsupported
)
goto Exit
@ -225,9 +225,9 @@ if not exist "%script%" goto ErrorScriptNotFound
rem Run
popd && pushd "%_path%"
if defined L_ELEV (
goto LaunchPSScriptElev
goto LaunchPSScriptElev
) else (
goto LaunchPSScriptUser
goto LaunchPSScriptUser
)
:LaunchPSScriptElev
@ -238,10 +238,10 @@ rem Create VB script
mkdir "%bin%\tmp" 2>nul
echo Set UAC = CreateObject^("Shell.Application"^) > "%bin%\tmp\Elevate.vbs"
if defined L_NCMD (
rem use Powershell's window instead of %CON%
echo UAC.ShellExecute "%POWERSHELL%", "%ps_args% -File "%script%"", "", "runas", 3 >> "%bin%\tmp\Elevate.vbs"
rem use Powershell's window instead of %CON%
echo UAC.ShellExecute "%POWERSHELL%", "%ps_args% -File "%script%"", "", "runas", 3 >> "%bin%\tmp\Elevate.vbs"
) else (
echo UAC.ShellExecute "%CON%", "-run %POWERSHELL% %ps_args% -File "%script%" -new_console:n", "", "runas", 1 >> "%bin%\tmp\Elevate.vbs"
echo UAC.ShellExecute "%CON%", "-run %POWERSHELL% %ps_args% -File "%script%" -new_console:n", "", "runas", 1 >> "%bin%\tmp\Elevate.vbs"
)
rem Run
@ -251,9 +251,9 @@ goto Exit
:LaunchPSScriptUser
rem Run
if defined L_NCMD (
start "" "%POWERSHELL%" %ps_args% -File "%script%" || goto ErrorUnknown
start "" "%POWERSHELL%" %ps_args% -File "%script%" || goto ErrorUnknown
) else (
start "" "%CON%" -run "%POWERSHELL%" %ps_args% -File "%script%" -new_console:n || goto ErrorUnknown
start "" "%CON%" -run "%POWERSHELL%" %ps_args% -File "%script%" -new_console:n || goto ErrorUnknown
)
goto Exit
@ -268,9 +268,9 @@ if not exist "%script%" goto ErrorScriptNotFound
rem Run
if defined L_ELEV (
goto LaunchPyScriptElev
goto LaunchPyScriptElev
) else (
goto LaunchPyScriptUser
goto LaunchPyScriptUser
)
:LaunchPyScriptElev
@ -281,9 +281,9 @@ rem Create VB script
mkdir "%bin%\tmp" 2>nul
echo Set UAC = CreateObject^("Shell.Application"^) > "%bin%\tmp\Elevate.vbs"
if defined L_NCMD (
echo UAC.ShellExecute "%PYTHON%", """%script%"" %L_ARGS%", "", "runas", 3 >> "%bin%\tmp\Elevate.vbs"
echo UAC.ShellExecute "%PYTHON%", """%script%"" %L_ARGS%", "", "runas", 3 >> "%bin%\tmp\Elevate.vbs"
) else (
echo UAC.ShellExecute "%CON%", "-run ""%PYTHON%"" ""%script%"" %L_ARGS% -new_console:n", "", "runas", 1 >> "%bin%\tmp\Elevate.vbs"
echo UAC.ShellExecute "%CON%", "-run ""%PYTHON%"" ""%script%"" %L_ARGS% -new_console:n", "", "runas", 1 >> "%bin%\tmp\Elevate.vbs"
)
rem Run
@ -292,9 +292,9 @@ goto Exit
:LaunchPyScriptUser
if defined L_NCMD (
start "" "%PYTHON%" "%script%" %L_ARGS% || goto ErrorUnknown
start "" "%PYTHON%" "%script%" %L_ARGS% || goto ErrorUnknown
) else (
start "" "%CON%" -run "%PYTHON%" "%script%" %L_ARGS% -new_console:n || goto ErrorUnknown
start "" "%CON%" -run "%PYTHON%" "%script%" %L_ARGS% -new_console:n || goto ErrorUnknown
)
goto Exit
@ -317,12 +317,12 @@ start "" /wait "%FASTCOPY%" %fastcopy_args% "%source%" /to="%dest%\"
rem Run
if exist "%dest%\%product_name%\Setup.exe" (
pushd "%dest%\%product_name%"
start "" "%dest%\%product_name%\Setup.exe" || goto ErrorUnknown
popd
pushd "%dest%\%product_name%"
start "" "%dest%\%product_name%\Setup.exe" || goto ErrorUnknown
popd
) else (
rem QuickBooks source not supported by this script
goto ErrorQuickBooksUnsupported
rem QuickBooks source not supported by this script
goto ErrorQuickBooksUnsupported
)
goto Exit
@ -331,16 +331,16 @@ echo.
echo.Usage (via defined variables):
echo. L_TYPE L_PATH L_ITEM L_ARGS
echo. Executable Working Dir Program Args [L_7ZIP] [L_ELEV] [L__CLI]
echo. Folder Folder '.' [L_7ZIP]
echo. Office Year Product [L_7ZIP]
echo. PSScript Scripts Script [L_7ZIP] [L_ELEV] [L_NCMD]
echo. PyScript Scripts Script Args [L_7ZIP] [L_ELEV] [L_NCMD]
echo. QuickBooks Year Product [L_7ZIP]
echo. Folder Folder '.' [L_7ZIP]
echo. Office Year Product [L_7ZIP]
echo. PSScript Scripts Script [L_7ZIP] [L_ELEV] [L_NCMD]
echo. PyScript Scripts Script Args [L_7ZIP] [L_ELEV] [L_NCMD]
echo. QuickBooks Year Product [L_7ZIP]
echo.
echo.L_7ZIP: Extra arguments for 7-Zip (in the :ExtractCBin label)
echo.L_ELEV: Elevate to run as Admin
echo.L_NCMD: Do not run script inside ConEmu (i.e. use the native window)
echo.L__CLI: Run executable in ConEmu
echo.L_7ZIP: Extra arguments for 7-Zip (in the :ExtractCBin label)
echo.L_ELEV: Elevate to run as Admin
echo.L_NCMD: Do not run script inside ConEmu (i.e. use the native window)
echo.L__CLI: Run executable in ConEmu
echo.
goto Abort
@ -392,15 +392,15 @@ set "%1=%_tmp%"
:ExtractOrFindPath
rem Test L_PATH in the following order:
rem 1: %cbin%\L_PATH.7z (which will be extracted to %bin%\L_PATH)
rem 2: %bin%\L_PATH
rem 3. %L_PATH% (i.e. treat L_PATH as an absolute path)
rem 1: %cbin%\L_PATH.7z (which will be extracted to %bin%\L_PATH)
rem 2: %bin%\L_PATH
rem 3. %L_PATH% (i.e. treat L_PATH as an absolute path)
rem NOTE: This function should be called as 'call :ExtractOrFindPath || goto ErrorProgramNotFound' to catch invalid paths.
set _path=
if exist "%cbin%\%L_PATH%.7z" (
call :ExtractCBin
call :ExtractCBin
) else if exist "%cbin%\%L_PATH%\%L_ITEM:~0,-4%.7z" (
call :ExtractCBin
call :ExtractCBin
)
if exist "%bin%\%L_PATH%" (set "_path=%bin%\%L_PATH%")
if not defined _path (set "_path=%L_PATH%")
@ -476,9 +476,9 @@ goto Abort
:Abort
rem Handle color theme for both the native console and ConEmu
if defined ConEmuBuild (
color c4
color c4
) else (
color 4e
color 4e
)
echo Aborted.
echo.

View file

@ -46,7 +46,7 @@ goto Exit
rem Loops through all arguments to check for accepted flags
set DEBUG=
for %%f in (%*) do (
if /i "%%f" == "/DEBUG" (@echo on & set "DEBUG=/DEBUG")
if /i "%%f" == "/DEBUG" (@echo on & set "DEBUG=/DEBUG")
)
@exit /b 0
@ -70,9 +70,9 @@ popd
rem Sets title using KIT_NAME_FULL from settings\main.py
set "SETTINGS=%bin%\Scripts\settings\main.py"
for /f "tokens=* usebackq" %%f in (`findstr KIT_NAME_FULL "%SETTINGS%"`) do (
set "_v=%%f"
set "_v=!_v:*'=!"
set "KIT_NAME_FULL=!_v:~0,-1!"
set "_v=%%f"
set "_v=!_v:*'=!"
set "KIT_NAME_FULL=!_v:~0,-1!"
)
set "window_title=%*"
if not defined window_title set "window_title=Launcher"

View file

@ -3,7 +3,7 @@
## Init ##
#Requires -Version 3.0
if (Test-Path Env:\DEBUG) {
Set-PSDebug -Trace 1
Set-PSDebug -Trace 1
}
$Host.UI.RawUI.WindowTitle = "Wizard Kit: Build Tool"
$WD = $(Split-Path $MyInvocation.MyCommand.Path)
@ -21,47 +21,47 @@ $Host.UI.RawUI.ForegroundColor = "white"
## Functions ##
function Abort {
Write-Host -ForegroundColor "Red" "`nAborted."
WKPause "Press Enter to exit..."
exit
Write-Host -ForegroundColor "Red" "`nAborted."
WKPause "Press Enter to exit..."
exit
}
function DownloadFile ($Path, $Name, $Url) {
$OutFile = "{0}\{1}" -f $Path, $Name
$OutFile = "{0}\{1}" -f $Path, $Name
Write-Host ("Downloading: $Name")
New-Item -Type Directory $Path 2>&1 | Out-Null
try {
Invoke-WebRequest -Uri $Url -OutFile $OutFile
}
catch {
Write-Host (" ERROR: Failed to download file." ) -ForegroundColor "Red"
$global:DownloadErrors += 1
}
Write-Host ("Downloading: $Name")
New-Item -Type Directory $Path 2>&1 | Out-Null
try {
Invoke-WebRequest -Uri $Url -OutFile $OutFile
}
catch {
Write-Host (" ERROR: Failed to download file." ) -ForegroundColor "Red"
$global:DownloadErrors += 1
}
}
function FindDynamicUrl ($SourcePage, $RegEx) {
# Get source page
Invoke-Webrequest -Uri $SourcePage -OutFile "tmp_page"
# Get source page
Invoke-Webrequest -Uri $SourcePage -OutFile "tmp_page"
# Search for real url
$Url = Get-Content "tmp_page" | Where-Object {$_ -imatch $RegEx}
$Url = $Url -ireplace '.*(a |)href="([^"]+)".*', '$2'
$Url = $Url -ireplace ".*(a |)href='([^']+)'.*", '$2'
# Search for real url
$Url = Get-Content "tmp_page" | Where-Object {$_ -imatch $RegEx}
$Url = $Url -ireplace '.*(a |)href="([^"]+)".*', '$2'
$Url = $Url -ireplace ".*(a |)href='([^']+)'.*", '$2'
# Remove tmp_page
Remove-Item "tmp_page"
# Remove tmp_page
Remove-Item "tmp_page"
$Url | Select-Object -First 1
$Url | Select-Object -First 1
}
function WKPause ($Message = "Press Enter to continue... ") {
Write-Host $Message -NoNewLine
Read-Host
Write-Host $Message -NoNewLine
Read-Host
}
## Safety Check ##
if ($PSVersionTable.PSVersion.Major -eq 6 -and $PSVersionTable.OS -imatch "Windows 6.1") {
Write-Host "`nThis script doesn't support PowerShell 6.0 on Windows 7."
Write-Host "`nThis script doesn't support PowerShell 6.0 on Windows 7."
Write-Host "Press Enter to exit... " -NoNewLine
Abort
Abort
}
## PowerShell equivalent of Python's "if __name__ == '__main__'"
@ -71,160 +71,160 @@ if ($PSVersionTable.PSVersion.Major -eq 6 -and $PSVersionTable.OS -imatch "Windo
# Asked by: https://stackoverflow.com/users/65164/mark-mascolino
# Answer by: https://stackoverflow.com/users/696808/bacon-bits
if ($MyInvocation.InvocationName -ne ".") {
Clear-Host
Write-Host "Wizard Kit: Build Tool`n`n`n`n`n"
## Download ##
$DownloadErrors = 0
$Path = $Temp
Clear-Host
Write-Host "Wizard Kit: Build Tool`n`n`n`n`n"
# 7-Zip
DownloadFile -Path $Path -Name "7z-installer.msi" -Url "https://www.7-zip.org/a/7z1900.msi"
DownloadFile -Path $Path -Name "7z-extra.7z" -Url "https://www.7-zip.org/a/7z1900-extra.7z"
## Download ##
$DownloadErrors = 0
$Path = $Temp
# ConEmu
$Url = "https://github.com/Maximus5/ConEmu/releases/download/v19.03.10/ConEmuPack.190310.7z"
DownloadFile -Path $Path -Name "ConEmuPack.7z" -Url $Url
# 7-Zip
DownloadFile -Path $Path -Name "7z-installer.msi" -Url "https://www.7-zip.org/a/7z1900.msi"
DownloadFile -Path $Path -Name "7z-extra.7z" -Url "https://www.7-zip.org/a/7z1900-extra.7z"
# Notepad++
$Url = "https://notepad-plus-plus.org/repository/7.x/7.6.4/npp.7.6.4.bin.minimalist.7z"
DownloadFile -Path $Path -Name "npp.7z" -Url $Url
# ConEmu
$Url = "https://github.com/Maximus5/ConEmu/releases/download/v19.03.10/ConEmuPack.190310.7z"
DownloadFile -Path $Path -Name "ConEmuPack.7z" -Url $Url
# Python
$Url = "https://www.python.org/ftp/python/3.7.2/python-3.7.2.post1-embed-win32.zip"
DownloadFile -Path $Path -Name "python32.zip" -Url $Url
$Url = "https://www.python.org/ftp/python/3.7.2/python-3.7.2.post1-embed-amd64.zip"
DownloadFile -Path $Path -Name "python64.zip" -Url $Url
# Notepad++
$Url = "https://notepad-plus-plus.org/repository/7.x/7.6.4/npp.7.6.4.bin.minimalist.7z"
DownloadFile -Path $Path -Name "npp.7z" -Url $Url
# Python: psutil
$DownloadPage = "https://pypi.org/project/psutil/"
$RegEx = "href=.*-cp37-cp37m-win32.whl"
$Url = FindDynamicUrl $DownloadPage $RegEx
DownloadFile -Path $Path -Name "psutil32.whl" -Url $Url
$RegEx = "href=.*-cp37-cp37m-win_amd64.whl"
$Url = FindDynamicUrl $DownloadPage $RegEx
DownloadFile -Path $Path -Name "psutil64.whl" -Url $Url
# Python
$Url = "https://www.python.org/ftp/python/3.7.2/python-3.7.2.post1-embed-win32.zip"
DownloadFile -Path $Path -Name "python32.zip" -Url $Url
$Url = "https://www.python.org/ftp/python/3.7.2/python-3.7.2.post1-embed-amd64.zip"
DownloadFile -Path $Path -Name "python64.zip" -Url $Url
# Python: requests & dependancies
$RegEx = "href=.*.py3-none-any.whl"
foreach ($Module in @("chardet", "certifi", "idna", "urllib3", "requests")) {
$DownloadPage = "https://pypi.org/project/$Module/"
$Name = "$Module.whl"
$Url = FindDynamicUrl -SourcePage $DownloadPage -RegEx $RegEx
DownloadFile -Path $Path -Name $Name -Url $Url
}
# Python: psutil
$DownloadPage = "https://pypi.org/project/psutil/"
$RegEx = "href=.*-cp37-cp37m-win32.whl"
$Url = FindDynamicUrl $DownloadPage $RegEx
DownloadFile -Path $Path -Name "psutil32.whl" -Url $Url
$RegEx = "href=.*-cp37-cp37m-win_amd64.whl"
$Url = FindDynamicUrl $DownloadPage $RegEx
DownloadFile -Path $Path -Name "psutil64.whl" -Url $Url
# Visual C++ Runtimes
$Url = "https://aka.ms/vs/15/release/vc_redist.x86.exe"
DownloadFile -Path $Path -Name "vcredist_x86.exe" -Url $Url
$Url = "https://aka.ms/vs/15/release/vc_redist.x64.exe"
DownloadFile -Path $Path -Name "vcredist_x64.exe" -Url $Url
## Bail ##
# If errors were encountered during downloads
if ($DownloadErrors -gt 0) {
Abort
}
# Python: requests & dependancies
$RegEx = "href=.*.py3-none-any.whl"
foreach ($Module in @("chardet", "certifi", "idna", "urllib3", "requests")) {
$DownloadPage = "https://pypi.org/project/$Module/"
$Name = "$Module.whl"
$Url = FindDynamicUrl -SourcePage $DownloadPage -RegEx $RegEx
DownloadFile -Path $Path -Name $Name -Url $Url
}
## Install ##
# Visual C++ Runtimes
$ArgumentList = @("/install", "/passive", "/norestart")
Start-Process -FilePath "$Temp\vcredist_x86.exe" -ArgumentList $ArgumentList -Wait
Start-Process -FilePath "$Temp\vcredist_x64.exe" -ArgumentList $ArgumentList -Wait
Remove-Item "$Temp\vcredist*.exe"
## Extract ##
# 7-Zip
Write-Host "Extracting: 7-Zip"
try {
$ArgumentList = @("/a", "$Temp\7z-installer.msi", "TARGETDIR=$Temp\7zi", "/qn")
Start-Process -FilePath "$System32\msiexec.exe" -ArgumentList $ArgumentList -Wait
$SevenZip = "$Temp\7zi\Files\7-Zip\7z.exe"
$ArgumentList = @(
"x", "$Temp\7z-extra.7z", "-o$Bin\7-Zip",
"-aoa", "-bso0", "-bse0", "-bsp0",
"-x!x64\*.dll", "-x!Far", "-x!*.dll")
Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait
Start-Sleep 1
Move-Item "$Bin\7-Zip\x64\7za.exe" "$Bin\7-Zip\7za64.exe"
Remove-Item "$Bin\7-Zip\x64" -Recurse
Remove-Item "$Temp\7z*" -Recurse
$SevenZip = "$Bin\7-Zip\7za.exe"
}
catch {
Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red"
}
# Visual C++ Runtimes
$Url = "https://aka.ms/vs/15/release/vc_redist.x86.exe"
DownloadFile -Path $Path -Name "vcredist_x86.exe" -Url $Url
$Url = "https://aka.ms/vs/15/release/vc_redist.x64.exe"
DownloadFile -Path $Path -Name "vcredist_x64.exe" -Url $Url
# Notepad++
Write-Host "Extracting: Notepad++"
try {
$ArgumentList = @(
"x", "$Temp\npp.7z", "-o$Bin\NotepadPlusPlus",
"-aoa", "-bso0", "-bse0", "-bsp0")
Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait
Remove-Item "$Temp\npp.7z"
Move-Item "$Bin\NotepadPlusPlus\notepad++.exe" "$Bin\NotepadPlusPlus\notepadplusplus.exe"
}
catch {
Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red"
}
## Bail ##
# If errors were encountered during downloads
if ($DownloadErrors -gt 0) {
Abort
}
# ConEmu
Write-Host "Extracting: ConEmu"
try {
$ArgumentList = @(
"x", "$Temp\ConEmuPack.7z", "-o$Bin\ConEmu",
"-aoa", "-bso0", "-bse0", "-bsp0")
Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait
Remove-Item "$Temp\ConEmuPack.7z"
}
catch {
Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red"
}
## Install ##
# Visual C++ Runtimes
$ArgumentList = @("/install", "/passive", "/norestart")
Start-Process -FilePath "$Temp\vcredist_x86.exe" -ArgumentList $ArgumentList -Wait
Start-Process -FilePath "$Temp\vcredist_x64.exe" -ArgumentList $ArgumentList -Wait
Remove-Item "$Temp\vcredist*.exe"
# Python
foreach ($Arch in @("32", "64")) {
Write-Host "Extracting: Python (x$Arch)"
$Files = @(
"python$Arch.zip",
"certifi.whl",
"chardet.whl",
"idna.whl",
"psutil$Arch.whl",
"requests.whl",
"urllib3.whl"
)
try {
foreach ($File in $Files) {
$ArgumentList = @(
"x", "$Temp\$File", "-o$Bin\Python\x$Arch",
"-aoa", "-bso0", "-bse0", "-bsp0")
Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait
}
}
catch {
Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red"
}
}
try {
Copy-Item -Path "$System32\vcruntime140.dll" -Destination "$Bin\Python\x64\vcruntime140.dll" -Force
Copy-Item -Path "$SysWOW64\vcruntime140.dll" -Destination "$Bin\Python\x32\vcruntime140.dll" -Force
}
catch {
Write-Host (" ERROR: Failed to copy Visual C++ Runtime DLLs." ) -ForegroundColor "Red"
}
Remove-Item "$Temp\python*.zip"
Remove-Item "$Temp\*.whl"
## Configure ##
Write-Host "Configuring kit"
WKPause "Press Enter to open settings..."
$Cmd = "$Bin\NotepadPlusPlus\notepadplusplus.exe"
Start-Process -FilePath $Cmd -ArgumentList @("$Bin\Scripts\settings\main.py") -Wait
## Extract ##
# 7-Zip
Write-Host "Extracting: 7-Zip"
try {
$ArgumentList = @("/a", "$Temp\7z-installer.msi", "TARGETDIR=$Temp\7zi", "/qn")
Start-Process -FilePath "$System32\msiexec.exe" -ArgumentList $ArgumentList -Wait
$SevenZip = "$Temp\7zi\Files\7-Zip\7z.exe"
$ArgumentList = @(
"x", "$Temp\7z-extra.7z", "-o$Bin\7-Zip",
"-aoa", "-bso0", "-bse0", "-bsp0",
"-x!x64\*.dll", "-x!Far", "-x!*.dll")
Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait
Start-Sleep 1
Move-Item "$Bin\7-Zip\x64\7za.exe" "$Bin\7-Zip\7za64.exe"
Remove-Item "$Bin\7-Zip\x64" -Recurse
Remove-Item "$Temp\7z*" -Recurse
$SevenZip = "$Bin\7-Zip\7za.exe"
}
catch {
Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red"
}
## Done ##
Pop-Location
$ArgumentList = @("-run", "$Bin\Python\x32\python.exe", "$Bin\Scripts\update_kit.py", "-new_console:n")
Start-Process -FilePath "$Bin\ConEmu\ConEmu.exe" -ArgumentList $ArgumentList -verb RunAs
# Notepad++
Write-Host "Extracting: Notepad++"
try {
$ArgumentList = @(
"x", "$Temp\npp.7z", "-o$Bin\NotepadPlusPlus",
"-aoa", "-bso0", "-bse0", "-bsp0")
Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait
Remove-Item "$Temp\npp.7z"
Move-Item "$Bin\NotepadPlusPlus\notepad++.exe" "$Bin\NotepadPlusPlus\notepadplusplus.exe"
}
catch {
Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red"
}
# ConEmu
Write-Host "Extracting: ConEmu"
try {
$ArgumentList = @(
"x", "$Temp\ConEmuPack.7z", "-o$Bin\ConEmu",
"-aoa", "-bso0", "-bse0", "-bsp0")
Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait
Remove-Item "$Temp\ConEmuPack.7z"
}
catch {
Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red"
}
# Python
foreach ($Arch in @("32", "64")) {
Write-Host "Extracting: Python (x$Arch)"
$Files = @(
"python$Arch.zip",
"certifi.whl",
"chardet.whl",
"idna.whl",
"psutil$Arch.whl",
"requests.whl",
"urllib3.whl"
)
try {
foreach ($File in $Files) {
$ArgumentList = @(
"x", "$Temp\$File", "-o$Bin\Python\x$Arch",
"-aoa", "-bso0", "-bse0", "-bsp0")
Start-Process -FilePath $SevenZip -ArgumentList $ArgumentList -NoNewWindow -Wait
}
}
catch {
Write-Host (" ERROR: Failed to extract files." ) -ForegroundColor "Red"
}
}
try {
Copy-Item -Path "$System32\vcruntime140.dll" -Destination "$Bin\Python\x64\vcruntime140.dll" -Force
Copy-Item -Path "$SysWOW64\vcruntime140.dll" -Destination "$Bin\Python\x32\vcruntime140.dll" -Force
}
catch {
Write-Host (" ERROR: Failed to copy Visual C++ Runtime DLLs." ) -ForegroundColor "Red"
}
Remove-Item "$Temp\python*.zip"
Remove-Item "$Temp\*.whl"
## Configure ##
Write-Host "Configuring kit"
WKPause "Press Enter to open settings..."
$Cmd = "$Bin\NotepadPlusPlus\notepadplusplus.exe"
Start-Process -FilePath $Cmd -ArgumentList @("$Bin\Scripts\settings\main.py") -Wait
Start-Sleep 1
## Done ##
Pop-Location
$ArgumentList = @("-run", "$Bin\Python\x32\python.exe", "$Bin\Scripts\update_kit.py", "-new_console:n")
Start-Process -FilePath "$Bin\ConEmu\ConEmu.exe" -ArgumentList $ArgumentList -verb RunAs
}

File diff suppressed because it is too large Load diff

View file

@ -10,12 +10,12 @@ if not defined bin (goto Abort)
:: Credit to SS64.com Code taken from http://ss64.com/nt/syntax-getdate.html
:: Use WMIC to retrieve date and time in ISO 8601 format.
for /f "skip=1 tokens=1-6" %%G in ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') do (
if "%%~L"=="" goto s_done
set _yyyy=%%L
set _mm=00%%J
set _dd=00%%G
set _hour=00%%H
set _minute=00%%I
if "%%~L"=="" goto s_done
set _yyyy=%%L
set _mm=00%%J
set _dd=00%%G
set _hour=00%%H
set _minute=00%%I
)
:s_done
:: Pad digits with leading zeros
@ -28,9 +28,9 @@ set iso_date=%_yyyy%-%_mm%-%_dd%
:SetVars
set "SETTINGS=%bin%\Scripts\settings\main.py"
for /f "tokens=* usebackq" %%f in (`findstr KIT_NAME_SHORT "%SETTINGS%"`) do (
set "_v=%%f"
set "_v=!_v:*'=!"
set "KIT_NAME_SHORT=!_v:~0,-1!"
set "_v=%%f"
set "_v=!_v:*'=!"
set "KIT_NAME_SHORT=!_v:~0,-1!"
)
set "client_dir=%systemdrive%\%KIT_NAME_SHORT%"
set "log_dir=%client_dir%\Logs\%iso_date%"
@ -43,20 +43,20 @@ set _quarantine=
set _quickbooks=
set _transfer=
for %%f in (%*) do (
if /i "%%f" == "/DEBUG" (@echo on)
if /i "%%f" == "/Backups" set _backups=True
if /i "%%f" == "/Logs" set _logs=True
if /i "%%f" == "/Office" set _office=True
if /i "%%f" == "/Quarantine" set _quarantine=True
if /i "%%f" == "/QuickBooks" set _quickbooks=True
if /i "%%f" == "/Transfer" set _transfer=True
if /i "%%f" == "/DEBUG" (@echo on)
if /i "%%f" == "/Backups" set _backups=True
if /i "%%f" == "/Logs" set _logs=True
if /i "%%f" == "/Office" set _office=True
if /i "%%f" == "/Quarantine" set _quarantine=True
if /i "%%f" == "/QuickBooks" set _quickbooks=True
if /i "%%f" == "/Transfer" set _transfer=True
)
:CreateDirs
if defined _backups mkdir "%client_dir%\Backups">nul 2>&1
if defined _logs (
mkdir "%log_dir%\%KIT_NAME_FULL%">nul 2>&1
mkdir "%log_dir%\Tools">nul 2>&1)
mkdir "%log_dir%\%KIT_NAME_FULL%">nul 2>&1
mkdir "%log_dir%\Tools">nul 2>&1)
if defined _office mkdir "%client_dir%\Office">nul 2>&1
if defined _quarantine mkdir "%client_dir%\Quarantine">nul 2>&1
if defined _quickbooks mkdir "%client_dir%\QuickBooks">nul 2>&1

View file

@ -20,493 +20,493 @@ SKEL_DIR="$LIVE_DIR/airootfs/etc/skel"
TEMP_DIR="$BUILD_DIR/temp"
MIRRORLIST_SOURCE='https://www.archlinux.org/mirrorlist/?country=US&protocol=http&protocol=https&ip_version=4&use_mirror_status=on'
if which nano >/dev/null 2>&1; then
EDITOR=nano
EDITOR=nano
elif which vim >/dev/null 2>&1; then
EDITOR=vim
EDITOR=vim
else
EDITOR=vi
EDITOR=vi
fi
if [ ! -z ${SUDO_USER+x} ]; then
REAL_USER="$SUDO_USER"
REAL_USER="$SUDO_USER"
fi
function ask() {
while :; do
read -p "$1 [Y/N] " -r answer
if echo "$answer" | egrep -iq '^(y|yes|sure)$'; then
return 0
elif echo "$answer" | egrep -iq '^(n|no|nope)$'; then
return 1
fi
done
while :; do
read -p "$1 [Y/N] " -r answer
if echo "$answer" | egrep -iq '^(y|yes|sure)$'; then
return 0
elif echo "$answer" | egrep -iq '^(n|no|nope)$'; then
return 1
fi
done
}
function cleanup() {
for d in "$TEMP_DIR" "$LIVE_DIR"; do
if [[ -d "$d" ]]; then
if ask "Remove: ${d}?"; then
rm -Rf "$d"
fi
fi
done
mkdir -p "$BUILD_DIR" 2>/dev/null
mkdir -p "$LOG_DIR" 2>/dev/null
mkdir -p "$OUT_DIR" 2>/dev/null
mkdir -p "$TEMP_DIR" 2>/dev/null
for d in "$TEMP_DIR" "$LIVE_DIR"; do
if [[ -d "$d" ]]; then
if ask "Remove: ${d}?"; then
rm -Rf "$d"
fi
fi
done
mkdir -p "$BUILD_DIR" 2>/dev/null
mkdir -p "$LOG_DIR" 2>/dev/null
mkdir -p "$OUT_DIR" 2>/dev/null
mkdir -p "$TEMP_DIR" 2>/dev/null
}
function fix_kit_permissions() {
# GitHub zip archives don't preserve the correct permissions
for d in docs images scripts setup; do
find "$ROOT_DIR/$d" -type d -exec chmod 755 "{}" \;
done
# GitHub zip archives don't preserve the correct permissions
for d in docs images scripts setup; do
find "$ROOT_DIR/$d" -type d -exec chmod 755 "{}" \;
done
}
function load_settings() {
# Check if settings already loaded
## Code based on StackOverflow Q&A
## Question: https://stackoverflow.com/q/3601515
## Asked by: https://stackoverflow.com/users/260127/prosseek
## Edited by: https://stackoverflow.com/users/3924118/nbro
## Answer: https://stackoverflow.com/a/13864829
## Answer by: https://stackoverflow.com/users/1633643/lionel
## Answer edit: https://stackoverflow.com/users/-1/community
_main_path="$BUILD_DIR/main.py"
if [ ! -z ${KIT_NAME_FULL+x} ]; then
# KIT_NAME_FULL is set
return 0 # Skip loading settings from main.py
# Check if settings already loaded
## Code based on StackOverflow Q&A
## Question: https://stackoverflow.com/q/3601515
## Asked by: https://stackoverflow.com/users/260127/prosseek
## Edited by: https://stackoverflow.com/users/3924118/nbro
## Answer: https://stackoverflow.com/a/13864829
## Answer by: https://stackoverflow.com/users/1633643/lionel
## Answer edit: https://stackoverflow.com/users/-1/community
_main_path="$BUILD_DIR/main.py"
if [ ! -z ${KIT_NAME_FULL+x} ]; then
# KIT_NAME_FULL is set
return 0 # Skip loading settings from main.py
fi
if [[ "${1:-}" == "--edit" ]]; then
# Copy settings
if [[ ! -e "$BUILD_DIR/main.py" ]] || ask "Overwrite main.py?"; then
cp -bv "$ROOT_DIR/scripts/wk/cfg/main.py" "$BUILD_DIR/main.py"
dos2unix "$BUILD_DIR/main.py"
fi
if [[ "${1:-}" == "--edit" ]]; then
# Copy settings
if [[ ! -e "$BUILD_DIR/main.py" ]] || ask "Overwrite main.py?"; then
cp -bv "$ROOT_DIR/scripts/wk/cfg/main.py" "$BUILD_DIR/main.py"
dos2unix "$BUILD_DIR/main.py"
fi
# Edit settings
read -p "Press Enter to open settings... " -r
"$EDITOR" "$BUILD_DIR/main.py"
else
# Load settings from $LIVE_DIR
_main_path="$LIVE_DIR/airootfs/usr/local/bin/wk/cfg/main.py"
fi
# Edit settings
read -p "Press Enter to open settings... " -r
"$EDITOR" "$BUILD_DIR/main.py"
else
# Load settings from $LIVE_DIR
_main_path="$LIVE_DIR/airootfs/usr/local/bin/wk/cfg/main.py"
# Load settings
while read line; do
if echo "$line" | egrep -q "^\w+='"; then
line="$(echo "$line" | sed -r 's/[\r\n]+//')"
eval "$line"
fi
# Load settings
while read line; do
if echo "$line" | egrep -q "^\w+='"; then
line="$(echo "$line" | sed -r 's/[\r\n]+//')"
eval "$line"
fi
done < "$_main_path"
done < "$_main_path"
}
function copy_live_env() {
echo "Copying Archlinux files..."
rsync -aI /usr/share/archiso/configs/releng/ "$LIVE_DIR/"
echo "Copying Archlinux files..."
rsync -aI /usr/share/archiso/configs/releng/ "$LIVE_DIR/"
# Remove items
rm "$LIVE_DIR/airootfs/etc/systemd/scripts/choose-mirror"
rmdir "$LIVE_DIR/airootfs/etc/systemd/scripts" --ignore-fail-on-non-empty
rm "$LIVE_DIR/airootfs/etc/systemd/system/choose-mirror.service"
rm "$LIVE_DIR/airootfs/etc/systemd/system/etc-pacman.d-gnupg.mount"
rm "$LIVE_DIR/airootfs/etc/systemd/system/pacman-init.service"
rm "$LIVE_DIR/airootfs/etc/udev/rules.d/81-dhcpcd.rules"
rmdir "$LIVE_DIR/airootfs/etc/udev/rules.d" --ignore-fail-on-non-empty
rmdir "$LIVE_DIR/airootfs/etc/udev" --ignore-fail-on-non-empty
rm "$LIVE_DIR/isolinux"/*.cfg
rm "$LIVE_DIR/syslinux"/*.cfg "$LIVE_DIR/syslinux"/*.png
# Remove items
rm "$LIVE_DIR/airootfs/etc/systemd/scripts/choose-mirror"
rmdir "$LIVE_DIR/airootfs/etc/systemd/scripts" --ignore-fail-on-non-empty
rm "$LIVE_DIR/airootfs/etc/systemd/system/choose-mirror.service"
rm "$LIVE_DIR/airootfs/etc/systemd/system/etc-pacman.d-gnupg.mount"
rm "$LIVE_DIR/airootfs/etc/systemd/system/pacman-init.service"
rm "$LIVE_DIR/airootfs/etc/udev/rules.d/81-dhcpcd.rules"
rmdir "$LIVE_DIR/airootfs/etc/udev/rules.d" --ignore-fail-on-non-empty
rmdir "$LIVE_DIR/airootfs/etc/udev" --ignore-fail-on-non-empty
rm "$LIVE_DIR/isolinux"/*.cfg
rm "$LIVE_DIR/syslinux"/*.cfg "$LIVE_DIR/syslinux"/*.png
# Add items
rsync -aI "$ROOT_DIR/setup/linux/include/" "$LIVE_DIR/"
if [[ "${1:-}" != "--minimal" ]]; then
rsync -aI "$ROOT_DIR/setup/linux/include_x/" "$LIVE_DIR/"
fi
mkdir -p "$LIVE_DIR/airootfs/usr/local/bin"
rsync -aI "$ROOT_DIR/scripts/" "$LIVE_DIR/airootfs/usr/local/bin/"
cp -a "$BUILD_DIR/main.py" "$LIVE_DIR/airootfs/usr/local/bin/wk/cfg/"
# Add items
rsync -aI "$ROOT_DIR/setup/linux/include/" "$LIVE_DIR/"
if [[ "${1:-}" != "--minimal" ]]; then
rsync -aI "$ROOT_DIR/setup/linux/include_x/" "$LIVE_DIR/"
fi
mkdir -p "$LIVE_DIR/airootfs/usr/local/bin"
rsync -aI "$ROOT_DIR/scripts/" "$LIVE_DIR/airootfs/usr/local/bin/"
cp -a "$BUILD_DIR/main.py" "$LIVE_DIR/airootfs/usr/local/bin/wk/cfg/"
}
function run_elevated() {
prog="$1"
shift
if which sudo >/dev/null 2>&1; then
if ! sudo "$prog" $*; then
echo "ERROR: Failed to run '$prog'"
if ask "Retry?"; then
sudo "$prog" $*
fi
fi
else
echo -n "Root "
if ! su -c "export REAL_USER=$USER && '$prog' $*"; then
echo "ERROR: Failed to run '$prog'"
if ask "Retry?"; then
su -c "export REAL_USER=$USER && '$prog' $*"
fi
fi
prog="$1"
shift
if which sudo >/dev/null 2>&1; then
if ! sudo "$prog" $*; then
echo "ERROR: Failed to run '$prog'"
if ask "Retry?"; then
sudo "$prog" $*
fi
fi
else
echo -n "Root "
if ! su -c "export REAL_USER=$USER && '$prog' $*"; then
echo "ERROR: Failed to run '$prog'"
if ask "Retry?"; then
su -c "export REAL_USER=$USER && '$prog' $*"
fi
fi
fi
}
function update_live_env() {
hostname="$(echo "${KIT_NAME_SHORT}-linux" | tr "[:upper:]" "[:lower:]")"
username="tech"
label="${KIT_NAME_SHORT}_LINUX"
hostname="$(echo "${KIT_NAME_SHORT}-linux" | tr "[:upper:]" "[:lower:]")"
username="tech"
label="${KIT_NAME_SHORT}_LINUX"
# Boot config (legacy)
mkdir -p "$LIVE_DIR/arch"
cp "$ROOT_DIR/images/Pxelinux.png" "$LIVE_DIR/arch/pxelinux.png"
cp "$ROOT_DIR/images/Syslinux.png" "$LIVE_DIR/arch/syslinux.png"
sed -i -r "s/_+/$KIT_NAME_FULL/" "$LIVE_DIR/syslinux/wk_head.cfg"
mkdir -p "$TEMP_DIR" 2>/dev/null
curl -Lo "$TEMP_DIR/wimboot.zip" "http://git.ipxe.org/releases/wimboot/wimboot-latest.zip"
7z e -aoa "$TEMP_DIR/wimboot.zip" -o"$LIVE_DIR/arch/boot" 'wimboot*/LICENSE.txt' 'wimboot*/README.txt' 'wimboot*/wimboot'
# Boot config (legacy)
mkdir -p "$LIVE_DIR/arch"
cp "$ROOT_DIR/images/Pxelinux.png" "$LIVE_DIR/arch/pxelinux.png"
cp "$ROOT_DIR/images/Syslinux.png" "$LIVE_DIR/arch/syslinux.png"
sed -i -r "s/_+/$KIT_NAME_FULL/" "$LIVE_DIR/syslinux/wk_head.cfg"
mkdir -p "$TEMP_DIR" 2>/dev/null
curl -Lo "$TEMP_DIR/wimboot.zip" "http://git.ipxe.org/releases/wimboot/wimboot-latest.zip"
7z e -aoa "$TEMP_DIR/wimboot.zip" -o"$LIVE_DIR/arch/boot" 'wimboot*/LICENSE.txt' 'wimboot*/README.txt' 'wimboot*/wimboot'
# Boot config (UEFI)
mkdir -p "$LIVE_DIR/EFI/boot"
cp "/usr/share/refind/refind_x64.efi" "$LIVE_DIR/EFI/boot/bootx64.efi"
cp "$ROOT_DIR/images/rEFInd.png" "$LIVE_DIR/EFI/boot/rEFInd.png"
rsync -aI "/usr/share/refind/drivers_x64/" "$LIVE_DIR/EFI/boot/drivers_x64/"
rsync -aI "/usr/share/refind/icons/" "$LIVE_DIR/EFI/boot/icons/" --exclude "/usr/share/refind/icons/svg"
sed -i "s/%ARCHISO_LABEL%/${label}/" "$LIVE_DIR/EFI/boot/refind.conf"
# Boot config (UEFI)
mkdir -p "$LIVE_DIR/EFI/boot"
cp "/usr/share/refind/refind_x64.efi" "$LIVE_DIR/EFI/boot/bootx64.efi"
cp "$ROOT_DIR/images/rEFInd.png" "$LIVE_DIR/EFI/boot/rEFInd.png"
rsync -aI "/usr/share/refind/drivers_x64/" "$LIVE_DIR/EFI/boot/drivers_x64/"
rsync -aI "/usr/share/refind/icons/" "$LIVE_DIR/EFI/boot/icons/" --exclude "/usr/share/refind/icons/svg"
sed -i "s/%ARCHISO_LABEL%/${label}/" "$LIVE_DIR/EFI/boot/refind.conf"
# Customize_airootfs.sh
sed -i -r 's/set -e -u/set -o errexit\nset -o errtrace\nset -o nounset\nset -o pipefail/' "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Customize_airootfs.sh
sed -i -r 's/set -e -u/set -o errexit\nset -o errtrace\nset -o nounset\nset -o pipefail/' "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Memtest86
mkdir -p "$LIVE_DIR/EFI/memtest86/Benchmark"
mkdir -p "$TEMP_DIR/memtest86"
curl -Lo "$TEMP_DIR/memtest86/memtest86-usb.zip" "https://www.memtest86.com/downloads/memtest86-usb.zip"
7z e -aoa "$TEMP_DIR/memtest86/memtest86-usb.zip" -o"$TEMP_DIR/memtest86" "memtest86-usb.img"
7z e -aoa "$TEMP_DIR/memtest86/memtest86-usb.img" -o"$TEMP_DIR/memtest86" "MemTest86.img"
7z x -aoa "$TEMP_DIR/memtest86/MemTest86.img" -o"$TEMP_DIR/memtest86"
rm "$TEMP_DIR/memtest86/EFI/BOOT/BOOTIA32.efi"
mv "$TEMP_DIR/memtest86/EFI/BOOT/BOOTX64.efi" "$LIVE_DIR/EFI/memtest86/memtestx64.efi"
mv "$TEMP_DIR/memtest86/EFI/BOOT"/* "$LIVE_DIR/EFI/memtest86"/
mv "$TEMP_DIR/memtest86/help"/* "$LIVE_DIR/EFI/memtest86"/
mv "$TEMP_DIR/memtest86/license.rtf" "$LIVE_DIR/EFI/memtest86"/
# Memtest86
mkdir -p "$LIVE_DIR/EFI/memtest86/Benchmark"
mkdir -p "$TEMP_DIR/memtest86"
curl -Lo "$TEMP_DIR/memtest86/memtest86-usb.zip" "https://www.memtest86.com/downloads/memtest86-usb.zip"
7z e -aoa "$TEMP_DIR/memtest86/memtest86-usb.zip" -o"$TEMP_DIR/memtest86" "memtest86-usb.img"
7z e -aoa "$TEMP_DIR/memtest86/memtest86-usb.img" -o"$TEMP_DIR/memtest86" "MemTest86.img"
7z x -aoa "$TEMP_DIR/memtest86/MemTest86.img" -o"$TEMP_DIR/memtest86"
rm "$TEMP_DIR/memtest86/EFI/BOOT/BOOTIA32.efi"
mv "$TEMP_DIR/memtest86/EFI/BOOT/BOOTX64.efi" "$LIVE_DIR/EFI/memtest86/memtestx64.efi"
mv "$TEMP_DIR/memtest86/EFI/BOOT"/* "$LIVE_DIR/EFI/memtest86"/
mv "$TEMP_DIR/memtest86/help"/* "$LIVE_DIR/EFI/memtest86"/
mv "$TEMP_DIR/memtest86/license.rtf" "$LIVE_DIR/EFI/memtest86"/
# build.sh
if ! grep -iq 'wizardkit additions' "$LIVE_DIR/build.sh"; then
sed -i -r 's/^(run_once make_iso)$/# wizardkit additions\n\1/' "$LIVE_DIR/build.sh"
sed -i '/# wizardkit additions/r .linux_items/build_additions.txt' "$LIVE_DIR/build.sh"
fi
# build.sh
if ! grep -iq 'wizardkit additions' "$LIVE_DIR/build.sh"; then
sed -i -r 's/^(run_once make_iso)$/# wizardkit additions\n\1/' "$LIVE_DIR/build.sh"
sed -i '/# wizardkit additions/r .linux_items/build_additions.txt' "$LIVE_DIR/build.sh"
fi
# Hostname
echo "$hostname" > "$LIVE_DIR/airootfs/etc/hostname"
echo "127.0.1.1 $hostname.localdomain $hostname" >> "$LIVE_DIR/airootfs/etc/hosts"
# Hostname
echo "$hostname" > "$LIVE_DIR/airootfs/etc/hostname"
echo "127.0.1.1 $hostname.localdomain $hostname" >> "$LIVE_DIR/airootfs/etc/hosts"
# Live packages
while read -r p; do
sed -i "/$p/d" "$LIVE_DIR/packages.x86_64"
done < "$ROOT_DIR/setup/linux/packages/live_remove"
cat "$ROOT_DIR/setup/linux/packages/live_add" >> "$LIVE_DIR/packages.x86_64"
if [[ "${1:-}" == "--minimal" ]]; then
cat "$ROOT_DIR/setup/linux/packages/live_add_min" >> "$LIVE_DIR/packages.x86_64"
else
cat "$ROOT_DIR/setup/linux/packages/live_add_x" >> "$LIVE_DIR/packages.x86_64"
fi
echo "[custom]" >> "$LIVE_DIR/pacman.conf"
echo "SigLevel = Optional TrustAll" >> "$LIVE_DIR/pacman.conf"
echo "Server = file://$REPO_DIR" >> "$LIVE_DIR/pacman.conf"
echo "" >> "$LIVE_DIR/pacman.conf"
# Live packages
while read -r p; do
sed -i "/$p/d" "$LIVE_DIR/packages.x86_64"
done < "$ROOT_DIR/setup/linux/packages/live_remove"
cat "$ROOT_DIR/setup/linux/packages/live_add" >> "$LIVE_DIR/packages.x86_64"
if [[ "${1:-}" == "--minimal" ]]; then
cat "$ROOT_DIR/setup/linux/packages/live_add_min" >> "$LIVE_DIR/packages.x86_64"
else
cat "$ROOT_DIR/setup/linux/packages/live_add_x" >> "$LIVE_DIR/packages.x86_64"
fi
echo "[custom]" >> "$LIVE_DIR/pacman.conf"
echo "SigLevel = Optional TrustAll" >> "$LIVE_DIR/pacman.conf"
echo "Server = file://$REPO_DIR" >> "$LIVE_DIR/pacman.conf"
echo "" >> "$LIVE_DIR/pacman.conf"
# Mirrors
sed -i -r 's/^(.*mirrorlist.*)$/#NOPE#\1/' "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "curl -o '/etc/pacman.d/mirrorlist' '$MIRRORLIST_SOURCE'" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "sed -i 's/#Server/Server/g' /etc/pacman.d/mirrorlist" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Mirrors
sed -i -r 's/^(.*mirrorlist.*)$/#NOPE#\1/' "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "curl -o '/etc/pacman.d/mirrorlist' '$MIRRORLIST_SOURCE'" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "sed -i 's/#Server/Server/g' /etc/pacman.d/mirrorlist" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# MOTD
sed -i -r "s/_+/$KIT_NAME_FULL Linux Environment/" "$LIVE_DIR/airootfs/etc/motd"
# MOTD
sed -i -r "s/_+/$KIT_NAME_FULL Linux Environment/" "$LIVE_DIR/airootfs/etc/motd"
# Oh My ZSH
git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git "$SKEL_DIR/.oh-my-zsh"
rm -Rf "$SKEL_DIR/.oh-my-zsh/.git"
curl -o "$SKEL_DIR/.oh-my-zsh/themes/lean.zsh-theme" https://raw.githubusercontent.com/miekg/lean/master/prompt_lean_setup
# Oh My ZSH
git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git "$SKEL_DIR/.oh-my-zsh"
rm -Rf "$SKEL_DIR/.oh-my-zsh/.git"
curl -o "$SKEL_DIR/.oh-my-zsh/themes/lean.zsh-theme" https://raw.githubusercontent.com/miekg/lean/master/prompt_lean_setup
if [[ "${1:-}" != "--minimal" ]]; then
# Openbox theme
git clone --depth=1 https://github.com/addy-dclxvi/Openbox-Theme-Collections.git "$TEMP_DIR/ob-themes"
mkdir -p "$LIVE_DIR/airootfs/usr/share/themes"
cp -a "$TEMP_DIR/ob-themes/Triste-Orange" "$LIVE_DIR/airootfs/usr/share/themes/"
fi
if [[ "${1:-}" != "--minimal" ]]; then
# Openbox theme
git clone --depth=1 https://github.com/addy-dclxvi/Openbox-Theme-Collections.git "$TEMP_DIR/ob-themes"
mkdir -p "$LIVE_DIR/airootfs/usr/share/themes"
cp -a "$TEMP_DIR/ob-themes/Triste-Orange" "$LIVE_DIR/airootfs/usr/share/themes/"
fi
# Services
sed -i -r 's/^(.*pacman-init.*)$/#NOPE#\1/' "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
sed -i -r 's/^(.*choose-mirror.*)$/#NOPE#\1/' "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Services
sed -i -r 's/^(.*pacman-init.*)$/#NOPE#\1/' "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
sed -i -r 's/^(.*choose-mirror.*)$/#NOPE#\1/' "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Shutdown stall fix
echo "sed -i -r 's/^.*(DefaultTimeoutStartSec)=.*$/\1=15s/' /etc/systemd/system.conf" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "sed -i -r 's/^.*(DefaultTimeoutStopSec)=.*$/\1=15s/' /etc/systemd/system.conf" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Shutdown stall fix
echo "sed -i -r 's/^.*(DefaultTimeoutStartSec)=.*$/\1=15s/' /etc/systemd/system.conf" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "sed -i -r 's/^.*(DefaultTimeoutStopSec)=.*$/\1=15s/' /etc/systemd/system.conf" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# SSH
mkdir -p "$SKEL_DIR/.ssh"
ssh-keygen -b 4096 -C "$username@$hostname" -N "" -f "$SKEL_DIR/.ssh/id_rsa"
echo 'rm /root/.ssh/id*' >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo 'rm /root/.zlogin' >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
sed -i -r '/.*PermitRootLogin.*/d' "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "sed -i -r '/.*PermitRootLogin.*/d' /etc/ssh/sshd_config" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
cp "$ROOT_DIR/setup/linux/authorized_keys" "$SKEL_DIR/.ssh/authorized_keys"
# SSH
mkdir -p "$SKEL_DIR/.ssh"
ssh-keygen -b 4096 -C "$username@$hostname" -N "" -f "$SKEL_DIR/.ssh/id_rsa"
echo 'rm /root/.ssh/id*' >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo 'rm /root/.zlogin' >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
sed -i -r '/.*PermitRootLogin.*/d' "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "sed -i -r '/.*PermitRootLogin.*/d' /etc/ssh/sshd_config" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
cp "$ROOT_DIR/setup/linux/authorized_keys" "$SKEL_DIR/.ssh/authorized_keys"
# Root user
echo "echo 'root:$ROOT_PASSWORD' | chpasswd" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Root user
echo "echo 'root:$ROOT_PASSWORD' | chpasswd" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Sudo
echo "echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Sudo
echo "echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Tech user
echo "groupadd -r autologin" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "useradd -m -s /bin/zsh -G autologin,power,storage,wheel -U $username" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "echo '$username:$TECH_PASSWORD' | chpasswd" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Tech user
echo "groupadd -r autologin" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "useradd -m -s /bin/zsh -G autologin,power,storage,wheel -U $username" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "echo '$username:$TECH_PASSWORD' | chpasswd" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Tech user autologin
mkdir -p "$LIVE_DIR/airootfs/etc/systemd/system/getty@tty1.service.d"
echo "[Service]" > "$LIVE_DIR/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf"
echo "ExecStart=" >> "$LIVE_DIR/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf"
echo "ExecStart=-/sbin/agetty --autologin $username --noclear %I 38400 linux" >> "$LIVE_DIR/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf"
# Tech user autologin
mkdir -p "$LIVE_DIR/airootfs/etc/systemd/system/getty@tty1.service.d"
echo "[Service]" > "$LIVE_DIR/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf"
echo "ExecStart=" >> "$LIVE_DIR/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf"
echo "ExecStart=-/sbin/agetty --autologin $username --noclear %I 38400 linux" >> "$LIVE_DIR/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf"
# Timezone
echo "ln -sf '/usr/share/zoneinfo/$LINUX_TIME_ZONE' '/etc/localtime'" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo 'sed -i "s/#FallbackNTP/NTP/" /etc/systemd/timesyncd.conf' >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Timezone
echo "ln -sf '/usr/share/zoneinfo/$LINUX_TIME_ZONE' '/etc/localtime'" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo 'sed -i "s/#FallbackNTP/NTP/" /etc/systemd/timesyncd.conf' >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# udevil fix
echo "mkdir /media" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# udevil fix
echo "mkdir /media" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
if [[ "${1:-}" != "--minimal" ]]; then
# VNC password
echo "mkdir '/home/$username/.vnc'" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "echo '$TECH_PASSWORD' | vncpasswd -f > '/home/$username/.vnc/passwd'" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
if [[ "${1:-}" != "--minimal" ]]; then
# VNC password
echo "mkdir '/home/$username/.vnc'" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
echo "echo '$TECH_PASSWORD' | vncpasswd -f > '/home/$username/.vnc/passwd'" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# Wallpaper
mkdir -p "$LIVE_DIR/airootfs/usr/share/wallpaper"
cp "$ROOT_DIR/images/Linux.png" "$LIVE_DIR/airootfs/usr/share/wallpaper/burned.in"
fi
# Wallpaper
mkdir -p "$LIVE_DIR/airootfs/usr/share/wallpaper"
cp "$ROOT_DIR/images/Linux.png" "$LIVE_DIR/airootfs/usr/share/wallpaper/burned.in"
fi
# WiFi
cp "$ROOT_DIR/setup/linux/known_networks" "$LIVE_DIR/airootfs/root/known_networks"
echo "add-known-networks --user=$username" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
# WiFi
cp "$ROOT_DIR/setup/linux/known_networks" "$LIVE_DIR/airootfs/root/known_networks"
echo "add-known-networks --user=$username" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh"
}
function update_repo() {
if [[ "$EUID" -eq 0 ]]; then
echo "This section not meant to be run as root."
echo "Aborted."
exit 1
fi
echo "Updating custom repo..."
if [[ "$EUID" -eq 0 ]]; then
echo "This section not meant to be run as root."
echo "Aborted."
exit 1
fi
echo "Updating custom repo..."
# Archive current files
if [[ -d "$REPO_DIR" ]]; then
mkdir -p "$BUILD_DIR/Archive" 2>/dev/null
archive="$BUILD_DIR/Archive/$(date "+%F_%H%M%S")"
mv -bv "$REPO_DIR" "$archive"
fi
sleep 1s
# Archive current files
if [[ -d "$REPO_DIR" ]]; then
mkdir -p "$BUILD_DIR/Archive" 2>/dev/null
archive="$BUILD_DIR/Archive/$(date "+%F_%H%M%S")"
mv -bv "$REPO_DIR" "$archive"
fi
sleep 1s
# Build custom repo packages
mkdir -p "$REPO_DIR" 2>/dev/null
mkdir -p "$TEMP_DIR" 2>/dev/null
pushd "$TEMP_DIR" >/dev/null
while read -r p; do
echo "Building: $p"
curl -LsfO https://aur.archlinux.org/cgit/aur.git/snapshot/$p.tar.gz
tar xf $p.tar.gz
pushd $p >/dev/null
makepkg -d
popd >/dev/null
mv -n $p/*xz "$REPO_DIR"/
done < "$ROOT_DIR/setup/linux/packages/aur"
# Build custom repo packages
mkdir -p "$REPO_DIR" 2>/dev/null
mkdir -p "$TEMP_DIR" 2>/dev/null
pushd "$TEMP_DIR" >/dev/null
while read -r p; do
echo "Building: $p"
curl -LsfO https://aur.archlinux.org/cgit/aur.git/snapshot/$p.tar.gz
tar xf $p.tar.gz
pushd $p >/dev/null
makepkg -d
popd >/dev/null
mv -n $p/*xz "$REPO_DIR"/
done < "$ROOT_DIR/setup/linux/packages/aur"
popd >/dev/null
# Build custom repo database
pushd "$REPO_DIR" >/dev/null
repo-add custom.db.tar.gz *xz
popd >/dev/null
# Build custom repo database
pushd "$REPO_DIR" >/dev/null
repo-add custom.db.tar.gz *xz
popd >/dev/null
}
function install_deps() {
echo "Installing dependencies..."
packages=
while read -r line; do
packages="$packages $line"
done < "$ROOT_DIR/setup/linux/packages/dependencies"
run_elevated pacman -Syu --needed --noconfirm $packages
echo "Installing dependencies..."
packages=
while read -r line; do
packages="$packages $line"
done < "$ROOT_DIR/setup/linux/packages/dependencies"
run_elevated pacman -Syu --needed --noconfirm $packages
}
function build_all() {
if [[ "$EUID" -ne 0 ]]; then
echo "This section is meant to be run as root."
echo "Aborted."
exit 1
fi
if [[ "$EUID" -ne 0 ]]; then
echo "This section is meant to be run as root."
echo "Aborted."
exit 1
fi
# Prep for build
cleanup
fix_kit_permissions
install_deps
load_settings --edit
update_repo
# Prep for build
cleanup
fix_kit_permissions
install_deps
load_settings --edit
update_repo
# Build (full)
copy_live_env
update_live_env
# Rerun script as root to start Archiso build process
run_elevated "$(realpath "$0")" --build-iso
# Cleanup
mv -nv "$LIVE_DIR" "${LIVE_DIR}.full"
perl-rename -v "s/(${KIT_NAME_SHORT}-Linux)-(${DATE}.*)/\1-Full-\2/" "$OUT_DIR"/*
# Build (full)
copy_live_env
update_live_env
# Rerun script as root to start Archiso build process
run_elevated "$(realpath "$0")" --build-iso
# Cleanup
mv -nv "$LIVE_DIR" "${LIVE_DIR}.full"
perl-rename -v "s/(${KIT_NAME_SHORT}-Linux)-(${DATE}.*)/\1-Full-\2/" "$OUT_DIR"/*
# Build (minimal)
copy_live_env --minimal
update_live_env --minimal
# Rerun script as root to start Archiso build process
run_elevated "$(realpath "$0")" --build-iso
# Cleanup
mv -nv "$LIVE_DIR" "${LIVE_DIR}.minimal"
perl-rename -v "s/(${KIT_NAME_SHORT}-Linux)-(${DATE}.*)/\1-Minimal-\2/" "$OUT_DIR"/*
# Build (minimal)
copy_live_env --minimal
update_live_env --minimal
# Rerun script as root to start Archiso build process
run_elevated "$(realpath "$0")" --build-iso
# Cleanup
mv -nv "$LIVE_DIR" "${LIVE_DIR}.minimal"
perl-rename -v "s/(${KIT_NAME_SHORT}-Linux)-(${DATE}.*)/\1-Minimal-\2/" "$OUT_DIR"/*
}
function build_iso() {
if [[ "$EUID" -ne 0 ]]; then
echo "This section is meant to be run as root."
echo "Aborted."
exit 1
fi
if [[ "$EUID" -ne 0 ]]; then
echo "This section is meant to be run as root."
echo "Aborted."
exit 1
fi
# Set permissions
echo "Setting permissions..."
chown root:root "$LIVE_DIR" -R
chmod 700 "$LIVE_DIR/airootfs/etc/skel/.ssh"
chmod 600 "$LIVE_DIR/airootfs/etc/skel/.ssh/id_rsa"
# Set permissions
echo "Setting permissions..."
chown root:root "$LIVE_DIR" -R
chmod 700 "$LIVE_DIR/airootfs/etc/skel/.ssh"
chmod 600 "$LIVE_DIR/airootfs/etc/skel/.ssh/id_rsa"
# Removing cached (and possibly outdated) custom repo packages
for package in $(cat "$ROOT_DIR/setup/linux/packages/aur"); do
for p in /var/cache/pacman/pkg/*${package}*; do
if [[ -f "${p}" ]]; then
rm "${p}"
fi
done
# Removing cached (and possibly outdated) custom repo packages
for package in $(cat "$ROOT_DIR/setup/linux/packages/aur"); do
for p in /var/cache/pacman/pkg/*${package}*; do
if [[ -f "${p}" ]]; then
rm "${p}"
fi
done
done
# Build ISO
prefix="${KIT_NAME_SHORT}-Linux"
label="${KIT_NAME_SHORT}_LINUX"
"$LIVE_DIR/build.sh" -N "$prefix" -V "$DATE" -L "$label" -w "$TEMP_DIR/Linux" -o "$OUT_DIR" -v | tee -a "$LOG_DIR/$DATETIME.log"
# Build ISO
prefix="${KIT_NAME_SHORT}-Linux"
label="${KIT_NAME_SHORT}_LINUX"
"$LIVE_DIR/build.sh" -N "$prefix" -V "$DATE" -L "$label" -w "$TEMP_DIR/Linux" -o "$OUT_DIR" -v | tee -a "$LOG_DIR/$DATETIME.log"
# Cleanup
echo "Removing temp files..."
rm "$TEMP_DIR/Linux" -Rf | tee -a "$LOG_DIR/$DATETIME.log"
# Cleanup
echo "Removing temp files..."
rm "$TEMP_DIR/Linux" -Rf | tee -a "$LOG_DIR/$DATETIME.log"
echo "Reverting permissions..."
chown $REAL_USER:$REAL_USER "$LIVE_DIR" -R
chown $REAL_USER:$REAL_USER "$OUT_DIR" -R
echo "Reverting permissions..."
chown $REAL_USER:$REAL_USER "$LIVE_DIR" -R
chown $REAL_USER:$REAL_USER "$OUT_DIR" -R
}
function build_full() {
if [[ "$EUID" -eq 0 ]]; then
echo "This section not meant to be run as root."
echo "Aborted."
exit 1
fi
if [[ "$EUID" -eq 0 ]]; then
echo "This section not meant to be run as root."
echo "Aborted."
exit 1
fi
# Prep for build
cleanup
fix_kit_permissions
install_deps
load_settings --edit
update_repo
copy_live_env
update_live_env
# Rerun script as root to start Archiso build process
run_elevated "$(realpath "$0")" --build-iso
# Cleanup
perl-rename -v "s/(${KIT_NAME_SHORT}-Linux)-(${DATE}.*)/\1-Full-\2/" "$OUT_DIR"/*
# Prep for build
cleanup
fix_kit_permissions
install_deps
load_settings --edit
update_repo
copy_live_env
update_live_env
# Rerun script as root to start Archiso build process
run_elevated "$(realpath "$0")" --build-iso
# Cleanup
perl-rename -v "s/(${KIT_NAME_SHORT}-Linux)-(${DATE}.*)/\1-Full-\2/" "$OUT_DIR"/*
}
function build_minimal() {
if [[ "$EUID" -eq 0 ]]; then
echo "This section not meant to be run as root."
echo "Aborted."
exit 1
fi
if [[ "$EUID" -eq 0 ]]; then
echo "This section not meant to be run as root."
echo "Aborted."
exit 1
fi
# Prep for build
cleanup
fix_kit_permissions
install_deps
load_settings --edit
update_repo
copy_live_env --minimal
update_live_env --minimal
# Rerun script as root to start Archiso build process
run_elevated "$(realpath "$0")" --build-iso
# Cleanup
perl-rename -v "s/(${KIT_NAME_SHORT}-Linux)-(${DATE}.*)/\1-Minimal-\2/" "$OUT_DIR"/*
# Prep for build
cleanup
fix_kit_permissions
install_deps
load_settings --edit
update_repo
copy_live_env --minimal
update_live_env --minimal
# Rerun script as root to start Archiso build process
run_elevated "$(realpath "$0")" --build-iso
# Cleanup
perl-rename -v "s/(${KIT_NAME_SHORT}-Linux)-(${DATE}.*)/\1-Minimal-\2/" "$OUT_DIR"/*
}
# Check input
case ${1:-} in
-a|--build-all)
build_all
echo Done
;;
-a|--build-all)
build_all
echo Done
;;
-b|--build-full)
build_full
echo Done
;;
-b|--build-full)
build_full
echo Done
;;
-f|--fix-perms)
fix_kit_permissions
echo Done
;;
-f|--fix-perms)
fix_kit_permissions
echo Done
;;
-i|--install-deps)
install_deps
echo Done
;;
-i|--install-deps)
install_deps
echo Done
;;
-m|--prep-minimal-env)
load_settings --edit
copy_live_env --minimal
update_live_env --minimal
echo Done
;;
-m|--prep-minimal-env)
load_settings --edit
copy_live_env --minimal
update_live_env --minimal
echo Done
;;
-o|--build-iso)
load_settings
build_iso
echo Done
;;
-o|--build-iso)
load_settings
build_iso
echo Done
;;
-p|--prep-live-env)
load_settings --edit
copy_live_env
update_live_env
echo Done
;;
-p|--prep-live-env)
load_settings --edit
copy_live_env
update_live_env
echo Done
;;
-u|--update-repo)
update_repo
echo Done
;;
-u|--update-repo)
update_repo
echo Done
;;
*)
echo "Usage: $(basename "$0") [OPTIONS]"
echo ""
echo "Options:"
echo " -a --build-all Perform all tasks to build all isos"
echo " -b --build-full Perform all tasks to build the full iso"
echo " -m --build-minimal Perform all tasks to build the minimal iso"
echo " -h --help Show usage"
echo ""
echo "Advanced options:"
echo " -f --fix-perms Fix folder permissions"
echo " -i --install-deps Install build dependencies"
echo " -n --prep-minimal-env Prep live & airootfs folders (minimal packages)"
echo " -o --build-iso Build ISO (using current setup)"
echo " -p --prep-live-env Prep live & airootfs folders"
echo " -u --update-repo Update custom pacman repo"
;;
*)
echo "Usage: $(basename "$0") [OPTIONS]"
echo ""
echo "Options:"
echo " -a --build-all Perform all tasks to build all isos"
echo " -b --build-full Perform all tasks to build the full iso"
echo " -m --build-minimal Perform all tasks to build the minimal iso"
echo " -h --help Show usage"
echo ""
echo "Advanced options:"
echo " -f --fix-perms Fix folder permissions"
echo " -i --install-deps Install build dependencies"
echo " -n --prep-minimal-env Prep live & airootfs folders (minimal packages)"
echo " -o --build-iso Build ISO (using current setup)"
echo " -p --prep-live-env Prep live & airootfs folders"
echo " -u --update-repo Update custom pacman repo"
;;
esac

View file

@ -36,9 +36,9 @@ rem Edited by: https://stackoverflow.com/users/330315/a-horse-with-no-name
rem Answer by: https://stackoverflow.com/users/3198799/and31415
fsutil dirty query %systemdrive% >nul
if %errorlevel% neq 0 (
call :RequestElevation
rem reset errorlevel to 1 to abort the current non-elevated script
color 00
call :RequestElevation
rem reset errorlevel to 1 to abort the current non-elevated script
color 00
)
@exit /b %errorlevel%
@ -46,7 +46,7 @@ if %errorlevel% neq 0 (
rem Loops through all arguments to check for accepted flags
set DEBUG=
for %%f in (%*) do (
if /i "%%f" == "/DEBUG" (@echo on & set "DEBUG=/DEBUG")
if /i "%%f" == "/DEBUG" (@echo on & set "DEBUG=/DEBUG")
)
@exit /b 0
@ -59,12 +59,12 @@ rem Check registry for WADK
set "r_path=HKLM\Software\Wow6432Node\Microsoft\Windows Kits\Installed Roots"
reg query "%r_path%" /v %r_vname% >nul 2>&1 && set "found=True"
if not defined found (
rem 32-bit systems?
set "r_path=HKLM\Software\Microsoft\Windows Kits\Installed Roots"
reg query "!r_path!" /v %r_vname% >nul 2>&1 && set "found=True"
rem 32-bit systems?
set "r_path=HKLM\Software\Microsoft\Windows Kits\Installed Roots"
reg query "!r_path!" /v %r_vname% >nul 2>&1 && set "found=True"
)
for /f "skip=2 tokens=2*" %%i in ('reg query "%r_path%" /v %r_vname%') do (
set adk_root=%%j\Assessment and Deployment Kit
set adk_root=%%j\Assessment and Deployment Kit
)
rem Set errorlevel if necessary
if not defined adk_root color 00

View file

@ -35,7 +35,7 @@ goto Exit
rem Loops through all arguments to check for accepted flags
set DEBUG=
for %%f in (%*) do (
if /i "%%f" == "/DEBUG" (@echo on & set "DEBUG=/DEBUG")
if /i "%%f" == "/DEBUG" (@echo on & set "DEBUG=/DEBUG")
)
@exit /b 0