-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.ps1
139 lines (106 loc) · 3.37 KB
/
install.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Test-CommandAvailable, Write-InstallInfo, Deny-Install and Test-IsAdministrator are all from: https://raw.githubusercontent.com/scoopinstaller/install/master/install.ps1
param(
[Parameter(Mandatory = $False, Position = 0)]
[Bool] $vlc = $False
)
function Test-CommandAvailable {
param (
[Parameter(Mandatory = $True, Position = 0)]
[String] $Command
)
return [Boolean](Get-Command $Command -ErrorAction SilentlyContinue)
}
function Write-InstallInfo {
param(
[Parameter(Mandatory = $True, Position = 0)]
[String] $String
)
Write-Output "`n$String`n"
}
function Test-IsAdministrator {
return ([Security.Principal.WindowsPrincipal]`
[Security.Principal.WindowsIdentity]::GetCurrent()`
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
function Deny-Install {
param(
[String] $message,
[Int] $errorCode = 1
)
Write-InstallInfo $message
break
}
$manager = "scoop"
if (Test-CommandAvailable("scoop")) {
$manager = "scoop"
Write-InstallInfo "Using scoop"
}
elseif (Test-CommandAvailable("choco")) {
$manager = "choco"
Write-InstallInfo "Using choco"
}
else {
Invoke-RestMethod -Uri "get.scoop.sh" | Invoke-Expression | Out-Null
$manager = "scoop"
Write-InstallInfo "Installed scoop"
}
function InstallDep {
param(
[Parameter(Mandatory = $True, Position = 0)]
[String] $dep,
[Parameter(Mandatory = $False, Position = 1)]
[String] $bucket = $null
)
if ($bucket -and $manager -eq "scoop") {
if (-Not (Test-CommandAvailable("git"))) {
scoop install git
Write-InstallInfo "Installed git for $bucket"
}
scoop bucket add $bucket
}
if ($manager -eq "scoop") {
Invoke-Expression "$manager install $dep"
} else {
if (Test-IsAdministrator) {
Invoke-Expression "$manager install $dep -y"
}
else {
start-process powershell -Verb "runas" -ArgumentList "-noexit -command 'Invoke-Expression '$manager install $dep -y'"
}
}
Write-InstallInfo "Installed $dep"
}
function Prechecks {
if (Test-CommandAvailable("mov-cli")) {
Deny-Install "mov-cli is already installed"
}
if (-Not (Test-CommandAvailable("python"))) {
InstallDep "python"
} else {
$PackageFullName = (Get-AppxPackage -Name "PythonSoftwareFoundation.Python.*").PackageFullName
if ($PackageFullName) {
Write-InstallInfo "You got Python from the Microsoft Store. We highly recommend installing a normal installation of Python"
$ms_python = Read-Host -Prompt "Remove ms-store python (y/n)?"
if ($ms_python.ToLower() -eq "y") {
Remove-AppxPackage -Package $PackageFullName
InstallDep "python"
}
}
}
if (-Not (Test-CommandAvailable("vlc")) -and $vlc -eq $true) {
InstallDep "vlc" "extras"
}
elseif (-Not (Test-CommandAvailable("mpv")) -and $vlc -eq $false) {
InstallDep "mpv" "extras"
}
if (-Not (Test-CommandAvailable("fzf"))) {
InstallDep "fzf"
}
}
Prechecks
if ($manager -eq "choco") {
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv
}
pip install mov-cli
Write-InstallInfo "mov-cli installed. >.<"