From 74415b99552a1250a4c0212089a8a161f6d33ec7 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 21 Aug 2017 08:49:44 -0400 Subject: [PATCH] script updates --- README.md | 30 +++++---------- ...pose.mac.yml => docker-compose.macwin.yml} | 0 docker/docker-compose.windows.yml | 35 ------------------ scripts/bitwarden.ps1 | 37 +++++++++++-------- scripts/bitwarden.sh | 23 +++++------- scripts/install.ps1 | 2 +- scripts/run.ps1 | 4 +- scripts/run.sh | 7 ++-- scripts/update-db.ps1 | 2 +- 9 files changed, 50 insertions(+), 90 deletions(-) rename docker/{docker-compose.mac.yml => docker-compose.macwin.yml} (100%) delete mode 100644 docker/docker-compose.windows.yml diff --git a/README.md b/README.md index ba0bc6518..5ef5fe334 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,16 @@ You can deploy bitwarden using Docker containers on Windows, macOS, and Linux di *These dependencies are free to use.* +### Linux & macOS + +``` +sudo curl -s -o bitwarden.sh https://raw.githubusercontent.com/bitwarden/core/master/scripts/bitwarden.sh && chmod u+x bitwarden.sh + +./bitwarden.sh install +./bitwarden.sh updatedb +./bitwarden.sh run +``` + ### Windows ``` @@ -81,26 +91,6 @@ Invoke-RestMethod -OutFile bitwarden.ps1 -Uri https://raw.githubusercontent.com/ .\bitwarden.ps1 -run ``` -### macOS - -``` -curl -s -o bitwarden.sh https://raw.githubusercontent.com/bitwarden/core/master/scripts/bitwarden.sh - -./bitwarden.sh install -./bitwarden.sh updatedb -./bitwarden.sh runmac -``` - -### Linux - -``` -curl -s -o bitwarden.sh https://raw.githubusercontent.com/bitwarden/core/master/scripts/bitwarden.sh - -./bitwarden.sh install -./bitwarden.sh updatedb -./bitwarden.sh run -``` - ## Contribute Code contributions are welcome! Visual Studio or VS Code is highly recommended if you are working on this project. Please commit any pull requests against the `master` branch. diff --git a/docker/docker-compose.mac.yml b/docker/docker-compose.macwin.yml similarity index 100% rename from docker/docker-compose.mac.yml rename to docker/docker-compose.macwin.yml diff --git a/docker/docker-compose.windows.yml b/docker/docker-compose.windows.yml deleted file mode 100644 index 07ecf6676..000000000 --- a/docker/docker-compose.windows.yml +++ /dev/null @@ -1,35 +0,0 @@ -version: '3' - -services: - mssql: - volumes: - - mssql_data:/var/opt/mssql/data - env_file: - - mssql.env - - c:/bitwarden/docker/mssql.override.env - web: - volumes: - - c:/bitwarden/web:/etc/bitwarden/web - attachments: - volumes: - - c:/bitwarden/core/attachments:/etc/bitwarden/core/attachments - api: - volumes: - - c:/bitwarden/core:/etc/bitwarden/core - env_file: - - global.env - - c:/bitwarden/docker/global.override.env - identity: - volumes: - - c:/bitwarden/identity:/etc/bitwarden/identity - - c:/bitwarden/core:/etc/bitwarden/core - env_file: - - global.env - - c:/bitwarden/docker/global.override.env - nginx: - volumes: - - c:/bitwarden/nginx:/etc/bitwarden/nginx - - c:/bitwarden/letsencrypt:/etc/letsencrypt - - c:/bitwarden/ssl:/etc/ssl -volumes: - mssql_data: diff --git a/scripts/bitwarden.ps1 b/scripts/bitwarden.ps1 index bdb2c3e53..e4bf061fb 100644 --- a/scripts/bitwarden.ps1 +++ b/scripts/bitwarden.ps1 @@ -4,11 +4,9 @@ param ( [switch] $restart, [switch] $update, [switch] $updatedb, - [string] $output = "c:/bitwarden" + [string] $output = "" ) -$year = (Get-Date).year - Write-Host @' _ _ _ _ | |__ (_) |___ ____ _ _ __ __| | ___ _ __ @@ -19,46 +17,55 @@ Write-Host @' Write-Host " Open source password management solutions -Copyright 2015-${year}, 8bit Solutions LLC +Copyright 2015-${(Get-Date).year}, 8bit Solutions LLC https://bitwarden.com, https://github.com/bitwarden " $dir = Split-Path -Parent $MyInvocation.MyCommand.Path -$dockerDir = ".\docker" +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" $githubBaseUrl = "https://raw.githubusercontent.com/bitwarden/core/master" function Download-Run-Files { - Invoke-RestMethod -OutFile run.ps1 -Uri "${githubBaseUrl}/scripts/run.ps1" + Invoke-RestMethod -OutFile $scriptsDir\run.ps1 -Uri "${githubBaseUrl}/scripts/run.ps1" Invoke-RestMethod -OutFile $dockerDir\docker-compose.yml -Uri "${githubBaseUrl}/docker/docker-compose.yml" - Invoke-RestMethod -OutFile $dockerDir\docker-compose.windows.yml ` -Uri "${githubBaseUrl}/docker/docker-compose.windows.yml" + Invoke-RestMethod -OutFile $dockerDir\docker-compose.macwin.yml ` -Uri "${githubBaseUrl}/docker/docker-compose.macwin.yml" Invoke-RestMethod -OutFile $dockerDir\global.env -Uri "${githubBaseUrl}/docker/global.env" Invoke-RestMethod -OutFile $dockerDir\mssql.env -Uri "${githubBaseUrl}/docker/mssql.env" } if($install) { - Invoke-RestMethod -OutFile install.ps1 ` -Uri "${githubBaseUrl}/scripts/install.ps1" - .\install.ps1 -outputDir $output + Invoke-RestMethod -OutFile $scriptsDir\install.ps1 ` -Uri "${githubBaseUrl}/scripts/install.ps1" + $scriptsDir\install.ps1 -outputDir $output } elseif($run -Or $restart) { - if(!(Test-Path -Path $dockerDir)){ + if(!(Test-Path -Path $dockerDir)) { New-Item -ItemType directory -Path $dockerDir | Out-Null Download-Run-Files } - .\run.ps1 -dockerDir $dockerDir + $scriptsDir\run.ps1 -dockerDir $dockerDir } elseif($update) { - if(Test-Path -Path $dockerDir){ + if(Test-Path -Path $dockerDir) { Remove-Item -Recurse -Force $dockerDir | Out-Null } New-Item -ItemType directory -Path $dockerDir | Out-Null Download-Run-Files - .\run.ps1 -dockerDir $dockerDir + $scriptsDir\run.ps1 -dockerDir $dockerDir } elseif($updatedb) { - Invoke-RestMethod -OutFile update-db.ps1 -Uri "${githubBaseUrl}/scripts/update-db.ps1" - .\update-db.ps1 -outputDir $output + Invoke-RestMethod -OutFile $scriptsDir\update-db.ps1 -Uri "${githubBaseUrl}/scripts/update-db.ps1" + $scriptsDir\update-db.ps1 -outputDir $output } else { echo "No command found." diff --git a/scripts/bitwarden.sh b/scripts/bitwarden.sh index 7e4bc8ac0..15455cb83 100755 --- a/scripts/bitwarden.sh +++ b/scripts/bitwarden.sh @@ -17,20 +17,11 @@ https://bitwarden.com, https://github.com/bitwarden EOF -OS="linux" -if [ $# -eq 2 ] -then - if [ $2 == "mac" -o $2 == "linux" ] - then - OS=$2 - fi -fi - DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" OUTPUT="$DIR/bitwarden" -if [ $# -eq 3 ] +if [ $# -eq 2 ] then - OUTPUT=$3 + OUTPUT=$2 fi if [ ! -d "$OUTPUT" ] @@ -38,6 +29,12 @@ then mkdir $OUTPUT fi +OS="linux" +if [ "$(uname)" == "Darwin" ] +then + OS="macwin" +fi + SCRIPTS_DIR="$OUTPUT/scripts" DOCKER_DIR="$OUTPUT/docker" GITHUB_BASE_URL="https://raw.githubusercontent.com/bitwarden/core/master" @@ -68,7 +65,7 @@ then mkdir $DOCKER_DIR downloadRunFiles fi - $SCRIPTS_DIR/run.sh $DOCKER_DIR $OS + $SCRIPTS_DIR/run.sh $DOCKER_DIR elif [ "$1" == "update" ] then if [ -d "$DOCKER_DIR" ] @@ -78,7 +75,7 @@ then mkdir $DOCKER_DIR downloadRunFiles - $SCRIPTS_DIR/run.sh $DOCKER_DIR $OS + $SCRIPTS_DIR/run.sh $DOCKER_DIR elif [ "$1" == "updatedb" ] then curl -s -o $SCRIPTS_DIR/update-db.sh $GITHUB_BASE_URL/scripts/update-db.sh diff --git a/scripts/install.ps1 b/scripts/install.ps1 index b9951d7e7..bdacbba4e 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -1,5 +1,5 @@ param ( - [string]$outputDir = "c:/bitwarden" + [string]$outputDir = "../." ) if(!(Test-Path -Path $outputDir )){ diff --git a/scripts/run.ps1 b/scripts/run.ps1 index 3839293b1..71674ef4e 100644 --- a/scripts/run.ps1 +++ b/scripts/run.ps1 @@ -10,5 +10,5 @@ if($dockerDir -eq "") { docker --version docker-compose --version -docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.windows.yml down -docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.windows.yml up -d +docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.macwin.yml down +docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.macwin.yml up -d diff --git a/scripts/run.sh b/scripts/run.sh index 1b3ce1d3c..2b3249133 100644 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -3,14 +3,15 @@ set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DOCKER_DIR=$DIR/../docker -OS="linux" if [ $# -eq 1 ] then DOCKER_DIR=$1 fi -if [ $# -eq 2 ] + +OS="linux" +if [ "$(uname)" == "Darwin" ] then - OS=$2 + OS="macwin" fi docker --version diff --git a/scripts/update-db.ps1 b/scripts/update-db.ps1 index 48fb293da..916d692a3 100644 --- a/scripts/update-db.ps1 +++ b/scripts/update-db.ps1 @@ -1,5 +1,5 @@ param ( - [string]$outputDir = "c:/bitwarden" + [string]$outputDir = "../." ) docker run -it --rm --name setup --network container:mssql -v ${outputDir}:/bitwarden bitwarden/setup `