mirror of
https://github.com/bitwarden/server.git
synced 2024-11-25 12:45:18 +01:00
format PowerShell scripts
This commit is contained in:
parent
dfb5890bdf
commit
4d33b3e1da
@ -36,8 +36,8 @@ echo ""
|
||||
|
||||
$scriptPath = $MyInvocation.MyCommand.Path
|
||||
$dir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
if($output -eq "") {
|
||||
$output="${dir}\bwdata"
|
||||
if ($output -eq "") {
|
||||
$output = "${dir}\bwdata"
|
||||
}
|
||||
|
||||
$scriptsDir = "${output}\scripts"
|
||||
@ -52,50 +52,50 @@ function Download-Self {
|
||||
}
|
||||
|
||||
function Download-Run-File {
|
||||
if(!(Test-Path -Path $scriptsDir)) {
|
||||
if (!(Test-Path -Path $scriptsDir)) {
|
||||
New-Item -ItemType directory -Path $scriptsDir | Out-Null
|
||||
}
|
||||
Invoke-RestMethod -OutFile $scriptsDir\run.ps1 -Uri "${githubBaseUrl}/scripts/run.ps1"
|
||||
}
|
||||
|
||||
function Check-Output-Dir-Exists {
|
||||
if(!(Test-Path -Path $output)) {
|
||||
if (!(Test-Path -Path $output)) {
|
||||
throw "Cannot find a bitwarden installation at $output."
|
||||
}
|
||||
}
|
||||
|
||||
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."
|
||||
}
|
||||
}
|
||||
|
||||
# Commands
|
||||
|
||||
if($install) {
|
||||
if ($install) {
|
||||
Check-Output-Dir-Not-Exists
|
||||
New-Item -ItemType directory -Path $output | Out-Null
|
||||
Download-Run-File
|
||||
Invoke-Expression "$scriptsDir\run.ps1 -install -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
|
||||
}
|
||||
elseif($start -Or $restart) {
|
||||
elseif ($start -Or $restart) {
|
||||
Check-Output-Dir-Exists
|
||||
Invoke-Expression "$scriptsDir\run.ps1 -restart -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
|
||||
}
|
||||
elseif($update) {
|
||||
elseif ($update) {
|
||||
Check-Output-Dir-Exists
|
||||
Download-Run-File
|
||||
Invoke-Expression "$scriptsDir\run.ps1 -update -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
|
||||
}
|
||||
elseif($updatedb) {
|
||||
elseif ($updatedb) {
|
||||
Check-Output-Dir-Exists
|
||||
Invoke-Expression "$scriptsDir\run.ps1 -updatedb -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
|
||||
}
|
||||
elseif($stop) {
|
||||
elseif ($stop) {
|
||||
Check-Output-Dir-Exists
|
||||
Invoke-Expression "$scriptsDir\run.ps1 -stop -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
|
||||
}
|
||||
elseif($updateself) {
|
||||
elseif ($updateself) {
|
||||
Download-Self
|
||||
echo "Updated self."
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ param (
|
||||
|
||||
# Setup
|
||||
|
||||
$dockerDir="${outputDir}\docker"
|
||||
$dockerDir = "${outputDir}\docker"
|
||||
|
||||
# Functions
|
||||
|
||||
@ -23,23 +23,23 @@ function Install() {
|
||||
[string]$domain = $( Read-Host "Enter the domain name for your bitwarden instance (ex. bitwarden.company.com)" )
|
||||
echo ""
|
||||
|
||||
if($domain -eq "") {
|
||||
if ($domain -eq "") {
|
||||
$domain = "localhost"
|
||||
}
|
||||
|
||||
if($domain -ne "localhost") {
|
||||
if ($domain -ne "localhost") {
|
||||
Write-Host "(!) " -f cyan -nonewline
|
||||
$letsEncrypt = $( Read-Host "Do you want to use Let's Encrypt to generate a free SSL certificate? (y/n)" )
|
||||
echo ""
|
||||
|
||||
if($letsEncrypt -eq "y") {
|
||||
if ($letsEncrypt -eq "y") {
|
||||
Write-Host "(!) " -f cyan -nonewline
|
||||
[string]$email = $( Read-Host "Enter your email address (Let's Encrypt will send you certificate " +
|
||||
"expiration reminders)" )
|
||||
echo ""
|
||||
|
||||
$letsEncryptPath = "${outputDir}/letsencrypt"
|
||||
if(!(Test-Path -Path $letsEncryptPath )){
|
||||
if (!(Test-Path -Path $letsEncryptPath )) {
|
||||
New-Item -ItemType directory -Path $letsEncryptPath | Out-Null
|
||||
}
|
||||
docker pull certbot/certbot
|
||||
@ -60,7 +60,7 @@ function Install() {
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
else {
|
||||
@ -69,7 +69,7 @@ function Docker-Compose-Up {
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
else {
|
||||
@ -78,7 +78,7 @@ function Docker-Compose-Down {
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
else {
|
||||
@ -92,7 +92,7 @@ function Docker-Prune {
|
||||
}
|
||||
|
||||
function Update-Lets-Encrypt {
|
||||
if(Test-Path -Path "${outputDir}\letsencrypt\live") {
|
||||
if (Test-Path -Path "${outputDir}\letsencrypt\live") {
|
||||
docker pull certbot/certbot
|
||||
docker run -it --rm --name certbot -p 443:443 -p 80:80 `
|
||||
-v $outputDir/letsencrypt:/etc/letsencrypt/ certbot/certbot `
|
||||
@ -135,22 +135,22 @@ function Pull-Setup {
|
||||
|
||||
# Commands
|
||||
|
||||
if($install) {
|
||||
if ($install) {
|
||||
Install
|
||||
}
|
||||
elseif($start -Or $restart) {
|
||||
elseif ($start -Or $restart) {
|
||||
Restart
|
||||
}
|
||||
elseif($pull) {
|
||||
elseif ($pull) {
|
||||
Docker-Compose-Pull
|
||||
}
|
||||
elseif($stop) {
|
||||
elseif ($stop) {
|
||||
Docker-Compose-Down
|
||||
}
|
||||
elseif($updatedb) {
|
||||
elseif ($updatedb) {
|
||||
Update-Database
|
||||
}
|
||||
elseif($update) {
|
||||
elseif ($update) {
|
||||
Docker-Compose-Down
|
||||
Update
|
||||
Restart
|
||||
|
Loading…
Reference in New Issue
Block a user