mirror of
				https://github.com/jakeswenson/BitBetter.git
				synced 2025-10-31 12:53:25 +00:00 
			
		
		
		
	Add a script which simplifies Bitwarden updates
This commit is contained in:
		
							parent
							
								
									a55480d25e
								
							
						
					
					
						commit
						779e344389
					
				|  | @ -63,6 +63,7 @@ You'll also want to edit the `/path/to/bwdata/scripts/run.sh` file. In the `func | ||||||
| 
 | 
 | ||||||
| You can now start or restart Bitwarden as normal and the modified api will be used. **It is now ready to accept self-issued licenses.** | You can now start or restart Bitwarden as normal and the modified api will be used. **It is now ready to accept self-issued licenses.** | ||||||
| 
 | 
 | ||||||
|  | To update Bitwarden, the provided `update-bitwarden.sh` script can be used. It will rebuild the BitBetter images and automatically update Bitwarden afterwards. Docker pull errors can be ignored for api and identity images. | ||||||
| --- | --- | ||||||
| ### Note: Manually generating Certificate & Key | ### Note: Manually generating Certificate & Key | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										66
									
								
								update-bitwarden.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										66
									
								
								update-bitwarden.sh
									
									
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,66 @@ | ||||||
|  | #!/bin/bash | ||||||
|  | 
 | ||||||
|  | SCRIPT_BASE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||||||
|  | BW_VERSION="$(curl --silent "https://api.github.com/repos/bitwarden/server/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')" | ||||||
|  | 
 | ||||||
|  | echo "Starting Bitwarden update, newest server version: $BW_VERSION" | ||||||
|  | 
 | ||||||
|  | # Default path is the parent directory of the BitBetter location | ||||||
|  | BITWARDEN_BASE="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )" | ||||||
|  | 
 | ||||||
|  | # Get Bitwarden base from user (or keep default value) | ||||||
|  | read -p "Enter Bitwarden base directory [$BITWARDEN_BASE]: " tmpbase | ||||||
|  | BITWARDEN_BASE=${tmpbase:-$BITWARDEN_BASE} | ||||||
|  | 
 | ||||||
|  | # Check if directory exists and is valid | ||||||
|  | [ -d "$BITWARDEN_BASE" ] || { echo "Bitwarden base directory $BITWARDEN_BASE not found!"; exit 1; } | ||||||
|  | [ -f "$BITWARDEN_BASE/bitwarden.sh" ] || { echo "Bitwarden base directory $BITWARDEN_BASE is not valid!"; exit 1; } | ||||||
|  | 
 | ||||||
|  | # Check if user wants to recreate the docker-compose override file | ||||||
|  | RECREATE_OV="y" | ||||||
|  | read -p "Rebuild docker-compose override? [Y/n]: " tmprecreate | ||||||
|  | RECREATE_OV=${tmprecreate:-$RECREATE_OV} | ||||||
|  | 
 | ||||||
|  | if [[ $RECREATE_OV =~ ^[Yy]$ ]] | ||||||
|  | then | ||||||
|  |     { | ||||||
|  |         echo "version: '3'" | ||||||
|  |         echo "" | ||||||
|  |         echo "services:" | ||||||
|  |         echo "  api:" | ||||||
|  |         echo "    image: bitbetter/api:$BW_VERSION" | ||||||
|  |         echo "" | ||||||
|  |         echo "  identity:" | ||||||
|  |         echo "    image: bitbetter/identity:$BW_VERSION" | ||||||
|  |         echo "" | ||||||
|  |     } > $BITWARDEN_BASE/bwdata/docker/docker-compose.override.yml | ||||||
|  |     echo "BitBetter docker-compose override created!" | ||||||
|  | else | ||||||
|  |     echo "Make sure to check if the docker override contains the correct image version ($BW_VERSION) in $BITWARDEN_BASE/bwdata/docker/docker-compose.override.yml!" | ||||||
|  | fi | ||||||
|  | 
 | ||||||
|  | # Check if user wants to rebuild the bitbetter images | ||||||
|  | REBUILD_BB="n" | ||||||
|  | read -p "Rebuild BitBetter images? [y/N]: " tmprebuild | ||||||
|  | REBUILD_BB=${tmprebuild:-$REBUILD_BB} | ||||||
|  | 
 | ||||||
|  | if [[ $REBUILD_BB =~ ^[Yy]$ ]] | ||||||
|  | then | ||||||
|  |     ./build.sh | ||||||
|  |     echo "BitBetter images updated to version: $BW_VERSION" | ||||||
|  | fi | ||||||
|  | 
 | ||||||
|  | # Now start the bitwarden update | ||||||
|  | cd $BITWARDEN_BASE | ||||||
|  | 
 | ||||||
|  | ./bitwarden.sh updateself | ||||||
|  | 
 | ||||||
|  | # Update the bitwarden.sh: automatically patch run.sh to fix docker-compose pull errors for private images | ||||||
|  | awk '1;/function downloadRunFile/{c=6}c&&!--c{print "sed -i '\''s/docker-compose pull/docker-compose pull --ignore-pull-failures/g'\'' $SCRIPTS_DIR/run.sh"}' $BITWARDEN_BASE/bitwarden.sh > tmp_bw.sh && mv tmp_bw.sh $BITWARDEN_BASE/bitwarden.sh | ||||||
|  | chmod +x $BITWARDEN_BASE/bitwarden.sh | ||||||
|  | echo "Patching bitwarden.sh completed..." | ||||||
|  | 
 | ||||||
|  | ./bitwarden.sh update | ||||||
|  | 
 | ||||||
|  | cd $SCRIPT_BASE | ||||||
|  | echo "Bitwarden update completed!" | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user