Compare commits

...

3 Commits

Author SHA1 Message Date
Jackson K
fff2b4294d Actually remove .DS_Store 2025-12-06 07:09:12 +13:00
Jackson K
9d5ed5eddd Remove .DS_Store file, and add to .gitignore 2025-12-06 07:07:45 +13:00
Jackson K
3ac8aed47f Change build.ps1 and Dockerfile-bitwarden-patched to CRLF 2025-12-06 07:05:38 +13:00
4 changed files with 149 additions and 148 deletions

1
.gitignore vendored
View File

@@ -9,3 +9,4 @@ src/bitBetter/.vs/*
*.pfx *.pfx
*.cer *.cer
*.vsidx *.vsidx
.DS_Store

256
build.ps1
View File

@@ -1,128 +1,128 @@
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true $PSNativeCommandUseErrorActionPreference = $true
# detect buildx, ErrorActionPreference will ensure the script stops execution if not found # detect buildx, ErrorActionPreference will ensure the script stops execution if not found
docker buildx version docker buildx version
# define temporary directory # define temporary directory
$tempdirectory = "$pwd\temp" $tempdirectory = "$pwd\temp"
# define services to patch # define services to patch
$components = "Api","Identity" $components = "Api","Identity"
# delete old directories / files if applicable # delete old directories / files if applicable
if (Test-Path "$tempdirectory" -PathType Container) { if (Test-Path "$tempdirectory" -PathType Container) {
Remove-Item "$tempdirectory" -Recurse -Force Remove-Item "$tempdirectory" -Recurse -Force
} }
if (Test-Path -Path "$pwd\src\licenseGen\Core.dll" -PathType Leaf) { if (Test-Path -Path "$pwd\src\licenseGen\Core.dll" -PathType Leaf) {
Remove-Item "$pwd\src\licenseGen\Core.dll" -Force Remove-Item "$pwd\src\licenseGen\Core.dll" -Force
} }
if (Test-Path -Path "$pwd\src\licenseGen\cert.pfx" -PathType Leaf) { if (Test-Path -Path "$pwd\src\licenseGen\cert.pfx" -PathType Leaf) {
Remove-Item "$pwd\src\licenseGen\cert.pfx" -Force Remove-Item "$pwd\src\licenseGen\cert.pfx" -Force
} }
if (Test-Path -Path "$pwd\src\bitBetter\cert.cer" -PathType Leaf) { if (Test-Path -Path "$pwd\src\bitBetter\cert.cer" -PathType Leaf) {
Remove-Item "$pwd\src\bitBetter\cert.cer" -Force Remove-Item "$pwd\src\bitBetter\cert.cer" -Force
} }
if (Test-Path "$pwd\.keys\cert.cert" -PathType Leaf) { if (Test-Path "$pwd\.keys\cert.cert" -PathType Leaf) {
Rename-Item -Path "$pwd\.keys\cert.cert" -NewName "$pwd\.keys\cert.cer" Rename-Item -Path "$pwd\.keys\cert.cert" -NewName "$pwd\.keys\cert.cer"
} }
# generate keys if none are available # generate keys if none are available
if (!(Test-Path "$pwd\.keys" -PathType Container)) { if (!(Test-Path "$pwd\.keys" -PathType Container)) {
.\generateKeys.ps1 .\generateKeys.ps1
} }
# copy the key to bitBetter # copy the key to bitBetter
Copy-Item "$pwd\.keys\cert.cer" -Destination "$pwd\src\bitBetter" Copy-Item "$pwd\.keys\cert.cer" -Destination "$pwd\src\bitBetter"
# build bitBetter and clean the source directory after # build bitBetter and clean the source directory after
docker build --no-cache -t bitbetter/bitbetter "$pwd\src\bitBetter" docker build --no-cache -t bitbetter/bitbetter "$pwd\src\bitBetter"
Remove-Item "$pwd\src\bitBetter\cert.cer" -Force Remove-Item "$pwd\src\bitBetter\cert.cer" -Force
# gather all running instances, cannot run a wildcard filter on Ancestor= :(, does find all where name = *bitwarden* # gather all running instances, cannot run a wildcard filter on Ancestor= :(, does find all where name = *bitwarden*
$oldinstances = docker container ps --all -f Name=bitwarden --format '{{.ID}}' $oldinstances = docker container ps --all -f Name=bitwarden --format '{{.ID}}'
# stop and remove all running instances # stop and remove all running instances
foreach ($instance in $oldinstances) { foreach ($instance in $oldinstances) {
docker stop $instance docker stop $instance
docker rm $instance docker rm $instance
} }
# update bitwarden itself # update bitwarden itself
if ($args[0] -eq 'update') { if ($args[0] -eq 'update') {
docker pull ghcr.io/bitwarden/lite:beta docker pull ghcr.io/bitwarden/lite:beta
} else { } else {
$confirmation = Read-Host "Update (or get) bitwarden source container (y/n)" $confirmation = Read-Host "Update (or get) bitwarden source container (y/n)"
if ($confirmation -eq 'y') { if ($confirmation -eq 'y') {
docker pull ghcr.io/bitwarden/lite:beta docker pull ghcr.io/bitwarden/lite:beta
} }
} }
# stop and remove previous existing patch(ed) container # stop and remove previous existing patch(ed) container
$oldinstances = docker container ps --all -f Ancestor=bitwarden-patched --format '{{.ID}}' $oldinstances = docker container ps --all -f Ancestor=bitwarden-patched --format '{{.ID}}'
foreach ($instance in $oldinstances) { foreach ($instance in $oldinstances) {
docker stop $instance docker stop $instance
docker rm $instance docker rm $instance
} }
$oldinstances = docker image ls bitwarden-patched --format '{{.ID}}' $oldinstances = docker image ls bitwarden-patched --format '{{.ID}}'
foreach ($instance in $oldinstances) { foreach ($instance in $oldinstances) {
docker image rm $instance docker image rm $instance
} }
# remove old extract containers # remove old extract containers
$oldinstances = docker container ps --all -f Name=bitwarden-extract --format '{{.ID}}' $oldinstances = docker container ps --all -f Name=bitwarden-extract --format '{{.ID}}'
foreach ($instance in $oldinstances) { foreach ($instance in $oldinstances) {
docker stop $instance docker stop $instance
docker rm $instance docker rm $instance
} }
# start a new bitwarden instance so we can patch it # start a new bitwarden instance so we can patch it
$patchinstance = docker run -d --name bitwarden-extract ghcr.io/bitwarden/lite:beta $patchinstance = docker run -d --name bitwarden-extract ghcr.io/bitwarden/lite:beta
# create our temporary directory # create our temporary directory
New-item -ItemType Directory -Path $tempdirectory 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 # extract the files that need to be patched from the services that need to be patched into our temporary directory
foreach ($component in $components) { foreach ($component in $components) {
New-item -itemtype Directory -path "$tempdirectory\$component" New-item -itemtype Directory -path "$tempdirectory\$component"
docker cp $patchinstance`:/app/$component/Core.dll "$tempdirectory\$component\Core.dll" docker cp $patchinstance`:/app/$component/Core.dll "$tempdirectory\$component\Core.dll"
} }
# stop and remove our temporary container # stop and remove our temporary container
docker stop bitwarden-extract docker stop bitwarden-extract
docker rm bitwarden-extract docker rm bitwarden-extract
# run bitBetter, this applies our patches to the required files # run bitBetter, this applies our patches to the required files
docker run -v "$tempdirectory`:/app/mount" --rm bitbetter/bitbetter docker run -v "$tempdirectory`:/app/mount" --rm bitbetter/bitbetter
# create a new image with the patched files # create a new image with the patched files
docker build . --tag bitwarden-patched --file "$pwd\src\bitBetter\Dockerfile-bitwarden-patch" docker build . --tag bitwarden-patched --file "$pwd\src\bitBetter\Dockerfile-bitwarden-patch"
# start all user requested instances # start all user requested instances
if (Test-Path -Path "$pwd\.servers\serverlist.txt" -PathType Leaf) { if (Test-Path -Path "$pwd\.servers\serverlist.txt" -PathType Leaf) {
foreach($line in Get-Content "$pwd\.servers\serverlist.txt") { foreach($line in Get-Content "$pwd\.servers\serverlist.txt") {
if (!($line.StartsWith("#"))) { if (!($line.StartsWith("#"))) {
Invoke-Expression "& $line" Invoke-Expression "& $line"
} }
} }
} }
# remove our bitBetter image # remove our bitBetter image
docker image rm bitbetter/bitbetter docker image rm bitbetter/bitbetter
# copy our patched library to the licenseGen source directory # copy our patched library to the licenseGen source directory
Copy-Item "$tempdirectory\Identity\Core.dll" -Destination "$pwd\src\licenseGen" Copy-Item "$tempdirectory\Identity\Core.dll" -Destination "$pwd\src\licenseGen"
Copy-Item "$pwd\.keys\cert.pfx" -Destination "$pwd\src\licenseGen" Copy-Item "$pwd\.keys\cert.pfx" -Destination "$pwd\src\licenseGen"
# build the licenseGen # build the licenseGen
docker build -t bitbetter/licensegen "$pwd\src\licenseGen" docker build -t bitbetter/licensegen "$pwd\src\licenseGen"
# clean the licenseGen source directory # clean the licenseGen source directory
Remove-Item "$pwd\src\licenseGen\Core.dll" -Force Remove-Item "$pwd\src\licenseGen\Core.dll" -Force
Remove-Item "$pwd\src\licenseGen\cert.pfx" -Force Remove-Item "$pwd\src\licenseGen\cert.pfx" -Force
# remove our temporary directory # remove our temporary directory
Remove-Item "$tempdirectory" -Recurse -Force Remove-Item "$tempdirectory" -Recurse -Force

View File

@@ -1,17 +1,17 @@
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true $PSNativeCommandUseErrorActionPreference = $true
if ($($args.Count) -lt 1) { if ($($args.Count) -lt 1) {
echo "USAGE: <License Gen action> [License Gen args...]" echo "USAGE: <License Gen action> [License Gen args...]"
echo "ACTIONS:" echo "ACTIONS:"
echo " interactive" echo " interactive"
echo " user" echo " user"
echo " org" echo " org"
Exit 1 Exit 1
} }
if ($args[0] -eq "interactive") { if ($args[0] -eq "interactive") {
docker run -it --rm bitbetter/licensegen interactive docker run -it --rm bitbetter/licensegen interactive
} else { } else {
docker run bitbetter/licensegen $args docker run bitbetter/licensegen $args
} }

View File

@@ -1,3 +1,3 @@
FROM ghcr.io/bitwarden/lite:beta FROM ghcr.io/bitwarden/lite:beta
COPY ./temp/ /app/ COPY ./temp/ /app/