1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00

self host script updates

This commit is contained in:
Kyle Spearrin 2017-11-08 22:24:23 -05:00
parent 78b28061b2
commit 8944c49484
11 changed files with 76 additions and 229 deletions

View File

@ -1,34 +0,0 @@
version: '3'
services:
mssql:
volumes:
- ../mssql/data:/var/opt/mssql/data
- ../mssql/backups:/etc/bitwarden/mssql/backups
env_file:
- mssql.env
- ../env/mssql.override.env
web:
volumes:
- ../web:/etc/bitwarden/web
attachments:
volumes:
- ../core/attachments:/etc/bitwarden/core/attachments
api:
volumes:
- ../core:/etc/bitwarden/core
env_file:
- global.env
- ../env/global.override.env
identity:
volumes:
- ../identity:/etc/bitwarden/identity
- ../core:/etc/bitwarden/core
env_file:
- global.env
- ../env/global.override.env
nginx:
volumes:
- ../nginx:/etc/bitwarden/nginx
- ../letsencrypt:/etc/letsencrypt
- ../ssl:/etc/ssl

View File

@ -1,36 +0,0 @@
version: '3'
services:
mssql:
volumes:
- mssql_data:/var/opt/mssql/data
- ../mssql/backups:/etc/bitwarden/mssql/backups
env_file:
- mssql.env
- ../env/mssql.override.env
web:
volumes:
- ../web:/etc/bitwarden/web
attachments:
volumes:
- ../core/attachments:/etc/bitwarden/core/attachments
api:
volumes:
- ../core:/etc/bitwarden/core
env_file:
- global.env
- ../env/global.override.env
identity:
volumes:
- ../identity:/etc/bitwarden/identity
- ../core:/etc/bitwarden/core
env_file:
- global.env
- ../env/global.override.env
nginx:
volumes:
- ../nginx:/etc/bitwarden/nginx
- ../letsencrypt:/etc/letsencrypt
- ../ssl:/etc/ssl
volumes:
mssql_data:

View File

@ -1,40 +0,0 @@
version: '3'
services:
mssql:
image: bitwarden/mssql:1.13.1
container_name: mssql
restart: always
web:
image: bitwarden/web:1.19.0
container_name: web
restart: always
attachments:
image: bitwarden/attachments:1.13.1
container_name: attachments
restart: always
api:
image: bitwarden/api:1.13.1
container_name: api
restart: always
identity:
image: bitwarden/identity:1.13.1
container_name: identity
restart: always
icons:
image: bitwarden/icons:1.13.1
container_name: icons
restart: always
nginx:
image: bitwarden/nginx:1.13.1
container_name: nginx
restart: always
ports:
- '80:80'
- '443:443'

View File

@ -1,8 +0,0 @@
ASPNETCORE_ENVIRONMENT=Production
globalSettings__selfHosted=true
globalSettings__baseServiceUri__vault=http://localhost
globalSettings__baseServiceUri__api=http://localhost/api
globalSettings__baseServiceUri__identity=http://localhost/identity
globalSettings__baseServiceUri__internalIdentity=http://identity
globalSettings__pushRelayBaseUri=https://push.bitwarden.com
globalSettings__installation__identityUri=https://identity.bitwarden.com

View File

@ -1,3 +0,0 @@
ACCEPT_EULA=Y
MSSQL_PID=Express
SA_PASSWORD=SECRET

View File

