mirror of
https://github.com/Ravinou/borgwarehouse
synced 2024-05-15 20:16:50 +02:00
feat: add cronjobs to docker
This commit is contained in:
parent
f1cfe2459b
commit
9e55b47f77
|
@ -1,12 +1,14 @@
|
|||
FROM node:18-bookworm-slim
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y curl git jq borgbackup openssh-server sudo && \
|
||||
apt-get install -y curl git jq jc borgbackup openssh-server sudo cron && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN echo "borgwarehouse ALL=(ALL) NOPASSWD: /usr/sbin/service ssh restart" >> /etc/sudoers
|
||||
|
||||
RUN echo "borgwarehouse ALL=(ALL) NOPASSWD: /usr/sbin/service cron restart" >> /etc/sudoers
|
||||
|
||||
RUN groupadd borgwarehouse
|
||||
|
||||
RUN useradd -m -g borgwarehouse borgwarehouse
|
||||
|
|
|
@ -40,11 +40,18 @@ check_repos_directory() {
|
|||
fi
|
||||
}
|
||||
|
||||
add_cron_job() {
|
||||
local CRON_JOB="* * * * * curl --request POST --url 'http://localhost:3000/api/cronjob/checkStatus' --header 'Authorization: Bearer $CRONJOB_KEY'; curl --request POST --url 'http://localhost:3000/api/cronjob/getStorageUsed' --header 'Authorization: Bearer $CRONJOB_KEY'"
|
||||
echo "$CRON_JOB" | crontab -u borgwarehouse -
|
||||
}
|
||||
|
||||
init_ssh_server
|
||||
check_ssh_directory
|
||||
create_authorized_keys_file
|
||||
check_repos_directory
|
||||
add_cron_job
|
||||
|
||||
sudo service ssh restart
|
||||
sudo service cron restart
|
||||
|
||||
exec "$@"
|
|
@ -1,9 +0,0 @@
|
|||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/sbin/userdel -rf [[\:xdigit\:]]*
|
||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/sbin/useradd -d /var/borgwarehouse/[[\:xdigit\:]]* -s /bin/bash -m --badname [[\:xdigit\:]]*
|
||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/mkdir -p /var/borgwarehouse/[[\:xdigit\:]]*/repos/repo[[\:digit\:]]*, /usr/bin/mkdir -p /var/borgwarehouse/[[\:xdigit\:]]*/.ssh
|
||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/touch /var/borgwarehouse/[[\:xdigit\:]]*/.ssh/authorized_keys
|
||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/chmod -R 750 /var/borgwarehouse/[[\:xdigit\:]]*, /usr/bin/chmod 600 /var/borgwarehouse/[[\:xdigit\:]]*/.ssh/authorized_keys
|
||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/chown -R [[\:xdigit\:]]*\:borgwarehouse /var/borgwarehouse/[[\:xdigit\:]]*
|
||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/tee /var/borgwarehouse/[[\:xdigit\:]]*/.ssh/authorized_keys
|
||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/sed -ri s|*|g /var/borgwarehouse/[[\:xdigit\:]]*/.ssh/authorized_keys
|
||||
borgwarehouse ALL=(ALL) NOPASSWD: /usr/bin/du -s -- [[\:xdigit\:]]*
|
|
@ -34,7 +34,7 @@ if [ ${#repositoryName} != 8 ]; then
|
|||
fi
|
||||
|
||||
# Delete the repository and the line associated in the authorized_keys file
|
||||
if [ -d "$1" ]; then
|
||||
if [ -d "${pool}/${repositoryName}" ]; then
|
||||
# Delete the repository
|
||||
rm -rf "${pool}/${repositoryName}"
|
||||
# Delete the line in the authorized_keys file
|
||||
|
|
Loading…
Reference in a new issue