forked from fauxpilot/fauxpilot
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshutdown.ps1
67 lines (58 loc) · 1.54 KB
/
shutdown.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
#!/usr/bin/env -S pwsh -nop
#requires -version 5
<#PSScriptInfo
.VERSION 0.0.1
.GUID
.AUTHOR Rowe Wilson Frederisk Holme
.PROJECTURI https://github.com/Frederisk/fauxpilot-windows
.COMPANYNAME
.COPYRIGHT
.TAGS
.LICENSEURI https://github.com/Frederisk/fauxpilot-windows/blob/main/LICENSE.txt
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
#>
<#
.SYNOPSIS
fauxpilot-windows-shutdown - Stop fauxpilot in Windows.
.DESCRIPTION
.PARAMETER Help
Display the full help message.
.INPUTS
System.String
.OUTPUTS
System.Object
.NOTES
#>
using namespace System;
using namespace System.Management.Automation;
using namespace System.IO;
[CmdletBinding()]
param (
[Switch][Alias('h')]$Help
)
if ($Help) {
Get-Help -Name ($MyInvocation.MyCommand.Definition) -Full | Out-Host;
exit 0;
}
Write-Verbose -Message 'Read in .env file' | Out-Null;
Get-Content -Path '.env' -Encoding utf8NoBOM | ForEach-Object -Process {
$name, $value = $_.Split('=');
Write-Verbose -Message "Name: $name, Value: $value" | Out-Null;
# Set-Variable -Name $name -Value $value;
[Environment]::SetEnvironmentVariable($name, $value);
}
try {
[ApplicationInfo]$docker = Get-Command -Name 'docker';
Write-Verbose -Message 'up with docker compose';
&$docker compose down --remove-orphans;
}
catch {
Write-Verbose -Message $_.ToString();
[ApplicationInfo]$dockerCompose = Get-Command -Name 'docker-compose';
Write-Verbose -Message 'up with docker-compose';
&$dockerCompose down --remove-orphans;
}