mirror of
				https://github.com/jakeswenson/BitBetter.git
				synced 2025-10-31 04:43:25 +00:00 
			
		
		
		
	Improve naming
This commit is contained in:
		
							parent
							
								
									f9055c711a
								
							
						
					
					
						commit
						a527d425fd
					
				|  | @ -1,4 +1,4 @@ | ||||||
| # Uncomment a line below and fill in the missing values or add your own. Every line in this file will be called by build.[sh|ps1] once the patched image is built. | # Uncomment a line below and fill in the missing values or add your own. Every line in this file will be called by build.[sh|ps1] once the patched image is built. | ||||||
| # 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 | # 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-patched | ||||||
| # <OR> | # <OR> | ||||||
| # docker-compose -f <full-local-path>/docker-compose.yml up -d | # docker-compose -f <full-local-path>/docker-compose.yml up -d | ||||||
|  |  | ||||||
|  | @ -70,7 +70,7 @@ From the BitBetter directory, simply run: | ||||||
| ./build.[sh|ps1] | ./build.[sh|ps1] | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| This will create a new self-signed certificate in the `.keys` directory if one does not already exist and then create a modified version of the official `ghcr.io/bitwarden/self-host` image called `bitwarden-patch`. | This will create a new self-signed certificate in the `.keys` directory if one does not already exist and then create a modified version of the official `ghcr.io/bitwarden/self-host` image called `bitwarden-patched`. | ||||||
| 
 | 
 | ||||||
