2022-06-02 21:26:42 +03:00
|
|
|
#!/usr/bin/env bash
|
2020-03-01 02:34:55 +03:00
|
|
|
set -o pipefail -o errexit
|
|
|
|
|
2024-03-09 10:46:13 +03:00
|
|
|
function replace_embedded_svg_icon() {
|
|
|
|
if [ ! -f $1 ]; then echo "$1 does not exist"; exit -1; fi
|
|
|
|
if [ ! -f $2 ]; then echo "$2 does not exist"; exit -1; fi
|
|
|
|
|
|
|
|
echo "'$1' -> '$2'"
|
|
|
|
|
|
|
|
first='`$'
|
|
|
|
last='^`'
|
|
|
|
sed -i "/$first/,/$last/{ /$first/{p; r $1
|
|
|
|
}; /$last/p; d }" $2
|
|
|
|
}
|
|
|
|
|
2020-03-01 02:34:55 +03:00
|
|
|
# If a patch was not provided, try to choose one
|
2022-06-02 21:26:42 +03:00
|
|
|
if [[ -z ${PATCH_NAME} ]]; then
|
2020-03-01 02:34:55 +03:00
|
|
|
# If a patch with the same name as the ref exists, use it
|
2022-06-02 21:26:42 +03:00
|
|
|
if [ -f "../patches/${VAULT_VERSION}.patch" ]; then
|
|
|
|
echo "Exact patch file found, using that"
|
|
|
|
PATCH_NAME="${VAULT_VERSION}.patch"
|
2023-12-18 19:09:47 +03:00
|
|
|
elif [ -f "../patches/legacy/${VAULT_VERSION}.patch" ]; then
|
|
|
|
echo "Exact legacy patch file found, using that"
|
|
|
|
echo "NOTE: This is a Legacy patch file for an older web-vault version!"
|
|
|
|
# Sleep 10 seconds so this note might be noticed a bit better
|
|
|
|
sleep 10
|
|
|
|
PATCH_NAME="legacy/${VAULT_VERSION}.patch"
|
2020-03-01 02:34:55 +03:00
|
|
|
else
|
2023-12-18 19:09:47 +03:00
|
|
|
echo "No exact patch file not found, using latest"
|
2020-03-01 02:34:55 +03:00
|
|
|
# If not, use the latest one
|
2024-01-17 02:47:43 +03:00
|
|
|
PATCH_NAME="$(find ../patches/ -type f -print0 | xargs -0 basename -a | sort -V | tail -n1)"
|
2020-03-01 02:34:55 +03:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-12-18 19:09:47 +03:00
|
|
|
# Final check if the patch file exists, if not, exit
|
|
|
|
if [[ ! -f "../patches/${PATCH_NAME}" ]]; then
|
|
|
|
echo "Patch file '${PATCH_NAME}' not found in the patches directory!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-11-30 19:52:03 +03:00
|
|
|
echo "Patching images"
|
2023-03-28 18:49:13 +03:00
|
|
|
cp -vfR ../resources/src/* ./apps/web/src/
|
2022-12-04 15:45:45 +03:00
|
|
|
|
2024-03-09 09:58:25 +03:00
|
|
|
echo "Patching logos"
|
2024-03-09 10:46:13 +03:00
|
|
|
replace_embedded_svg_icon \
|
2024-03-09 09:58:25 +03:00
|
|
|
../resources/vaultwarden-admin-console-logo.svg \
|
|
|
|
./apps/web/src/app/admin-console/icons/admin-console-logo.ts
|
2024-03-09 10:46:13 +03:00
|
|
|
replace_embedded_svg_icon \
|
2024-03-09 09:58:25 +03:00
|
|
|
../resources/vaultwarden-password-manager-logo.svg \
|
|
|
|
./apps/web/src/app/layouts/password-manager-logo.ts
|
|
|
|
|
2024-06-19 13:18:11 +03:00
|
|
|
echo "Remove non-free bitwarden_license/ code"
|
|
|
|
rm -rf ./bitwarden_license/
|
|
|
|
|
2022-06-02 21:26:42 +03:00
|
|
|
echo "Using patch: ${PATCH_NAME}"
|
|
|
|
git apply "../patches/${PATCH_NAME}" --reject
|
2022-11-30 19:52:03 +03:00
|
|
|
|
2020-03-01 02:34:55 +03:00
|
|
|
echo "Patching successful!"
|