1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-28 13:15:12 +01:00

format PowerShell scripts

This commit is contained in:
Kyle Spearrin 2018-05-31 13:43:04 -04:00
parent dfb5890bdf
commit 4d33b3e1da
2 changed files with 26 additions and 26 deletions

View File

@ -36,8 +36,8 @@ echo ""
$scriptPath = $MyInvocation.MyCommand.Path $scriptPath = $MyInvocation.MyCommand.Path
$dir = Split-Path -Parent $MyInvocation.MyCommand.Path $dir = Split-Path -Parent $MyInvocation.MyCommand.Path
if($output -eq "") { if ($output -eq "") {
$output="${dir}\bwdata" $output = "${dir}\bwdata"
} }
$scriptsDir = "${output}\scripts" $scriptsDir = "${output}\scripts"
@ -52,50 +52,50 @@ function Download-Self {
} }
function Download-Run-File { function Download-Run-File {
if(!(Test-Path -Path $scriptsDir)) { if (!(Test-Path -Path $scriptsDir)) {
New-Item -ItemType directory -Path $scriptsDir | Out-Null New-Item -ItemType directory -Path $scriptsDir | Out-Null
} }
Invoke-RestMethod -OutFile $scriptsDir\run.ps1 -Uri "${githubBaseUrl}/scripts/run.ps1" Invoke-RestMethod -OutFile $scriptsDir\run.ps1 -Uri "${githubBaseUrl}/scripts/run.ps1"
} }
function Check-Output-Dir-Exists { function Check-Output-Dir-Exists {
if(!(Test-Path -Path $output)) { if (!(Test-Path -Path $output)) {
throw "Cannot find a bitwarden installation at $output." throw "Cannot find a bitwarden installation at $output."
} }
} }
function Check-Output-Dir-Not-Exists { function Check-Output-Dir-Not-Exists {
if(Test-Path -Path $output) { if (Test-Path -Path $output) {
throw "Looks like bitwarden is already installed at $output." throw "Looks like bitwarden is already installed at $output."
} }
} }
# Commands # Commands
if($install) { if ($install) {
Check-Output-Dir-Not-Exists Check-Output-Dir-Not-Exists
New-Item -ItemType directory -Path $output | Out-Null New-Item -ItemType directory -Path $output | Out-Null
Download-Run-File Download-Run-File
Invoke-Expression "$scriptsDir\run.ps1 -install -outputDir $output -coreVersion $coreVersion -webVersion $webVersion" Invoke-Expression "$scriptsDir\run.ps1 -install -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
} }
elseif($start -Or $restart) { elseif ($start -Or $restart) {
Check-Output-Dir-Exists Check-Output-Dir-Exists
Invoke-Expression "$scriptsDir\run.ps1 -restart -outputDir $output -coreVersion $coreVersion -webVersion $webVersion" Invoke-Expression "$scriptsDir\run.ps1 -restart -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
} }
elseif($update) { elseif ($update) {
Check-Output-Dir-Exists Check-Output-Dir-Exists
Download-Run-File Download-Run-File
Invoke-Expression "$scriptsDir\run.ps1 -update -outputDir $output -coreVersion $coreVersion -webVersion $webVersion" Invoke-Expression "$scriptsDir\run.ps1 -update -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
} }
elseif($updatedb) { elseif ($updatedb) {
Check-Output-Dir-Exists Check-Output-Dir-Exists
Invoke-Expression "$scriptsDir\run.ps1 -updatedb -outputDir $output -coreVersion $coreVersion -webVersion $webVersion" Invoke-Expression "$scriptsDir\run.ps1 -updatedb -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
} }
elseif($stop) { elseif ($stop) {
Check-Output-Dir-Exists Check-Output-Dir-Exists
Invoke-Expression "$scriptsDir\run.ps1 -stop -outputDir $output -coreVersion $coreVersion -webVersion $webVersion" Invoke-Expression "$scriptsDir\run.ps1 -stop -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
} }
elseif($updateself) { elseif ($updateself) {
Download-Self Download-Self
echo "Updated self." echo "Updated self."
} }

View File