| Afterwards it will automatically generate the license generator and start all previously specified containers which are **now ready to accept self-issued licenses.** | Afterwards it will automatically generate the license generator and start all previously specified containers which are **now ready to accept self-issued licenses.** | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -55,12 +55,12 @@ if ($args[0] -eq 'y') { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # stop and remove previous existing patch(ed) container | # stop and remove previous existing patch(ed) container | ||||||
| $oldinstances = docker container ps --all -f Ancestor=bitwarden-patch --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-patch --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 | ||||||
| } | } | ||||||
|  | @ -92,7 +92,7 @@ docker rm bitwarden-extract | ||||||
| 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-patch --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) { | ||||||
|  |  | ||||||
							
								
								
									
										248
									
								
								build.sh
									
									
									
									
									
								
							
							
						
						
									
										248
									
								
								build.sh
									
									
									
									
									
								
							|  | @ -1,125 +1,125 @@ | ||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -e | set -e | ||||||
| 
 | 
 | ||||||
| # 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 [ -d "$TEMPDIRECTORY" ]; then | if [ -d "$TEMPDIRECTORY" ]; then | ||||||
| 	rm -rf "$TEMPDIRECTORY" | 	rm -rf "$TEMPDIRECTORY" | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| if [ -f "$PWD/src/licenseGen/Core.dll" ]; then | if [ -f "$PWD/src/licenseGen/Core.dll" ]; then | ||||||
|     rm -f "$PWD/src/licenseGen/Core.dll" |     rm -f "$PWD/src/licenseGen/Core.dll" | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| if [ -f "$PWD/src/licenseGen/cert.pfx" ]; then | if [ -f "$PWD/src/licenseGen/cert.pfx" ]; then | ||||||
|     rm -f "$PWD/src/licenseGen/cert.pfx" |     rm -f "$PWD/src/licenseGen/cert.pfx" | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| if [ -f "$PWD/src/bitBetter/cert.cert" ]; then | if [ -f "$PWD/src/bitBetter/cert.cert" ]; then | ||||||
|     rm -f "$PWD/src/bitBetter/cert.cert" |     rm -f "$PWD/src/bitBetter/cert.cert" | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| # generate keys if none are available | # generate keys if none are available | ||||||
| if [ ! -d "$PWD/.keys" ]; then | if [ ! -d "$PWD/.keys" ]; then | ||||||
| 	./generateKeys.sh | 	./generateKeys.sh | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| # copy the key to bitBetter | # copy the key to bitBetter | ||||||
| cp -f "$PWD/.keys/cert.cert" "$PWD/src/bitBetter" | cp -f "$PWD/.keys/cert.cert" "$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" | ||||||
| rm -f "$PWD/src/bitBetter/cert.cert" | rm -f "$PWD/src/bitBetter/cert.cert" | ||||||
| 
 | 
 | ||||||
| # gather all running instances | # gather all running instances | ||||||
| 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 | ||||||
| for INSTANCE in ${OLDINSTANCES[@]}; do | for INSTANCE in ${OLDINSTANCES[@]}; do | ||||||
| 	docker stop $INSTANCE | 	docker stop $INSTANCE | ||||||
| 	docker rm $INSTANCE | 	docker rm $INSTANCE | ||||||
| done | done | ||||||
| 
 | 
 | ||||||
| # update bitwarden itself | # update bitwarden itself | ||||||
| if [ "$1" = "update" ]; then | if [ "$1" = "update" ]; then | ||||||
| 	docker pull ghcr.io/bitwarden/self-host:beta | 	docker pull ghcr.io/bitwarden/self-host:beta | ||||||
| else | else | ||||||
| 	read -p "Update (or get) bitwarden source container (y/n): " -n 1 -r | 	read -p "Update (or get) bitwarden source container (y/n): " -n 1 -r | ||||||
| 	echo | 	echo | ||||||
| 	if [[ $REPLY =~ ^[Yy]$ ]] | 	if [[ $REPLY =~ ^[Yy]$ ]] | ||||||
| 	then | 	then | ||||||
| 		docker pull ghcr.io/bitwarden/self-host:beta | 		docker pull ghcr.io/bitwarden/self-host:beta | ||||||
| 	fi | 	fi | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| # stop and remove previous existing patch(ed) container | # stop and remove previous existing patch(ed) container | ||||||
| OLDINSTANCES=$(docker container ps --all -f Ancestor=bitwarden-patch --format '{{.ID}}') | OLDINSTANCES=$(docker container ps --all -f Ancestor=bitwarden-patched --format '{{.ID}}') | ||||||
| for INSTANCE in ${OLDINSTANCES[@]}; do | for INSTANCE in ${OLDINSTANCES[@]}; do | ||||||
| 	docker stop $INSTANCE | 	docker stop $INSTANCE | ||||||
| 	docker rm $INSTANCE | 	docker rm $INSTANCE | ||||||
| done | done | ||||||
| OLDINSTANCES=$(docker image ls bitwarden-patch --format '{{.ID}}') | OLDINSTANCES=$(docker image ls bitwarden-patched --format '{{.ID}}') | ||||||
| for INSTANCE in ${OLDINSTANCES[@]}; do | for INSTANCE in ${OLDINSTANCES[@]}; do | ||||||
| 	docker image rm $INSTANCE | 	docker image rm $INSTANCE | ||||||
| done | done | ||||||
| 
 | 
 | ||||||
| # 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}}') | ||||||
| for INSTANCE in ${OLDINSTANCES[@]}; do | for INSTANCE in ${OLDINSTANCES[@]}; do | ||||||
| 	docker stop $INSTANCE | 	docker stop $INSTANCE | ||||||
| 	docker rm $INSTANCE | 	docker rm $INSTANCE | ||||||
| done | done | ||||||
| 
 | 
 | ||||||
| # 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/self-host:beta) | PATCHINSTANCE=$(docker run -d --name bitwarden-extract ghcr.io/bitwarden/self-host:beta) | ||||||
| 
 | 
 | ||||||
| # create our temporary directory | # create our temporary directory | ||||||
| mkdir $TEMPDIRECTORY | mkdir $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 | ||||||
| for COMPONENT in ${COMPONENTS[@]}; do | for COMPONENT in ${COMPONENTS[@]}; do | ||||||
| 	mkdir "$TEMPDIRECTORY/$COMPONENT" | 	mkdir "$TEMPDIRECTORY/$COMPONENT" | ||||||
| 	docker cp $PATCHINSTANCE:/app/$COMPONENT/Core.dll "$TEMPDIRECTORY/$COMPONENT/Core.dll" | 	docker cp $PATCHINSTANCE:/app/$COMPONENT/Core.dll "$TEMPDIRECTORY/$COMPONENT/Core.dll" | ||||||
| done | done | ||||||
| 
 | 
 | ||||||
| # 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-patch --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 [ -f "$PWD/src/bitBetter/cert.cert" ]; then | if [ -f "$PWD/src/bitBetter/cert.cert" ]; then | ||||||
| 	sed -i 's/\r$//' "$PWD/.servers/serverlist.txt" | 	sed -i 's/\r$//' "$PWD/.servers/serverlist.txt" | ||||||
| 	cat "$PWD/.servers/serverlist.txt" | while read -r LINE; do | 	cat "$PWD/.servers/serverlist.txt" | while read -r LINE; do | ||||||
| 		if [[ $LINE == "#*" ]]; then | 		if [[ $LINE == "#*" ]]; then | ||||||
| 			bash -c "$LINE" | 			bash -c "$LINE" | ||||||
| 		fi | 		fi | ||||||
| 	done | 	done | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| # 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 | ||||||
| cp -f "$TEMPDIRECTORY/Identity/Core.dll" "$PWD/src/licenseGen" | cp -f "$TEMPDIRECTORY/Identity/Core.dll" "$PWD/src/licenseGen" | ||||||
| cp -f "$PWD/.keys/cert.pfx" "$PWD/src/licenseGen" | cp -f "$PWD/.keys/cert.pfx" "$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 | ||||||
| rm -f "$PWD/src/licenseGen/Core.dll" | rm -f "$PWD/src/licenseGen/Core.dll" | ||||||
| rm -f "$PWD/src/licenseGen/cert.pfx" | rm -f "$PWD/src/licenseGen/cert.pfx" | ||||||
| 
 | 
 | ||||||
| # remove our temporary directory | # remove our temporary directory | ||||||
| rm -rf "$TEMPDIRECTORY" | rm -rf "$TEMPDIRECTORY" | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user