-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Initial work * Fix typo * Fix typo * Fix stupid issue * Add comments and fix minor issues * Add extra information * Add Linux script for generating keys * Add circleci * Add comments * Add extra option * Add missing permissions and empty script for now * Fix line endings * Add missing mount point * Simplify patch * Fix scripts * Reduce complexity * Fix circleci * Remove useless line * Move to src folder and improve image creation
- Loading branch information
Showing
20 changed files
with
732 additions
and
680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
machine: true | ||
steps: | ||
- checkout | ||
- run: | ||
name: Print the Current Time | ||
command: date | ||
- run: | ||
name: Generate Keys | ||
command: ./.keys/generate-keys.sh | ||
- run: | ||
name: Build script | ||
command: ./build.sh | ||
version: 2.1 | ||
jobs: | ||
build: | ||
machine: true | ||
steps: | ||
- checkout | ||
- run: | ||
name: Print the Current Time | ||
command: date | ||
- run: | ||
name: Generate Keys | ||
command: ./generateKeys.sh | ||
- run: | ||
name: Build script | ||
command: ./build.sh y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
docker run -d --name bitwarden -v <full-local-path>\logs:/var/log/bitwarden -v <full-local-path>\bwdata:/etc/bitwarden -p 80:8080 --env-file <full-local-path>\settings.env bitwarden-patch | ||
<OR> | ||
docker-compose -f <full-local-path>/docker-compose.yml up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# define temporary directory | ||
$tempdirectory = "$pwd\temp" | ||
# define services to patch | ||
$components = "Api","Identity" | ||
|
||
# delete old directories / files if applicable | ||
if (Test-Path "$tempdirectory") { | ||
Remove-Item "$tempdirectory" -Recurse -Force | ||
} | ||
|
||
if (Test-Path -Path "$pwd\src\licenseGen\Core.dll" -PathType Leaf) { | ||
Remove-Item "$pwd\src\licenseGen\Core.dll" -Force | ||
} | ||
|
||
if (Test-Path -Path "$pwd\src\licenseGen\cert.pfx" -PathType Leaf) { | ||
Remove-Item "$pwd\src\licenseGen\cert.pfx" -Force | ||
} | ||
|
||
if (Test-Path -Path "$pwd\src\bitBetter\cert.cert" -PathType Leaf) { | ||
Remove-Item "$pwd\src\bitBetter\cert.cert" -Force | ||
} | ||
|
||
# generate keys if none are available | ||
if (!(Test-Path "$pwd\.keys")) { | ||
.\generateKeys.ps1 | ||
} | ||
|
||
# copy the key to bitBetter and licenseGen | ||
Copy-Item "$pwd\.keys\cert.cert" -Destination "$pwd\src\bitBetter" | ||
Copy-Item "$pwd\.keys\cert.pfx" -Destination "$pwd\src\licenseGen" | ||
|
||
# build bitBetter and clean the source directory after | ||
docker build -t bitbetter/bitbetter "$pwd\src\bitBetter" | ||
Remove-Item "$pwd\src\bitBetter\cert.cert" -Force | ||
|
||
# gather all running instances | ||
$oldinstances = docker container ps --all -f Name=bitwarden --format '{{.ID}}' | ||
|
||
# stop all running instances | ||
foreach ($instance in $oldinstances) { | ||
docker stop $instance | ||
docker rm $instance | ||
} | ||
|
||
# update bitwarden itself | ||
if ($args[0] -eq 'y') | ||
{ | ||
docker pull bitwarden/self-host:beta | ||
} | ||
else | ||
{ | ||
$confirmation = Read-Host "Update (or get) bitwarden source container" | ||
if ($confirmation -eq 'y') { | ||
docker pull bitwarden/self-host:beta | ||
} | ||
} | ||
|
||
# stop and remove previous existing patch(ed) container | ||
docker stop bitwarden-patch | ||
docker rm bitwarden-patch | ||
docker image rm bitwarden-patch | ||
|
||
# start a new bitwarden instance so we can patch it | ||
$patchinstance = docker run -d --name bitwarden-patch bitwarden/self-host:beta | ||
|
||
# create our temporary directory | ||
New-item -ItemType Directory -Path $tempdirectory | ||
|
||
# extract the files that need to be patched from the services that need to be patched into our temporary directory | ||
foreach ($component in $components) { | ||
New-item -itemtype Directory -path "$tempdirectory\$component" | ||
docker cp $patchinstance`:/app/$component/Core.dll "$tempdirectory\$component\Core.dll" | ||
} | ||
|
||
# run bitBetter, this applies our patches to the required files | ||
docker run -v "$tempdirectory`:/app/mount" --rm bitbetter/bitbetter | ||
|
||
# create a new image with the patched files | ||
docker build . --tag bitwarden-patch --file "$pwd\src\bitBetter\Dockerfile-bitwarden-patch" | ||
|
||
# stop and remove our temporary container | ||
docker stop bitwarden-patch | ||
docker rm bitwarden-patch | ||
|
||
# copy our patched library to the licenseGen source directory | ||
Copy-Item "$tempdirectory\Identity\Core.dll" -Destination "$pwd\src\licenseGen" | ||
|
||
# remove our temporary directory | ||
Remove-Item "$tempdirectory" -Recurse -Force | ||
|
||
# start all user requested instances | ||
foreach($line in Get-Content "$pwd\.servers\serverlist.txt") { | ||
Invoke-Expression "& $line" | ||
} | ||
|
||
# remove our bitBetter image | ||
docker image rm bitbetter/bitbetter | ||
|
||
# build the licenseGen | ||
docker build -t bitbetter/licensegen "$pwd\src\licenseGen" | ||
|
||
# clean the licenseGen source directory | ||
Remove-Item "$pwd\src\licenseGen\Core.dll" -Force | ||
Remove-Item "$pwd\src\licenseGen\cert.pfx" -Force |
Oops, something went wrong.