Skip to content

Commit

Permalink
installer worky
Browse files Browse the repository at this point in the history
  • Loading branch information
reisir committed Apr 30, 2023
1 parent ce1b5d7 commit 88db3b9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
Binary file added @Resources/installed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added @Resources/vine_boom.wav
Binary file not shown.
12 changes: 10 additions & 2 deletions Installer.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ OnRefreshAction=[!CommandMeasure Powershell Run]
[\]
@Include=#@#Mond.inc

[Variables]
LogFile=mond.log

[Powershell]
Measure=Plugin
Plugin=RunCommand
Parameter=mond -FirstTimeInstall -SkinPath '#SKINSPATH#'
State=Show
OutputFile=mond.log
OutputFile=#LogFile#
OutputType=UTF8
FinishAction=[!Log "Installed!!"][!ShowMeter Installed][!UpdateMeter *][!Redraw][Play "#@#vine_boom.wav"][!Delay 548]["#ROOTCONFIGPATH##LogFile#"][!DeactivateConfig]

[Splash]
Meter=Image
ImageName=#@#splash.png

[Installed]
Meter=Image
ImageName=#@#installed.png
Hidden=1
46 changes: 44 additions & 2 deletions MetersOnDemand.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,48 @@ function ToIteratable {
return $Members
}

function InstallMonD {

# https://github.com/ThePoShWolf/Utilities/blob/master/Misc/Set-PathVariable.ps1
# Added |^$ to filter out empty items in $arrPath
# Removed the $Scope param and added a static [System.EnvironmentVariableTarget]::User
function Set-PathVariable {
param (
[string]$AddPath,
[string]$RemovePath
)

$Scope = [System.EnvironmentVariableTarget]::User

$regexPaths = @()
if ($PSBoundParameters.Keys -contains 'AddPath') {
$regexPaths += [regex]::Escape($AddPath)
}

if ($PSBoundParameters.Keys -contains 'RemovePath') {
$regexPaths += [regex]::Escape($RemovePath)
}

$arrPath = [System.Environment]::GetEnvironmentVariable('PATH', $Scope) -split ';'
foreach ($path in $regexPaths) {
$arrPath = $arrPath | Where-Object { $_ -notMatch "^$path\\?|^$" }
}
$value = ($arrPath + $addPath) -join ';'
[System.Environment]::SetEnvironmentVariable('PATH', $value, $Scope)
}

function InstallMonD {

Write-Host "DEBUG INFORMATION"
Write-Host "/////////////////"
Write-Host "Self: " -NoNewline
Write-Host $Self
Write-Host "PSScriptRoot: " -NoNewline
Write-Host $PSScriptRoot
Write-Host "SkinPath: " -NoNewline
Write-Host $SkinPath
Write-Host "/////////////////"

Write-Host "`nInstalling MonD..."

# Remove trailing \
$SkinPath = $SkinPath -replace "\\$", ""
Expand All @@ -447,11 +485,15 @@ function InstallMonD {
if (!(Test-Path $SkinPath)) { throw "SkinPath doesn't exist???" }
if (!(Test-Path $InstallPath)) { New-Item -ItemType Directory -Path $InstallPath }

Write-Host "`nCopying '$($Self.FileName)' & '$($Self.BatFileName)' to '$InstallPath'"

Copy-Item -Path "$PSScriptRoot\$($Self.FileName)" -Destination $InstallPath
Copy-Item -Path "$PSScriptRoot\$($Self.BatFileName)" -Destination $InstallPath

# TODO: Add $InstallPath to PATH
Write-Host "`nAdding '$InstallPath' to PATH"
Set-PathVariable -AddPath $InstallPath

Write-Host "`nSuccessfully installed MonD $($Self.Version)"
}

# Main body
Expand Down

0 comments on commit 88db3b9

Please sign in to comment.