mirror of
https://github.com/jakeswenson/BitBetter.git
synced 2025-12-16 19:26:18 +00:00
Update and fix unified branch (#257)
* Upstream patches * Fix license generator according to upstream changes (#245) (#249) * Test generating user and organization licenses during build check (#252) * Fix ps1 script and update language * Update class path * Cleanup code * Cleanup code * Cleanup code * Refactor and fixes * Copy all files * Copy files only when needed * Make call consistent * Simplify call * Clarify language * Reuse code * Cleanup * Cleanup * Remove NewtonSoft.Json * Upgrade dnlib * Cleanup * Fix path issue * Fix comparator * Cleanup circleci * Fix type * Fix circleci * Properly detect previous version * Add missing parameter * Better detect running patched containers * Improve naming * Fix line endings * Fix typo * Add comment * Fix tabs * Cleanup org license * Use proper file extension * Add missing file * Migrate cert.cert if exists * Check for the correct file * Fix character check * Add comment * Add more documentation * Add proper line endings * Add potentially correct line * Add auto restart * Update comment * Improve consistency between bash and powerhell * Update documentation * Detect buildx * Fix spelling mistake * Fix check order and improve verbosity
This commit is contained in:
87
build.sh
87
build.sh
@@ -1,6 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# detect buildx, set -e will ensure the script stops execution if not found
|
||||
docker buildx version
|
||||
|
||||
# define temporary directory
|
||||
TEMPDIRECTORY="$PWD/temp"
|
||||
|
||||
@@ -20,8 +23,12 @@ if [ -f "$PWD/src/licenseGen/cert.pfx" ]; then
|
||||
rm -f "$PWD/src/licenseGen/cert.pfx"
|
||||
fi
|
||||
|
||||
if [ -f "$PWD/src/bitBetter/cert.cert" ]; then
|
||||
rm -f "$PWD/src/bitBetter/cert.cert"
|
||||
if [ -f "$PWD/src/bitBetter/cert.cer" ]; then
|
||||
rm -f "$PWD/src/bitBetter/cert.cer"
|
||||
fi
|
||||
|
||||
if [ -f "$PWD/.keys/cert.cert" ]; then
|
||||
mv "$PWD/.keys/cert.cert" "$PWD/.keys/cert.cer"
|
||||
fi
|
||||
|
||||
# generate keys if none are available
|
||||
@@ -29,15 +36,14 @@ if [ ! -d "$PWD/.keys" ]; then
|
||||
./generateKeys.sh
|
||||
fi
|
||||
|
||||
# copy the key to bitBetter and licenseGen
|
||||
cp -f "$PWD/.keys/cert.cert" "$PWD/src/bitBetter"
|
||||
cp -f "$PWD/.keys/cert.pfx" "$PWD/src/licenseGen"
|
||||
# copy the key to bitBetter
|
||||
cp -f "$PWD/.keys/cert.cer" "$PWD/src/bitBetter"
|
||||
|
||||
# build bitBetter and clean the source directory after
|
||||
docker build --no-cache -t bitbetter/bitbetter "$PWD/src/bitBetter"
|
||||
rm -f "$PWD/src/bitBetter/cert.cert"
|
||||
rm -f "$PWD/src/bitBetter/cert.cer"
|
||||
|
||||
# gather all running instances
|
||||
# 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}}')
|
||||
|
||||
# stop and remove all running instances
|
||||
@@ -47,24 +53,35 @@ for INSTANCE in ${OLDINSTANCES[@]}; do
|
||||
done
|
||||
|
||||
# update bitwarden itself
|
||||
if [ "$1" = "y" ]; then
|
||||
if [ "$1" = "update" ]; then
|
||||
docker pull ghcr.io/bitwarden/self-host:beta
|
||||
else
|
||||
read -p "Update (or get) bitwarden source container: " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
read -p "Update (or get) bitwarden source container (y/n): "
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
docker pull ghcr.io/bitwarden/self-host:beta
|
||||
fi
|
||||
fi
|
||||
|
||||
# remove previous existing patch(ed) image
|
||||
if [ "$(docker image ls -q bitwarden-patch)" ]; then
|
||||
docker image rm bitwarden-patch
|
||||
fi
|
||||
# stop and remove previous existing patch(ed) container
|
||||
OLDINSTANCES=$(docker container ps --all -f Ancestor=bitwarden-patched --format '{{.ID}}')
|
||||
for INSTANCE in ${OLDINSTANCES[@]}; do
|
||||
docker stop $INSTANCE
|
||||
docker rm $INSTANCE
|
||||
done
|
||||
OLDINSTANCES=$(docker image ls bitwarden-patched --format '{{.ID}}')
|
||||
for INSTANCE in ${OLDINSTANCES[@]}; do
|
||||
docker image rm $INSTANCE
|
||||
done
|
||||
|
||||
# remove old extract containers
|
||||
OLDINSTANCES=$(docker container ps --all -f Name=bitwarden-extract --format '{{.ID}}')
|
||||
for INSTANCE in ${OLDINSTANCES[@]}; do
|
||||
docker stop $INSTANCE
|
||||
docker rm $INSTANCE
|
||||
done
|
||||
|
||||
# start a new bitwarden instance so we can patch it
|
||||
PATCHINSTANCE=$(docker run -d --name bitwarden-patch ghcr.io/bitwarden/self-host:beta)
|
||||
PATCHINSTANCE=$(docker run -d --name bitwarden-extract ghcr.io/bitwarden/self-host:beta)
|
||||
|
||||
# create our temporary directory
|
||||
mkdir $TEMPDIRECTORY
|
||||
@@ -75,34 +92,40 @@ for COMPONENT in ${COMPONENTS[@]}; do
|
||||
docker cp $PATCHINSTANCE:/app/$COMPONENT/Core.dll "$TEMPDIRECTORY/$COMPONENT/Core.dll"
|
||||
done
|
||||
|
||||
# stop and remove our temporary container
|
||||
docker stop bitwarden-extract
|
||||
docker rm bitwarden-extract
|
||||
|
||||
# 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
|
||||
cp -f "$TEMPDIRECTORY/Identity/Core.dll" "$PWD/src/licenseGen"
|
||||
|
||||
# remove our temporary directory
|
||||
rm -rf "$TEMPDIRECTORY"
|
||||
docker build . --tag bitwarden-patched --file "$PWD/src/bitBetter/Dockerfile-bitwarden-patch"
|
||||
|
||||
# start all user requested instances
|
||||
sed -i 's/\r$//' "$PWD/.servers/serverlist.txt"
|
||||
cat "$PWD/.servers/serverlist.txt" | while read -r LINE; do
|
||||
bash -c "$LINE"
|
||||
done
|
||||
if [ -f "$PWD/.servers/serverlist.txt" ]; then
|
||||
# convert line endings to unix
|
||||
sed -i 's/\r$//' "$PWD/.servers/serverlist.txt"
|
||||
cat "$PWD/.servers/serverlist.txt" | while read -r LINE; do
|
||||
if [[ $LINE != "#"* ]]; then
|
||||
bash -c "$LINE"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# remove our bitBetter image
|
||||
docker image rm bitbetter/bitbetter
|
||||
|
||||
# copy our patched library to the licenseGen source directory
|
||||
cp -f "$TEMPDIRECTORY/Identity/Core.dll" "$PWD/src/licenseGen"
|
||||
cp -f "$PWD/.keys/cert.pfx" "$PWD/src/licenseGen"
|
||||
|
||||
# build the licenseGen
|
||||
docker build -t bitbetter/licensegen "$PWD/src/licenseGen"
|
||||
|
||||
# clean the licenseGen source directory
|
||||
rm -f "$PWD/src/licenseGen/Core.dll"
|
||||
rm -f "$PWD/src/licenseGen/cert.pfx"
|
||||
|
||||
# remove our temporary directory
|
||||
rm -rf "$TEMPDIRECTORY"
|
||||
Reference in New Issue
Block a user