@ -41,8 +41,9 @@ if($output -eq "") {
} }
$scriptsDir = "${output}\scripts" $scriptsDir = "${output}\scripts"
$dockerDir = "${output}\docker"
$githubBaseUrl = "https://raw.githubusercontent.com/bitwarden/core/master" $githubBaseUrl = "https://raw.githubusercontent.com/bitwarden/core/master"
$coreVersion = "1.14.0"
$webVersion = "1.20.0"
# Functions # Functions
@ -64,18 +65,6 @@ function Download-Run-File {
Invoke-RestMethod -OutFile $scriptsDir\run.ps1 -Uri "${githubBaseUrl}/scripts/run.ps1" Invoke-RestMethod -OutFile $scriptsDir\run.ps1 -Uri "${githubBaseUrl}/scripts/run.ps1"
} }
function Download-Docker-Files {
Invoke-RestMethod -OutFile $dockerDir\docker-compose.yml -Uri "${githubBaseUrl}/docker/docker-compose.yml"
Invoke-RestMethod -OutFile $dockerDir\docker-compose.linwin.yml ` -Uri "${githubBaseUrl}/docker/docker-compose.linwin.yml"
Invoke-RestMethod -OutFile $dockerDir\global.env -Uri "${githubBaseUrl}/docker/global.env"
Invoke-RestMethod -OutFile $dockerDir\mssql.env -Uri "${githubBaseUrl}/docker/mssql.env"
}
function Download-All-Files {
Download-Run-File
Download-Docker-Files
}
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."
@ -94,34 +83,24 @@ 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-Install Download-Install
Invoke-Expression "$scriptsDir\install.ps1 -outputDir $output" Invoke-Expression "$scriptsDir\install.ps1 -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
} }
elseif($start -Or $restart) { elseif($start -Or $restart) {
Check-Output-Dir-Exists Check-Output-Dir-Exists
if(!(Test-Path -Path $dockerDir)) { Invoke-Expression "$scriptsDir\run.ps1 -restart -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
New-Item -ItemType directory -Path $dockerDir | Out-Null
Download-All-Files
}
Invoke-Expression "$scriptsDir\run.ps1 -restart -outputDir $output -dockerDir $dockerDir"
} }
elseif($update) { elseif($update) {
Check-Output-Dir-Exists Check-Output-Dir-Exists
if(Test-Path -Path $dockerDir) { Download-Run-File
Remove-Item -Recurse -Force $dockerDir | Out-Null Invoke-Expression "$scriptsDir\run.ps1 -update -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
}
New-Item -ItemType directory -Path $dockerDir | Out-Null
Download-All-Files
Invoke-Expression "$scriptsDir\run.ps1 -update -outputDir $output -dockerDir $dockerDir"
} }
elseif($updatedb) { elseif($updatedb) {
Check-Output-Dir-Exists Check-Output-Dir-Exists
Invoke-Expression "$scriptsDir\run.ps1 -updatedb -outputDir $output -dockerDir $dockerDir" 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 -dockerDir $dockerDir" Invoke-Expression "$scriptsDir\run.ps1 -stop -outputDir $output -coreVersion $coreVersion -webVersion $webVersion"
} }
elseif($updateself) { elseif($updateself) {
Download-Self Download-Self

View File

@ -35,15 +35,10 @@ then
OUTPUT=$2 OUTPUT=$2
fi fi
OS="linwin"
if [ "$(uname)" == "Darwin" ]
then
OS="mac"
fi
SCRIPTS_DIR="$OUTPUT/scripts" SCRIPTS_DIR="$OUTPUT/scripts"
DOCKER_DIR="$OUTPUT/docker"
GITHUB_BASE_URL="https://raw.githubusercontent.com/bitwarden/core/master" GITHUB_BASE_URL="https://raw.githubusercontent.com/bitwarden/core/master"
COREVERSION="1.14.0"
WEBVERSION="1.20.0"
# Functions # Functions
@ -70,18 +65,6 @@ function downloadRunFile() {
chmod u+x $SCRIPTS_DIR/run.sh chmod u+x $SCRIPTS_DIR/run.sh
} }
function downloadDockerFiles() {
curl -s -o $DOCKER_DIR/docker-compose.yml $GITHUB_BASE_URL/docker/docker-compose.yml
curl -s -o $DOCKER_DIR/docker-compose.$OS.yml $GITHUB_BASE_URL/docker/docker-compose.$OS.yml
curl -s -o $DOCKER_DIR/global.env $GITHUB_BASE_URL/docker/global.env
curl -s -o $DOCKER_DIR/mssql.env $GITHUB_BASE_URL/docker/mssql.env
}
function downloadAllFiles() {
downloadRunFile
downloadDockerFiles
}
function checkOutputDirExists() { function checkOutputDirExists() {
if [ ! -d "$OUTPUT" ] if [ ! -d "$OUTPUT" ]
then then
@ -105,36 +88,24 @@ then
checkOutputDirNotExists checkOutputDirNotExists
mkdir $OUTPUT mkdir $OUTPUT
downloadInstall downloadInstall
$SCRIPTS_DIR/install.sh $OUTPUT $SCRIPTS_DIR/install.sh $OUTPUT $COREVERSION $WEBVERSION
elif [ "$1" == "start" -o "$1" == "restart" ] elif [ "$1" == "start" -o "$1" == "restart" ]
then then
checkOutputDirExists checkOutputDirExists
if [ ! -d "$DOCKER_DIR" ] $SCRIPTS_DIR/run.sh restart $OUTPUT $COREVERSION $WEBVERSION
then
mkdir $DOCKER_DIR
downloadAllFiles
fi
$SCRIPTS_DIR/run.sh restart $OUTPUT $DOCKER_DIR
elif [ "$1" == "update" ] elif [ "$1" == "update" ]
then then
checkOutputDirExists checkOutputDirExists
if [ -d "$DOCKER_DIR" ] downloadRunFile
then $SCRIPTS_DIR/run.sh update $OUTPUT $COREVERSION $WEBVERSION
rm -rf $DOCKER_DIR
fi
mkdir $DOCKER_DIR
downloadAllFiles
$SCRIPTS_DIR/run.sh update $OUTPUT $DOCKER_DIR
elif [ "$1" == "updatedb" ] elif [ "$1" == "updatedb" ]
then then
checkOutputDirExists checkOutputDirExists
$SCRIPTS_DIR/run.sh updatedb $OUTPUT $DOCKER_DIR $SCRIPTS_DIR/run.sh updatedb $OUTPUT $COREVERSION $WEBVERSION
elif [ "$1" == "stop" ] elif [ "$1" == "stop" ]
then then
checkOutputDirExists checkOutputDirExists
$SCRIPTS_DIR/run.sh stop $OUTPUT $DOCKER_DIR $SCRIPTS_DIR/run.sh stop $OUTPUT $COREVERSION $WEBVERSION
elif [ "$1" == "updateself" ] elif [ "$1" == "updateself" ]
then then
downloadSelf downloadSelf

View File

@ -1,9 +1,9 @@
param ( param (
[string]$outputDir = "../." [string]$outputDir = "../.",
[string]$coreVersion = "latest",
[string]$webVersion = "latest"
) )
[string]$tag = "1.13.1"
if(!(Test-Path -Path $outputDir )){ if(!(Test-Path -Path $outputDir )){
New-Item -ItemType directory -Path $outputDir | Out-Null New-Item -ItemType directory -Path $outputDir | Out-Null
} }
@ -32,8 +32,8 @@ if($domain -ne "localhost") {
} }
} }
docker pull bitwarden/setup:$tag docker pull bitwarden/setup:$coreVersion
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$tag ` docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -install 1 -domain ${domain} -letsencrypt ${letsEncrypt} dotnet Setup.dll -install 1 -domain ${domain} -letsencrypt ${letsEncrypt} -os win -corev $coreVersion -webv $webVersion
echo "Setup complete" echo "Setup complete"

View File

@ -7,7 +7,23 @@ then
OUTPUT_DIR=$1 OUTPUT_DIR=$1
fi fi
TAG="1.13.1" COREVERSION="latest"
if [ $# -gt 2 ]
then
COREVERSION=$2
fi
WEBVERSION="latest"
if [ $# -gt 3 ]
then
WEBVERSION=$3
fi
OS="lin"
if [ "$(uname)" == "Darwin" ]
then
OS="mac"
fi
mkdir -p $OUTPUT_DIR mkdir -p $OUTPUT_DIR
@ -34,9 +50,9 @@ then
fi fi
fi fi
docker pull bitwarden/setup:$TAG docker pull bitwarden/setup:$COREVERSION
docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden bitwarden/setup:$TAG \ docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden bitwarden/setup:$COREVERSION \
dotnet Setup.dll -install 1 -domain $DOMAIN -letsencrypt $LETS_ENCRYPT dotnet Setup.dll -install 1 -domain $DOMAIN -letsencrypt $LETS_ENCRYPT -os $OS -corev $COREVERSION -webv $WEBVERSION
echo "" echo ""
echo "Setup complete" echo "Setup complete"

View File

@ -1,6 +1,7 @@
param ( param (
[string]$outputDir = "../.", [string]$outputDir = "../.",
[string]$dockerDir = "", [string]$coreVersion = "latest",
[string]$webVersion = "latest",
[switch] $start, [switch] $start,
[switch] $restart, [switch] $restart,
[switch] $stop, [switch] $stop,
@ -11,25 +12,20 @@ param (
# Setup # Setup
[string]$tag = "1.13.1" $dockerDir="${outputDir}\docker"
$dir = Split-Path -Parent $MyInvocation.MyCommand.Path
if($dockerDir -eq "") {
$dockerDir="${dir}\..\docker"
}
# Functions # Functions
function Docker-Compose-Up { function Docker-Compose-Up {
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.linwin.yml up -d docker-compose -f ${dockerDir}\docker-compose.yml up -d
} }
function Docker-Compose-Down { function Docker-Compose-Down {
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.linwin.yml down docker-compose -f ${dockerDir}\docker-compose.yml down
} }
function Docker-Compose-Pull { function Docker-Compose-Pull {
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.linwin.yml pull docker-compose -f ${dockerDir}\docker-compose.yml pull
} }
function Docker-Prune { function Docker-Prune {
@ -46,21 +42,21 @@ function Update-Lets-Encrypt {
function Update-Database { function Update-Database {
Pull-Setup Pull-Setup
docker run -it --rm --name setup --network container:mssql -v ${outputDir}:/bitwarden bitwarden/setup:$tag ` docker run -it --rm --name setup --network container:mssql -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -update 1 -db 1 dotnet Setup.dll -update 1 -db 1 -os win -corev $coreVersion -webv $webVersion
echo "Database update complete" echo "Database update complete"
} }
function Update { function Update {
Pull-Setup Pull-Setup
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$tag ` docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -update 1 dotnet Setup.dll -update 1 -os win -corev $coreVersion -webv $webVersion
} }
function Print-Environment { function Print-Environment {
Pull-Setup Pull-Setup
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$tag ` docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -printenv 1 -env win dotnet Setup.dll -printenv 1 -os win -corev $coreVersion -webv $webVersion
} }
function Restart { function Restart {
@ -73,7 +69,7 @@ function Restart {
} }
function Pull-Setup { function Pull-Setup {
docker pull bitwarden/setup:$tag docker pull bitwarden/setup:$coreVersion
} }
# Commands # Commands

View File

@ -11,32 +11,38 @@ then
OUTPUT_DIR=$2 OUTPUT_DIR=$2
fi fi
DOCKER_DIR=$DIR/../docker COREVERSION="latest"
if [ $# -gt 2 ] if [ $# -gt 2 ]
then then
DOCKER_DIR=$3 COREVERSION=$3
fi fi
OS="linwin" WEBVERSION="latest"
if [ $# -gt 3 ]
then
WEBVERSION=$4
fi
OS="lin"
if [ "$(uname)" == "Darwin" ] if [ "$(uname)" == "Darwin" ]
then then
OS="mac" OS="mac"
fi fi
TAG="1.13.1" DOCKER_DIR="$OUTPUT_DIR/docker"
# Functions # Functions
function dockerComposeUp() { function dockerComposeUp() {
docker-compose -f $DOCKER_DIR/docker-compose.yml -f $DOCKER_DIR/docker-compose.$OS.yml up -d docker-compose -f $DOCKER_DIR/docker-compose.yml up -d
} }
function dockerComposeDown() { function dockerComposeDown() {
docker-compose -f $DOCKER_DIR/docker-compose.yml -f $DOCKER_DIR/docker-compose.$OS.yml down docker-compose -f $DOCKER_DIR/docker-compose.yml down
} }
function dockerComposePull() { function dockerComposePull() {
docker-compose -f $DOCKER_DIR/docker-compose.yml -f $DOCKER_DIR/docker-compose.$OS.yml pull docker-compose -f $DOCKER_DIR/docker-compose.yml pull
} }
function dockerPrune() { function dockerPrune() {
@ -44,7 +50,7 @@ function dockerPrune() {
} }
function updateLetsEncrypt() { function updateLetsEncrypt() {
if [ -d "${outputDir}/letsencrypt/live" ] if [ -d "${OUTPUT_DIR}/letsencrypt/live" ]
then then
docker pull certbot/certbot docker pull certbot/certbot
docker run -it --rm --name certbot -p 443:443 -p 80:80 -v $OUTPUT_DIR/letsencrypt:/etc/letsencrypt/ certbot/certbot \ docker run -it --rm --name certbot -p 443:443 -p 80:80 -v $OUTPUT_DIR/letsencrypt:/etc/letsencrypt/ certbot/certbot \
@ -54,21 +60,21 @@ function updateLetsEncrypt() {
function updateDatabase() { function updateDatabase() {
pullSetup pullSetup
docker run -it --rm --name setup --network container:mssql -v $OUTPUT_DIR:/bitwarden bitwarden/setup:$TAG \ docker run -it --rm --name setup --network container:mssql -v $OUTPUT_DIR:/bitwarden bitwarden/setup:$COREVERSION \
dotnet Setup.dll -update 1 -db 1 dotnet Setup.dll -update 1 -db 1 -os $OS -corev $COREVERSION -webv $WEBVERSION
echo "Database update complete" echo "Database update complete"
} }
function update() { function update() {
pullSetup pullSetup
docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden bitwarden/setup:$TAG \ docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden bitwarden/setup:$COREVERSION \
dotnet Setup.dll -update 1 dotnet Setup.dll -update 1 -os $OS -corev $COREVERSION -webv $WEBVERSION
} }
function printEnvironment() { function printEnvironment() {
pullSetup pullSetup
docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden bitwarden/setup:$TAG \ docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden bitwarden/setup:$COREVERSION \
dotnet Setup.dll -printenv 1 -env $OS dotnet Setup.dll -printenv 1 -os $OS -corev $COREVERSION -webv $WEBVERSION
} }
function restart() { function restart() {
@ -81,7 +87,7 @@ function restart() {
} }
function pullSetup() { function pullSetup() {
docker pull bitwarden/setup:$TAG docker pull bitwarden/setup:$COREVERSION
} }
# Commands # Commands