From ffb4d2ab6ef6b1fe8d378b3848b211dab339a2dc Mon Sep 17 00:00:00 2001 From: Greizgh Date: Tue, 4 May 2021 19:19:53 +0200 Subject: [PATCH] rename built package --- .gitignore | 2 +- README.md | 6 +++--- build.sh | 16 ++++++++-------- control.dist | 2 +- debian/conffiles | 4 ++-- debian/postinst | 8 ++++---- patch/amd64/Dockerfile.patch | 28 ++++++++++++++-------------- patch/armv7/Dockerfile.patch | 28 ++++++++++++++-------------- service.dist | 10 +++++----- 9 files changed, 52 insertions(+), 52 deletions(-) diff --git a/.gitignore b/.gitignore index e5997a8..ed2902e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ git/ dist/ debian/config.env debian/control -debian/bitwarden_rs.service +debian/vaultwarden.service Dockerfile diff --git a/README.md b/README.md index 33cdb2a..d53e41e 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,10 @@ Then: ``` git clone https://github.com/greizgh/bitwarden_rs-debian.git cd bitwarden_rs-debian -./build.sh -r # target bitwarden_rs version, example 1.19.0 +./build.sh -r # target vaultwarden version, example 1.19.0 ``` -The `build.sh` script will build bitwarden_rs for the same Debian version which targets vaultwarden. +The `build.sh` script will build vaultwarden for the same Debian version which targets vaultwarden. That means, to build vaultwarden v1.19.0, make sure to checkout tag `v1.19.0` of this project. To compile for a different Debian version, specify the release name (e.g. Stretch, Buster) using the `-o` option. You can compile for arm32v7 or amd64 architecture using the `-a` option, only the Buster (default) release of debian is supported by arm32v7. @@ -33,7 +33,7 @@ To compile for a different Debian version, specify the release name (e.g. Stretc The packaged systemd unit is **disabled**, you need to configure vaultwarden through its [EnvFile](https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines): -`/etc/bitwarden_rs/config.env` +`/etc/vaultwarden/config.env` You will also probably want to setup a reverse proxy. diff --git a/build.sh b/build.sh index 652b62b..296accb 100755 --- a/build.sh +++ b/build.sh @@ -27,7 +27,7 @@ if [ -z "$ARCH_DIR" ]; then ARCH_DIR="amd64"; fi ARCH=$ARCH_DIR if [[ "$ARCH" =~ ^arm ]]; then ARCH="armhf"; fi -# Clone bitwarden_rs +# Clone vaultwarden if [ ! -d "$SRC" ]; then git clone https://github.com/dani-garcia/vaultwarden.git "$SRC" fi @@ -45,8 +45,8 @@ cd - || exit # Prepare EnvFile CONFIG="$DIR/debian/config.env" cp "$SRC/.env.template" "$CONFIG" -sed -i "s#\# DATA_FOLDER=data#DATA_FOLDER=/var/lib/bitwarden_rs#" "$CONFIG" -sed -i "s#\# WEB_VAULT_FOLDER=web-vault/#WEB_VAULT_FOLDER=/usr/share/bitwarden_rs/web-vault/#" "$CONFIG" +sed -i "s#\# DATA_FOLDER=data#DATA_FOLDER=/var/lib/vaultwarden#" "$CONFIG" +sed -i "s#\# WEB_VAULT_FOLDER=web-vault/#WEB_VAULT_FOLDER=/usr/share/vaultwarden/web-vault/#" "$CONFIG" sed -i "s/Uncomment any of the following lines to change the defaults/Uncomment any of the following lines to change the defaults\n\n## Warning\n## The default systemd-unit does not allow any custom directories.\n## Be sure to check if the service has appropriate permissions before you set custom paths./g" "$CONFIG" mkdir -p "$DST" @@ -63,7 +63,7 @@ sed -i "s/Version:.*/Version: $REF-1/" "$CONTROL" sed -i "s/Architecture:.*/Architecture: $ARCH/" "$CONTROL" # Prepare Systemd-unit -SYSTEMD_UNIT="$DIR/debian/bitwarden_rs.service" +SYSTEMD_UNIT="$DIR/debian/vaultwarden.service" cp "$DIR/service.dist" "$SYSTEMD_UNIT" if [ "$DB_TYPE" = "mysql" ]; then sed -i "s/After=network.target/After=network.target mysqld.service\nRequires=mysqld.service/g" "$SYSTEMD_UNIT" @@ -71,11 +71,11 @@ elif [ "$DB_TYPE" = "postgresql" ]; then sed -i "s/After=network.target/After=network.target postgresql.service\nRequires=postgresql.service/g" "$SYSTEMD_UNIT" fi -echo "[INFO] docker build -t bitwarden-deb "$DIR" --build-arg DB=$DB_TYPE" +echo "[INFO] docker build -t vaultwarden-deb "$DIR" --build-arg DB=$DB_TYPE" cp -r "$DIR/debian" "$SRC/debian" -docker build -t bitwarden-deb "$SRC" --build-arg DB=$DB_TYPE --target dpkg -f "$DIR/Dockerfile" +docker build -t vaultwarden-deb "$SRC" --build-arg DB=$DB_TYPE --target dpkg -f "$DIR/Dockerfile" pushd "$SRC"; git clean -fd; popd -CID=$(docker run -d bitwarden-deb) -docker cp "$CID":/bitwarden_package/vaultwarden.deb "$DST/vaultwarden-${OS_VERSION_NAME}-${REF}-${DB_TYPE}-${ARCH_DIR}.deb" +CID=$(docker run -d vaultwarden-deb) +docker cp "$CID":/vaultwarden_package/vaultwarden.deb "$DST/vaultwarden-${OS_VERSION_NAME}-${REF}-${DB_TYPE}-${ARCH_DIR}.deb" docker rm "$CID" diff --git a/control.dist b/control.dist index 4a0aebc..210f58d 100644 --- a/control.dist +++ b/control.dist @@ -1,4 +1,4 @@ -Package: bitwarden-rs +Package: vaultwarden Architecture: - Maintainer: Greizgh Priority: optional diff --git a/debian/conffiles b/debian/conffiles index 32b7421..ab82831 100644 --- a/debian/conffiles +++ b/debian/conffiles @@ -1,2 +1,2 @@ -/etc/bitwarden_rs/Rocket.toml -/etc/bitwarden_rs/config.env +/etc/vaultwarden/Rocket.toml +/etc/vaultwarden/config.env diff --git a/debian/postinst b/debian/postinst index a6a62dd..3afd2ee 100755 --- a/debian/postinst +++ b/debian/postinst @@ -1,5 +1,5 @@ #!/bin/sh -DIR_MODE=0700 adduser --system --home /var/lib/bitwarden_rs bitwarden -chmod 700 /var/lib/bitwarden_rs -chmod 600 /etc/bitwarden_rs/config.env -chmod 600 /etc/bitwarden_rs/Rocket.toml +DIR_MODE=0700 adduser --system --home /var/lib/vaultwarden vaultwarden +chmod 700 /var/lib/vaultwarden +chmod 600 /etc/vaultwarden/config.env +chmod 600 /etc/vaultwarden/Rocket.toml diff --git a/patch/amd64/Dockerfile.patch b/patch/amd64/Dockerfile.patch index 179494e..386963d 100644 --- a/patch/amd64/Dockerfile.patch +++ b/patch/amd64/Dockerfile.patch @@ -7,20 +7,20 @@ + +####################### dpkg target ########################## +FROM build as dpkg -+RUN mkdir -p /bitwarden_package/DEBIAN -+RUN mkdir -p /bitwarden_package/usr/local/bin -+RUN mkdir -p /bitwarden_package/usr/lib/systemd/system -+RUN mkdir -p /bitwarden_package/etc/bitwarden_rs -+RUN mkdir -p /bitwarden_package/usr/share/bitwarden_rs ++RUN mkdir -p /vaultwarden_package/DEBIAN ++RUN mkdir -p /vaultwarden_package/usr/local/bin ++RUN mkdir -p /vaultwarden_package/usr/lib/systemd/system ++RUN mkdir -p /vaultwarden_package/etc/vaultwarden ++RUN mkdir -p /vaultwarden_package/usr/share/vaultwarden + -+WORKDIR /bitwarden_package -+COPY debian/control /bitwarden_package/DEBIAN/control -+COPY debian/postinst /bitwarden_package/DEBIAN/postinst -+COPY debian/conffiles /bitwarden_package/DEBIAN/conffiles -+COPY Rocket.toml /bitwarden_package/etc/bitwarden_rs -+COPY debian/config.env /bitwarden_package/etc/bitwarden_rs -+COPY debian/bitwarden_rs.service /bitwarden_package/usr/lib/systemd/system -+COPY --from=vault /web-vault /bitwarden_package/usr/share/bitwarden_rs/web-vault -+COPY --from=build app/target/release/vaultwarden /bitwarden_package/usr/local/bin ++WORKDIR /vaultwarden_package ++COPY debian/control /vaultwarden_package/DEBIAN/control ++COPY debian/postinst /vaultwarden_package/DEBIAN/postinst ++COPY debian/conffiles /vaultwarden_package/DEBIAN/conffiles ++COPY Rocket.toml /vaultwarden_package/etc/vaultwarden ++COPY debian/config.env /vaultwarden_package/etc/vaultwarden ++COPY debian/vaultwarden.service /vaultwarden_package/usr/lib/systemd/system ++COPY --from=vault /web-vault /vaultwarden_package/usr/share/vaultwarden/web-vault ++COPY --from=build app/target/release/vaultwarden /vaultwarden_package/usr/local/bin + +RUN dpkg-deb --build . vaultwarden.deb diff --git a/patch/armv7/Dockerfile.patch b/patch/armv7/Dockerfile.patch index aee809e..78d1063 100644 --- a/patch/armv7/Dockerfile.patch +++ b/patch/armv7/Dockerfile.patch @@ -7,20 +7,20 @@ + +####################### dpkg target ########################## +FROM build as dpkg -+RUN mkdir -p /bitwarden_package/DEBIAN -+RUN mkdir -p /bitwarden_package/usr/local/bin -+RUN mkdir -p /bitwarden_package/usr/lib/systemd/system -+RUN mkdir -p /bitwarden_package/etc/bitwarden_rs -+RUN mkdir -p /bitwarden_package/usr/share/bitwarden_rs ++RUN mkdir -p /vaultwarden_package/DEBIAN ++RUN mkdir -p /vaultwarden_package/usr/local/bin ++RUN mkdir -p /vaultwarden_package/usr/lib/systemd/system ++RUN mkdir -p /vaultwarden_package/etc/vaultwarden ++RUN mkdir -p /vaultwarden_package/usr/share/vaultwarden + -+WORKDIR /bitwarden_package -+COPY debian/control /bitwarden_package/DEBIAN/control -+COPY debian/postinst /bitwarden_package/DEBIAN/postinst -+COPY debian/conffiles /bitwarden_package/DEBIAN/conffiles -+COPY Rocket.toml /bitwarden_package/etc/bitwarden_rs -+COPY debian/config.env /bitwarden_package/etc/bitwarden_rs -+COPY debian/bitwarden_rs.service /bitwarden_package/usr/lib/systemd/system -+COPY --from=vault /web-vault /bitwarden_package/usr/share/bitwarden_rs/web-vault -+COPY --from=build app/target/armv7-unknown-linux-gnueabihf/release/vaultwarden /bitwarden_package/usr/local/bin ++WORKDIR /vaultwarden_package ++COPY debian/control /vaultwarden_package/DEBIAN/control ++COPY debian/postinst /vaultwarden_package/DEBIAN/postinst ++COPY debian/conffiles /vaultwarden_package/DEBIAN/conffiles ++COPY Rocket.toml /vaultwarden_package/etc/vaultwarden ++COPY debian/config.env /vaultwarden_package/etc/vaultwarden ++COPY debian/vaultwarden.service /vaultwarden_package/usr/lib/systemd/system ++COPY --from=vault /web-vault /vaultwarden_package/usr/share/vaultwarden/web-vault ++COPY --from=build app/target/armv7-unknown-linux-gnueabihf/release/vaultwarden /vaultwarden_package/usr/local/bin + +RUN dpkg-deb --build . vaultwarden.deb diff --git a/service.dist b/service.dist index bcc74f9..c9653bd 100644 --- a/service.dist +++ b/service.dist @@ -4,15 +4,15 @@ After=network.target [Service] Type=simple -User=bitwarden -ExecStart=/usr/local/bin/bitwarden_rs +User=vaultwarden +ExecStart=/usr/local/bin/vaultwarden PrivateTmp=true PrivateDevices=true ProtectHome=true ProtectSystem=strict -WorkingDirectory=/etc/bitwarden_rs -ReadWriteDirectories=/var/lib/bitwarden_rs -EnvironmentFile=/etc/bitwarden_rs/config.env +WorkingDirectory=/etc/vaultwarden +ReadWriteDirectories=/var/lib/vaultwarden +EnvironmentFile=/etc/vaultwarden/config.env [Install] WantedBy=multi-user.target