@ -13,7 +13,7 @@ param (
# Setup # Setup
$dockerDir="${outputDir}\docker" $dockerDir = "${outputDir}\docker"
# Functions # Functions
@ -23,23 +23,23 @@ function Install() {
[string]$domain = $( Read-Host "Enter the domain name for your bitwarden instance (ex. bitwarden.company.com)" ) [string]$domain = $( Read-Host "Enter the domain name for your bitwarden instance (ex. bitwarden.company.com)" )
echo "" echo ""
if($domain -eq "") { if ($domain -eq "") {
$domain = "localhost" $domain = "localhost"
} }
if($domain -ne "localhost") { if ($domain -ne "localhost") {
Write-Host "(!) " -f cyan -nonewline Write-Host "(!) " -f cyan -nonewline
$letsEncrypt = $( Read-Host "Do you want to use Let's Encrypt to generate a free SSL certificate? (y/n)" ) $letsEncrypt = $( Read-Host "Do you want to use Let's Encrypt to generate a free SSL certificate? (y/n)" )
echo "" echo ""
if($letsEncrypt -eq "y") { if ($letsEncrypt -eq "y") {
Write-Host "(!) " -f cyan -nonewline Write-Host "(!) " -f cyan -nonewline
[string]$email = $( Read-Host "Enter your email address (Let's Encrypt will send you certificate " + [string]$email = $( Read-Host "Enter your email address (Let's Encrypt will send you certificate " +
"expiration reminders)" ) "expiration reminders)" )
echo "" echo ""
$letsEncryptPath = "${outputDir}/letsencrypt" $letsEncryptPath = "${outputDir}/letsencrypt"
if(!(Test-Path -Path $letsEncryptPath )){ if (!(Test-Path -Path $letsEncryptPath )) {
New-Item -ItemType directory -Path $letsEncryptPath | Out-Null New-Item -ItemType directory -Path $letsEncryptPath | Out-Null
} }
docker pull certbot/certbot docker pull certbot/certbot
@ -60,7 +60,7 @@ function Install() {
} }
function Docker-Compose-Up { function Docker-Compose-Up {
if(Test-Path -Path "${dockerDir}\docker-compose.override.yml" -PathType leaf) { if (Test-Path -Path "${dockerDir}\docker-compose.override.yml" -PathType leaf) {
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.override.yml up -d docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.override.yml up -d
} }
else { else {
@ -69,7 +69,7 @@ function Docker-Compose-Up {
} }
function Docker-Compose-Down { function Docker-Compose-Down {
if(Test-Path -Path "${dockerDir}\docker-compose.override.yml" -PathType leaf) { if (Test-Path -Path "${dockerDir}\docker-compose.override.yml" -PathType leaf) {
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.override.yml down docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.override.yml down
} }
else { else {
@ -78,7 +78,7 @@ function Docker-Compose-Down {
} }
function Docker-Compose-Pull { function Docker-Compose-Pull {
if(Test-Path -Path "${dockerDir}\docker-compose.override.yml" -PathType leaf) { if (Test-Path -Path "${dockerDir}\docker-compose.override.yml" -PathType leaf) {
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.override.yml pull docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.override.yml pull
} }
else { else {
@ -92,7 +92,7 @@ function Docker-Prune {
} }
function Update-Lets-Encrypt { function Update-Lets-Encrypt {
if(Test-Path -Path "${outputDir}\letsencrypt\live") { if (Test-Path -Path "${outputDir}\letsencrypt\live") {
docker pull certbot/certbot docker pull certbot/certbot
docker run -it --rm --name certbot -p 443:443 -p 80:80 ` docker run -it --rm --name certbot -p 443:443 -p 80:80 `
-v $outputDir/letsencrypt:/etc/letsencrypt/ certbot/certbot ` -v $outputDir/letsencrypt:/etc/letsencrypt/ certbot/certbot `
@ -135,22 +135,22 @@ function Pull-Setup {
# Commands # Commands
if($install) { if ($install) {
Install Install
} }
elseif($start -Or $restart) { elseif ($start -Or $restart) {
Restart Restart
} }
elseif($pull) { elseif ($pull) {
Docker-Compose-Pull Docker-Compose-Pull
} }
elseif($stop) { elseif ($stop) {
Docker-Compose-Down Docker-Compose-Down
} }
elseif($updatedb) { elseif ($updatedb) {
Update-Database Update-Database
} }
elseif($update) { elseif ($update) {
Docker-Compose-Down Docker-Compose-Down
Update Update
Restart Restart