Skip to content

Commit

Permalink
Bareos 22 (#186)
Browse files Browse the repository at this point in the history
* add bareos 22
  • Loading branch information
barcus authored Jun 17, 2024
1 parent 98d2675 commit db8b993
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 250 deletions.
8 changes: 4 additions & 4 deletions .github/actions/prepare-bareos-app/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

BUILDX_VER='v0.5.1'
latest_ubuntu='21'
latest_alpine='21'
latest_api='21'
latest_alpine='22'
latest_api='22'

build_file="${GITHUB_WORKSPACE}/build/app_build.txt"
tag_file="${GITHUB_WORKSPACE}/build/tag_build.txt"
Expand Down Expand Up @@ -55,7 +55,6 @@ for file in $docker_files; do
echo "${app} ${tag_build} ${version}" >> "$tag_file"
if [ "${version}" == "$latest_ubuntu" ]; then
echo "${app} ${tag_build} ubuntu" >> "$tag_file"
echo "${app} ${tag_build} latest" >> "$tag_file"
fi
fi
if [ "${tag_build}" == 'nightly-ubuntu-pgsql' ]; then
Expand All @@ -65,7 +64,6 @@ for file in $docker_files; do
echo "${app} ${tag_build} ${version}" >> "$tag_file"
if [ "${version}" == "$latest_ubuntu" ]; then
echo "${app} ${tag_build} ubuntu" >> "$tag_file"
echo "${app} ${tag_build} latest" >> "$tag_file"
fi
fi
fi
Expand All @@ -81,10 +79,12 @@ for file in $docker_files; do
echo "${app} ${tag_build} ${version}-alpine" >> "$tag_file"
if [ "${version}" == "$latest_alpine" ]; then
echo "${app} ${tag_build} alpine" >> "$tag_file"
echo "${app} ${tag_build} latest" >> "$tag_file"
fi
fi
if [ "${app}" != 'director' ] && [ "${version}" == "$latest_alpine" ]; then
echo "${app} ${tag_build} alpine" >> "$tag_file"
echo "${app} ${tag_build} latest" >> "$tag_file"
fi
if [ "${app}" == 'api' ] && [ "${version}" == "$latest_api" ]; then
echo "${app} ${tag_build} ${version}" >> "$tag_file"
Expand Down
32 changes: 32 additions & 0 deletions api/22-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM python:3.10-alpine

LABEL maintainer="barcus@tou.nu"

ARG BUILD_DATE
ARG NAME
ARG VCS_REF
ARG VERSION

LABEL org.label-schema.schema-version="1.0" \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$NAME \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/barcus/bareos" \
org.label-schema.version=$VERSION

RUN pip install --no-cache-dir --upgrade pip==22.0.4

RUN adduser -D bareos
USER bareos
WORKDIR /home/bareos

ENV PATH="/home/bareos/.local/bin:${PATH}"
RUN pip install --no-cache-dir "bareos-restapi>=22*,<23*"

COPY --chown=bareos docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod a+x /docker-entrypoint.sh

EXPOSE 8000

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["uvicorn","--log-level", "debug", "--host", "0.0.0.0", "bareos_restapi:app", "--reload"]
20 changes: 20 additions & 0 deletions api/22-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env ash
#set -x

secret=`tr -cd "[:alnum:]" < /dev/urandom | fold -w30 | head -n1`

# Generate api.ini config
cat <<EOF > /home/bareos/api.ini
[Director]
Name=${BAREOS_DIR_HOST}
Address=${BAREOS_DIR_HOST}
Port=9101
[JWT]
secret_key = ${secret}
algorithm = HS256
access_token_expire_minutes = 30
EOF

# Run Dockerfile CMD
exec "$@"
35 changes: 35 additions & 0 deletions client/22-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Dockerfile Bareos client/file daemon
FROM alpine:3.20

LABEL maintainer="barcus@tou.nu"

ARG BUILD_DATE
ARG NAME
ARG VCS_REF
ARG VERSION

ENV BAREOS_DAEMON_USER bareos
ENV BAREOS_DAEMON_GROUP bareos

LABEL org.label-schema.schema-version="1.0" \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$NAME \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/barcus/bareos" \
org.label-schema.version=$VERSION

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

RUN apk add --no-cache bareos-filedaemon openssh-client tar shadow bash su-exec

RUN tar czf /bareos-fd.tgz /etc/bareos/bareos-fd.d
RUN mkdir /run/bareos \
&& chown bareos /run/bareos

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod a+x /docker-entrypoint.sh

EXPOSE 9102

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/usr/sbin/bareos-fd", "-f"]
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ fi
if [ $(id -u) = '0' ]; then
[ -n "${PUID}" ] && usermod -u ${PUID} ${BAREOS_DAEMON_USER}
[ -n "${PGID}" ] && groupmod -g ${PGID} ${BAREOS_DAEMON_GROUP}

if [ ! -f /etc/bareos/bareos-config.control ]; then
tar xzf /bareos-fd.tgz --backup=simple --suffix=.before-control

Expand All @@ -24,10 +23,10 @@ if [ $(id -u) = '0' ]; then

# Fix permissions
find /etc/bareos ! -user ${BAREOS_DAEMON_USER} -exec chown ${BAREOS_DAEMON_USER}:${BAREOS_DAEMON_GROUP} {} \;
chown -R ${BAREOS_DAEMON_USER}:${BAREOS_DAEMON_GROUP} /var/lib/bareos /var/log/bareos
chown ${BAREOS_DAEMON_USER}:${BAREOS_DAEMON_GROUP} /run/bareos /var/log/bareos /var/lib/bareos

# Gosu
[ "${BAREOS_DAEMON_USER}" != 'root' ] && exec gosu "${BAREOS_DAEMON_USER}" "$BASH_SOURCE" "$@"
# Su-exec
[ "${BAREOS_DAEMON_USER}" != 'root' ] && su-exec "${BAREOS_DAEMON_USER}" "$BASH_SOURCE" "$@"
fi

exec "$@"
46 changes: 0 additions & 46 deletions client/nightly-ubuntu/Dockerfile

This file was deleted.

38 changes: 38 additions & 0 deletions director-pgsql/22-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Bareos director Dockerfile
FROM alpine:3.20

LABEL maintainer="barcus@tou.nu"

ARG BUILD_DATE
ARG NAME
ARG VCS_REF
ARG VERSION

LABEL org.label-schema.schema-version="1.0" \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$NAME \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/barcus/bareos" \
org.label-schema.version=$VERSION

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

RUN apk add --no-cache bareos bareos-postgresql postgresql-client curl tzdata tar

RUN tar czf /bareos-dir.tgz /etc/bareos
RUN mkdir /run/bareos \
&& chown bareos /run/bareos

COPY webhook-notify /usr/local/bin/webhook-notify
RUN chmod u+x /usr/local/bin/webhook-notify

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod u+x /docker-entrypoint.sh

EXPOSE 9101

VOLUME /etc/bareos
VOLUME /var/lib/bareos

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/usr/sbin/bareos-dir", "-u", "bareos", "-f"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env ash

github_bareos='raw.githubusercontent.com/bareos/bareos'
webui_admin_conf='master/webui/install/bareos/bareos-dir.d/profile/webui-admin.conf'
Expand All @@ -21,11 +21,13 @@ if [ ! -f /etc/bareos/bareos-config.control ]; then

# Update bareos-director configs
# Director / mycatalog & mail report
sed -i 's#dbuser = "bareos"#dbuser = '\"${DB_USER}\"'#' \
sed -i "s#dbuser =.*#dbuser = $DB_USER#" \
/etc/bareos/bareos-dir.d/catalog/MyCatalog.conf
sed -i 's#dbpassword = ""#dbpassword = '\"${DB_PASSWORD}\"'#' \
sed -i 's#dbpassword =.*#dbpassword = '\""${DB_PASSWORD}"\"'#' \
/etc/bareos/bareos-dir.d/catalog/MyCatalog.conf
sed -i 's#dbname = "bareos"#dbname = '\"${DB_NAME}\"'\n dbaddress = '\"${DB_HOST}\"'\n dbport = '\"${DB_PORT}\"'#' \
sed -i 's#dbname =.*#dbname = '\""${DB_NAME}"\"'\n dbaddress = '\""${DB_HOST}"\"'\n dbport = '\""${DB_PORT}"\"'#' \
/etc/bareos/bareos-dir.d/catalog/MyCatalog.conf
sed -i 's#dbdriver = .*#dbdriver = '\""postgresql"\"'#' \
/etc/bareos/bareos-dir.d/catalog/MyCatalog.conf
[ -n "${SENDER_MAIL}" ] && sed -i "s#<%r#<${SENDER_MAIL}#g" \
/etc/bareos/bareos-dir.d/messages/Daemon.conf
Expand All @@ -35,7 +37,7 @@ if [ ! -f /etc/bareos/bareos-config.control ]; then
/etc/bareos/bareos-dir.d/messages/Daemon.conf
[ -n "${SENDER_MAIL}" ] && sed -i "s#<%r#<${SENDER_MAIL}#g" \
/etc/bareos/bareos-dir.d/messages/Standard.conf
sed -i "s#/usr/bin/bsmtp -h localhost#/usr/bin/bsmtp -h ${SMTP_HOST}#" \
sed -i "s#/usr/bin/bsmtp -h localhost#/usr/bin/bsmtp -h ${SMTP_HOST}#g" \
/etc/bareos/bareos-dir.d/messages/Standard.conf
sed -i "s#mail = root#mail = ${ADMIN_MAIL}#" \
/etc/bareos/bareos-dir.d/messages/Standard.conf
Expand Down Expand Up @@ -63,12 +65,19 @@ if [ ! -f /etc/bareos/bareos-config.control ]; then
# webUI
sed -i 's#Password = .*#Password = '\""${BAREOS_WEBUI_PASSWORD}"\"'#' \
/etc/bareos/bareos-dir.d/console/admin.conf
sed -i "s#}# TlsEnable = false\n}#" \
/etc/bareos/bareos-dir.d/console/admin.conf


# MyCatalog Backup
sed -i "s#/var/lib/bareos/bareos.sql#/var/lib/bareos-director/bareos.sql#" \
/etc/bareos/bareos-dir.d/fileset/Catalog.conf
sed -i "s#make_catalog_backup MyCatalog#make_catalog_backup ${DB_NAME} ${DB_USER} '' ${DB_HOST}#" \
/etc/bareos/bareos-dir.d/job/BackupCatalog.conf

# Add pgpass file to ${DB_USER} home
homedir=$(getent passwd "$DB_USER" | cut -d: -f6)
echo "${DB_HOST}:${DB_PORT}:${DB_NAME}:${DB_USER}:${DB_PASSWORD}" > "${homedir}/.pgpass"
chmod 600 "${homedir}/.pgpass"
chown "${DB_USER}" "${homedir}/.pgpass"

# Control file
touch /etc/bareos/bareos-config.control
Expand Down Expand Up @@ -97,16 +106,15 @@ export PGPASSWORD=${DB_ADMIN_PASSWORD}
[[ -z "${DB_UPDATE}" ]] && DB_UPDATE='false'

if [ ! -f /etc/bareos/bareos-db.control ] && [ "${DB_INIT}" == 'true' ] ; then
# Init Postgresql DB
# Init Postgres DB
echo "Bareos DB init"
echo "Bareos DB init: Create user ${DB_USER}"
psql -c "create user ${DB_USER} with createdb createrole login;"
echo "Bareos DB init: Set user password"
psql -c "alter user ${DB_USER} password '${DB_PASSWORD}';"
/usr/lib/bareos/scripts/create_bareos_database 2>/dev/null
/usr/lib/bareos/scripts/make_bareos_tables 2>/dev/null
/usr/lib/bareos/scripts/grant_bareos_privileges 2>/dev/null

/etc/bareos/scripts/create_bareos_database 2>/dev/null
/etc/bareos/scripts/make_bareos_tables 2>/dev/null
/etc/bareos/scripts/grant_bareos_privileges 2>/dev/null
# Control file
touch /etc/bareos/bareos-db.control
fi
Expand All @@ -115,14 +123,14 @@ if [ "${DB_UPDATE}" == 'true' ] ; then
# Try Postgres upgrade
echo "Bareoos DB update"
echo "Bareoos DB update: Update tables"
/usr/lib/bareos/scripts/update_bareos_tables 2>/dev/null
/etc/bareos/scripts/update_bareos_tables 2>/dev/null
echo "Bareoos DB update: Grant privileges"
/usr/lib/bareos/scripts/grant_bareos_privileges 2>/dev/null
/etc/bareos/scripts/grant_bareos_privileges 2>/dev/null
fi

# Fix permissions
find /etc/bareos ! -user bareos -exec chown bareos {} \;
chown -R bareos:bareos /var/lib/bareos
chown -R bareos:bareos /var/lib/bareos /var/log/bareos

# Run Dockerfile CMD
exec "$@"
File renamed without changes.
60 changes: 0 additions & 60 deletions director-pgsql/nightly-ubuntu/Dockerfile

This file was deleted.

Loading

0 comments on commit db8b993

Please sign in to comment.