1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-01 13:43:23 +01:00
bitwarden-server/scripts/bitwarden.ps1

113 lines
3.0 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-23 22:15:42 +02:00
[switch] $updateself,
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
2017-08-23 22:15:42 +02:00
===================================================
2017-08-19 17:51:13 +02:00
"
2017-08-23 22:29:55 +02:00
docker --version
docker-compose --version
2017-08-23 22:33:41 +02:00
echo ""
2017-08-23 22:15:42 +02:00
# Setup
2017-08-23 22:22:02 +02:00
$scriptPath = $MyInvocation.MyCommand.Path
2017-08-19 17:51:13 +02:00
$dir = Split-Path -Parent $MyInvocation.MyCommand.Path
2017-08-21 14:49:44 +02:00
if($output -eq "") {
2017-10-03 22:34:39 +02:00
$output="${dir}\bwdata"
2017-08-21 14:49:44 +02:00
}
$scriptsDir = "${output}\scripts"
2017-08-19 17:51:13 +02:00
$githubBaseUrl = "https://raw.githubusercontent.com/bitwarden/core/master"
2017-11-14 03:26:59 +01:00
$coreVersion = "1.14.1"
$webVersion = "1.20.1"
2017-08-19 17:51:13 +02:00
2017-08-23 22:15:42 +02:00
# Functions
function Download-Self {
2017-08-23 22:22:02 +02:00
Invoke-RestMethod -OutFile $scriptPath -Uri "${githubBaseUrl}/scripts/bitwarden.ps1"
2017-08-23 22:15:42 +02:00
}
function Download-Install {
2017-09-18 18:11:03 +02:00
if(!(Test-Path -Path $scriptsDir)) {
New-Item -ItemType directory -Path $scriptsDir | Out-Null
}
2017-08-23 22:15:42 +02:00
Invoke-RestMethod -OutFile $scriptsDir\install.ps1 ` -Uri "${githubBaseUrl}/scripts/install.ps1"
}
function Download-Run-File {
2017-09-18 18:11:03 +02:00
if(!(Test-Path -Path $scriptsDir)) {
New-Item -ItemType directory -Path $scriptsDir | Out-Null
}
2017-08-23 22:15:42 +02:00
Invoke-RestMethod -OutFile $scriptsDir\run.ps1 -Uri "${githubBaseUrl}/scripts/run.ps1"
}
2017-09-18 18:11:03 +02:00
function Check-Output-Dir-Exists {
if(!(Test-Path -Path $output)) {
throw "Cannot find a bitwarden installation at $output."
}
}
function Check-Output-Dir-Not-Exists {
if(Test-Path -Path $output) {
throw "Looks like bitwarden is already installed at $output."
}
2017-08-23 22:15:42 +02:00
}
# Commands
2017-08-19 17:51:13 +02:00
if($install) {
2017-09-18 18:11:03 +02:00
Check-Output-Dir-Not-Exists
New-Item -ItemType directory -Path $output | Out-Null
2017-08-23 22:15:42 +02:00
Download-Install
2017-11-09 05:51:24 +01:00
Download-Run-File
2017-11-09 04:24:23 +01:00
Invoke-Expression "$scriptsDir\install.ps1 -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
2017-08-19 17:51:13 +02:00
}
2017-08-21 17:58:15 +02:00
elseif($start -Or $restart) {
2017-09-18 18:11:03 +02:00
Check-Output-Dir-Exists
2017-11-09 04:24:23 +01:00
Invoke-Expression "$scriptsDir\run.ps1 -restart -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
2017-08-19 17:51:13 +02:00
}
elseif($update) {
2017-09-18 18:11:03 +02:00
Check-Output-Dir-Exists
2017-11-09 04:24:23 +01:00
Download-Run-File
Invoke-Expression "$scriptsDir\run.ps1 -update -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
2017-08-19 17:51:13 +02:00
}
elseif($updatedb) {
2017-09-18 18:11:03 +02:00
Check-Output-Dir-Exists
2017-11-09 04:24:23 +01:00
Invoke-Expression "$scriptsDir\run.ps1 -updatedb -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
2017-08-19 17:51:13 +02:00
}
2017-08-21 15:39:12 +02:00
elseif($stop) {
2017-09-18 18:11:03 +02:00
Check-Output-Dir-Exists
2017-11-09 04:24:23 +01:00
Invoke-Expression "$scriptsDir\run.ps1 -stop -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
2017-08-23 22:15:42 +02:00
}
elseif($updateself) {
Download-Self
echo "Updated self."
2017-08-21 15:39:12 +02:00
}
2017-08-19 17:51:13 +02:00
else {
echo "No command found."
}