1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-22 12:15:36 +01:00
bitwarden-server/scripts/bitwarden.ps1

84 lines
2.7 KiB
PowerShell
Raw Normal View History

2017-08-19 17:51:13 +02:00
param (
[switch] $install,
2017-08-21 17:58:15 +02:00
[switch] $start,
2017-08-21 15:40:10 +02:00
[switch] $restart,
2017-08-21 15:39:12 +02:00
[switch] $stop,
2017-08-19 17:51:13 +02:00
[switch] $update,
[switch] $updatedb,
2017-08-21 14:49:44 +02:00
[string] $output = ""
2017-08-19 17:51:13 +02:00
)
2017-08-21 16:58:00 +02:00
$year = (Get-Date).year
2017-08-19 17:51:13 +02:00
Write-Host @'
_ _ _ _
| |__ (_) |___ ____ _ _ __ __| | ___ _ __
| '_ \| | __\ \ /\ / / _` | '__/ _` |/ _ \ '_ \
| |_) | | |_ \ V V / (_| | | | (_| | __/ | | |
|_.__/|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_|
'@
Write-Host "
Open source password management solutions
2017-08-21 16:58:00 +02:00
Copyright 2015-${year}, 8bit Solutions LLC
2017-08-19 17:51:13 +02:00
https://bitwarden.com, https://github.com/bitwarden
"
$dir = Split-Path -Parent $MyInvocation.MyCommand.Path
2017-08-21 14:49:44 +02:00
if($output -eq "") {
$output="${dir}\bitwarden"
}
if(!(Test-Path -Path $output)) {
New-Item -ItemType directory -Path $output | Out-Null
}
$scriptsDir = "${output}\scripts"
$dockerDir = "${output}\docker"
2017-08-19 17:51:13 +02:00
$githubBaseUrl = "https://raw.githubusercontent.com/bitwarden/core/master"
2017-08-21 15:07:24 +02:00
if(!(Test-Path -Path $scriptsDir)) {
New-Item -ItemType directory -Path $scriptsDir | Out-Null
}
2017-08-19 17:51:13 +02:00
function Download-Run-Files {
2017-08-21 17:58:15 +02:00
Invoke-RestMethod -OutFile $scriptsDir\start.ps1 -Uri "${githubBaseUrl}/scripts/start.ps1"
2017-08-21 15:39:12 +02:00
Invoke-RestMethod -OutFile $scriptsDir\stop.ps1 -Uri "${githubBaseUrl}/scripts/stop.ps1"
2017-08-19 23:59:04 +02:00
Invoke-RestMethod -OutFile $dockerDir\docker-compose.yml -Uri "${githubBaseUrl}/docker/docker-compose.yml"
2017-08-21 14:49:44 +02:00
Invoke-RestMethod -OutFile $dockerDir\docker-compose.macwin.yml ` -Uri "${githubBaseUrl}/docker/docker-compose.macwin.yml"
2017-08-19 23:59:04 +02:00
Invoke-RestMethod -OutFile $dockerDir\global.env -Uri "${githubBaseUrl}/docker/global.env"
Invoke-RestMethod -OutFile $dockerDir\mssql.env -Uri "${githubBaseUrl}/docker/mssql.env"
2017-08-19 17:51:13 +02:00
}
if($install) {
2017-08-21 14:49:44 +02:00
Invoke-RestMethod -OutFile $scriptsDir\install.ps1 ` -Uri "${githubBaseUrl}/scripts/install.ps1"
2017-08-21 15:07:24 +02:00
Invoke-Expression "$scriptsDir\install.ps1 -outputDir $output"
2017-08-19 17:51:13 +02:00
}
2017-08-21 17:58:15 +02:00
elseif($start -Or $restart) {
2017-08-21 14:49:44 +02:00
if(!(Test-Path -Path $dockerDir)) {
2017-08-19 17:51:13 +02:00
New-Item -ItemType directory -Path $dockerDir | Out-Null
Download-Run-Files
}
2017-08-21 17:58:15 +02:00
Invoke-Expression "$scriptsDir\start.ps1 -outputDir $output -dockerDir $dockerDir"
2017-08-19 17:51:13 +02:00
}
elseif($update) {
2017-08-21 14:49:44 +02:00
if(Test-Path -Path $dockerDir) {
2017-08-19 17:51:13 +02:00
Remove-Item -Recurse -Force $dockerDir | Out-Null
}
New-Item -ItemType directory -Path $dockerDir | Out-Null
Download-Run-Files
2017-08-21 17:58:15 +02:00
Invoke-Expression "$scriptsDir\start.ps1 -outputDir $output -dockerDir $dockerDir"
2017-08-19 17:51:13 +02:00
}
elseif($updatedb) {
2017-08-21 14:49:44 +02:00
Invoke-RestMethod -OutFile $scriptsDir\update-db.ps1 -Uri "${githubBaseUrl}/scripts/update-db.ps1"
2017-08-21 15:07:24 +02:00
Invoke-Expression "$scriptsDir\update-db.ps1 -outputDir $output"
2017-08-19 17:51:13 +02:00
}
2017-08-21 15:39:12 +02:00
elseif($stop) {
Invoke-Expression "$scriptsDir\stop.ps1 -dockerDir $dockerDir"
}
2017-08-19 17:51:13 +02:00
else {
echo "No command found."
}