Skip to content

Commit

Permalink
add update mirrors on startup option
Browse files Browse the repository at this point in the history
  • Loading branch information
brettinternet committed Jan 3, 2024
1 parent 464c7b4 commit 56496d0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions update-mirrors/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM bash:alpine3.19
RUN apk --update add git curl coreutils sed gawk dumb-init

ENV WORKING_DIRECTORY="/repos"
ENV RUN_ON_STARTUP="true"

COPY start.sh update.sh /

Expand Down
3 changes: 2 additions & 1 deletion update-mirrors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
A simple cronjob to update git mirrors. Curl is available for pre/post commands.

```sh
docker create -d \
docker create \
-v ./git:/repos
-e WORKING_DIRECTORY=/repos \
-e RUN_ON_STARTUP="true" \
-e GIT_REMOTE_1=https://github.com/brettinternet/containers \
-e GIT_REMOTE_2 https://github.com/brettinternet/homelab \
-e POST_COMMANDS_SUCCESS "curl -d 'Backup successful 😎' ntfy.sh/mytopic" \
Expand Down
6 changes: 6 additions & 0 deletions update-mirrors/start.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/sh

RUN_ON_STARTUP=$(echo "$RUN_ON_STARTUP" | awk '{print tolower($0)}')

if [ "$RUN_ON_STARTUP" == "true" ]; then
bash /update.sh
fi

SCHEDULE=${CRON:-"*/30 * * * *"}

echo "Update schedule: $SCHEDULE"
Expand Down

0 comments on commit 56496d0

Please sign in to comment.