Skip to content

Commit

Permalink
tftpd-hpa VERSION added
Browse files Browse the repository at this point in the history
  • Loading branch information
3x3cut0r committed Oct 31, 2023
1 parent 115ba3f commit c3dd372
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/tftpd-hpa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and Tag
id: tag
run: |
docker build -t 3x3cut0r/tftpd-hpa:latest ./tftpd-hpa
VERSION=$(docker run --rm 3x3cut0r/tftpd-hpa:latest sh -c "cat /VERSION | grep tftpd-hpa | cut -d= -f2")
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
# https://github.com/docker/build-push-action
- name: Build and push
uses: docker/build-push-action@v5
Expand All @@ -52,3 +59,4 @@ jobs:
push: true
tags: |
3x3cut0r/tftpd-hpa:latest
3x3cut0r/tftpd-hpa:${{ steps.tag.outputs.VERSION }}
6 changes: 5 additions & 1 deletion tftpd-hpa/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ RUN addgroup -g $GID -S tftp && \
# add tftp-hpa
RUN apk add --no-cache tftp-hpa runit tzdata && \
mkdir -p /tftpboot \
/runit-services \
/runit-services/tftpd-hpa \
/runit-services/syslogd && \
echo -e "#!/bin/sh\nbusybox syslogd -n -O /dev/stdout" > \
Expand All @@ -29,6 +28,11 @@ RUN apk add --no-cache tftp-hpa runit tzdata && \
chmod +x /runit-services/syslogd/run \
/runit-services/tftpd-hpa/run

# store versions in /VERSION
RUN touch /VERSION && \
echo "alpine=$(cat /etc/alpine-release)" > /VERSION && \
echo "tftpd-hpa=$(/usr/sbin/in.tftpd --version | cut -d, -f1 | cut -d' ' -f2)" >> /VERSION

# tftpd-hpa environment variables
# (see: https://manpages.debian.org/testing/tftpd-hpa/tftpd.8.en.html)
ENV TZ="UTC" \
Expand Down
2 changes: 1 addition & 1 deletion tftpd-hpa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ docker run -d \
### 1.2 docker-compose.yaml <a name="docker-compose"></a>

```shell
version: '3'
version: '3.9'

services:
tftpd-hpa:
Expand Down
20 changes: 18 additions & 2 deletions tftpd-hpa/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
#!/bin/sh
set -e

############################
# setup user environment #
############################

# set timezone
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

############################
# run app #
############################

# if started without args, exec in.tftpd
if [ "$#" = "0" ]; then

param=""
if [ "$BLOCKSIZE" != "" ]; then param="${param} --blocksize $BLOCKSIZE"; fi
if [ "$CREATE" = "1" ]; then param="${param} --create"; fi
Expand All @@ -18,21 +29,26 @@ if [ "$#" = "0" ]; then
if [ "$VERBOSE" = "1" ]; then param="${param} --verbose"; fi
if [ "$VERBOSITY" != "" ]; then param="${param} --verbosity $VERBOSITY"; fi
param="--foreground --address 0.0.0.0:69 --user tftp ${param} /tftpboot"

echo -e "\nINFO: /usr/sbin/in.tftpd ${param}\n"
echo -e "#!/bin/sh\n/usr/sbin/in.tftpd ${param}" > /runit-services/tftpd-hpa/run

else
# if first arg looks like a flag, assume we want to run in.tftpd
if [ "$( echo "$1" | cut -c1 )" = "-" ]; then
echo -e "\nINFO: /usr/sbin/in.tftpd --foreground --address 0.0.0.0:69 --user tftp $@\n"
echo -e "#!/bin/sh\n/usr/sbin/in.tftpd --foreground --address 0.0.0.0:69 --user tftp $@" > /runit-services/tftpd-hpa/run

# if the first arg is "in.tftpd" ...
elif [ "$1" = "in.tftpd" ]; then
echo -e "\nINFO: /usr/sbin/in.tftpd --foreground --address 0.0.0.0:69 --user tftp $@\n"
echo -e "#!/bin/sh\n/usr/sbin/in.tftpd --foreground --address 0.0.0.0:69 --user tftp ${@}" > /runit-services/tftpd-hpa/run

# if first arg doesn't looks like a flag
else
printf "\nINFO: $@\n\n"
echo -e "#!/bin/sh\n$@" > /runit-services/tftpd-hpa/run
exec "$@"
exit 0
fi
fi

exec runsvdir /runit-services

0 comments on commit c3dd372

Please sign in to comment.