Skip to content

Commit 45b79d5

Browse files
committed
Release 3.4.0 - See CHANGELOG.md
1 parent 77b9afa commit 45b79d5

File tree

9 files changed

+76
-580
lines changed

9 files changed

+76
-580
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 3.4.0 2023-06-01 <dave at tiredofit dot ca>
2+
3+
This release changes the DEBUG environment variable into LOG_LEVEl variable. Old Debug environment variables will be phased out in a future release
4+
5+
### Changed
6+
- Switch DEBUG to LOG_LEVEL and set default to 2
7+
- Refactor script and do a better job at creating configuration
8+
9+
110
## 3.3.1 2023-05-10 <dave at tiredofit dot ca>
211

312
### Added

README.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This will build a Docker Image for [tinc](https://www.tinc.org/) - A VPN service
3333
- [Installation](#installation)
3434
- [Build from Source](#build-from-source)
3535
- [Prebuilt Images](#prebuilt-images)
36-
- [Multi Architecture](#multi-archictecture)
36+
- [Multi Architecture](#multi-architecture)
3737
- [Configuration](#configuration)
3838
- [Quick Start](#quick-start)
3939
- [Persistent Storage](#persistent-storage)
@@ -62,11 +62,13 @@ Clone this repository and build the image with `docker build <arguments> (imagen
6262
### Prebuilt Images
6363
Builds of the image are available on [Docker Hub](https://hub.docker.com/r/tiredofit/tinc)
6464

65-
Builds of the image are also available on the [Github Container Registry](https://github.com/tiredofit/docker-/pkgs/container/docker-)
66-
65+
```bash
66+
docker pull docker.io/tiredofit/docker-tinc:(imagetag)
67+
Builds of the image are also available on the [Github Container Registry](https://github.com/tiredofit/docker-tinc/pkgs/container/docker-tinc)
68+
69+
```bash
70+
docker pull ghcr.io/tiredofit/docker-tinc:(imagetag)
6771
```
68-
docker pull ghcr.io/tiredofit/docker-:(imagetag)
69-
```
7072

7173
The following image tags are available along with their tagged release based on what's written in the [Changelog](CHANGELOG.md):
7274
@@ -113,7 +115,6 @@ Be sure to view the following repositories to understand all the customizable op
113115
| `CIPHER` | Encryption Cipher | `aes-256-cbc` |
114116
| `COMPRESSION` | Level of LZO Compression (e.g. 9) | `0` |
115117
| `CRON_PERIOD` | Adjustable time to check GIT Server for any updates | `30` |
116-
| `DEBUG` | Adjustable Debug level as per tinc documentation (e.g 5) | `0` |
117118
| `DIGEST` | Hashing Digest | `sha256` |
118119
| `ENABLE_GIT` | Enable Git Repository Functionality `TRUE` or `FALSE` | `TRUE` |
119120
| `ENABLE_CONFIG_RELOAD` | Enable reloading Tinc when configuration changes | `TRUE` |
@@ -123,6 +124,7 @@ Be sure to view the following repositories to understand all the customizable op
123124
| `GIT_USER` | Username to Authenticate to git server (e.g. `username`) | |
124125
| `INTERFACE` | Which Interface to use (relies on /dev/tun) (e.g. `tun0`) | `tun0` |
125126
| `LISTEN_PORT` | Listening Port | `655` |
127+
| `LOG_LEVEL` | Adjustable Debug level as per tinc documentation (e.g 5) | `2` |
126128
| `LOG_PATH` | Log Path | `/var/log/tinc` |
127129
| `MAC_LENGTH` | MAC Length | `16` |
128130
| `NETWORK` | The VPN name - (e.g. `securenetwork`) | |
@@ -151,16 +153,17 @@ The following ports are exposed.
151153

152154
For debugging and maintenance purposes you may want access the containers shell.
153155

154-
``bash
156+
````bash
155157
docker exec -it (whatever your container name is) bash
156-
``
158+
````
157159

158160
## Support
159161

160162
These images were built to serve a specific need in a production environment and gradually have had more functionality added based on requests from the community.
161163
### Usage
162164
- The [Discussions board](../../discussions) is a great place for working with the community on tips and tricks of using this image.
163165
- Consider [sponsoring me](https://github.com/sponsors/tiredofit) for personalized support
166+
164167
### Bugfixes
165168
- Please, submit a [Bug Report](issues/new) if something isn't working as expected. I'll do my best to issue a fix in short order.
166169

install/assets/cron/crontab.txt

-1
This file was deleted.

install/assets/defaults/10-tinc

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ ENABLE_GIT=${ENABLE_GIT:-"TRUE"}
99
ENABLE_WATCHDOG=${ENABLE_WATCHDOG:-"FALSE"}
1010
INTERFACE=${INTERFACE:-"tun0"}
1111
LISTEN_PORT=${LISTEN_PORT:-655}
12+
13+
if [ -n "${DEBUG}" ] ; then
14+
LOG_LEVEL=${DEBUG}
15+
fi
16+
17+
LOG_LEVEL=${LOG_LEVEL:-"2"}
1218
LOG_PATH=${LOG_PATH:-"/var/log/tinc/"}
1319
MAC_LENGTH=${MAC_LENGTH:-16}
1420
WATCHDOG_FREQUENCY=${WATCHDOG_FREQUENCY:-60}

install/etc/cont-init.d/10-tinc

+34-39
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,8 @@ if [ "$SETUP_TYPE" = "AUTO" ]; then
1111
sanity_var PRIVATE_IP "Private IP"
1212
sanity_var PUBLIC_IP "Public IP"
1313

14-
if var_true "${DEBUG_MODE}" ; then
15-
DEBUG=9
16-
else
17-
DEBUG=${DEBUG:-0}
18-
fi
19-
2014
if var_true ${ENABLE_GIT} ; then
21-
### Adjust Runtime Variables for Crontab
22-
sed -i -e "s#<NETWORK>#${NETWORK}#g" /assets/cron/crontab.txt
23-
sed -i -e "s#<CRON_PERIOD>#${CRON_PERIOD}#g" /assets/cron/crontab.txt
24-
else
25-
rm -rf /assets/cron/crontab.txt
15+
echo "*/${CRON_PERIOD} * * * * git -C /etc/tinc/${NETWORK}/hosts/ pull >/dev/null 2>&1" > /assets/cron/crontab.txt
2616
fi
2717

2818
### check if network exists
@@ -34,7 +24,7 @@ if [ "$SETUP_TYPE" = "AUTO" ]; then
3424
sanity_var GIT_PASS "Git password"
3525
sanity_var GIT_URL "Git URL"
3626
print_debug "Cloning existing repository from Git"
37-
git clone https://"$GIT_USER":"$GIT_PASS"@"$GIT_URL" /etc/tinc/"${NETWORK}"/hosts
27+
git clone https://"${GIT_USER}":"${GIT_PASS}"@"${GIT_URL}" /etc/tinc/"${NETWORK}"/hosts
3828
else
3929
mkdir -p /etc/tinc/"${NETWORK}"/hosts
4030
fi
@@ -46,47 +36,52 @@ if [ "$SETUP_TYPE" = "AUTO" ]; then
4636
tinc -n "${NETWORK}" init "${NODE}"
4737

4838
# Declare public and private IPs in the host file, CONFIG/NET/hosts/HOST
49-
echo "Address = ${PUBLIC_IP} ${LISTEN_PORT}" >> /etc/tinc/"${NETWORK}"/hosts/"${NODE}"
50-
echo "Subnet = ${PRIVATE_IP}/32" >> /etc/tinc/"${NETWORK}"/hosts/"${NODE}"
51-
echo "Cipher = ${CIPHER}" >> /etc/tinc/"${NETWORK}"/hosts/"${NODE}"
52-
echo "Digest = ${DIGEST}" >> /etc/tinc/"${NETWORK}"/hosts/"${NODE}"
53-
echo "MACLength = ${MAC_LENGTH}" >> /etc/tinc/"${NETWORK}"/hosts/"${NODE}"
54-
echo "Compression = ${COMPRESSION}" >> /etc/tinc/"${NETWORK}"/hosts/"${NODE}"
39+
cat << EOF >> /etc/tinc/"${NETWORK}"/hosts/"${NODE}"
40+
Address = ${PUBLIC_IP} ${LISTEN_PORT}
41+
Subnet = ${PRIVATE_IP}/32
42+
Cipher = ${CIPHER}
43+
Digest = ${DIGEST}
44+
MACLength = ${MAC_LENGTH}
45+
Compression = ${COMPRESSION}
46+
EOF
5547

5648
if var_true "${ENABLE_GIT}" ; then
5749
cd /etc/tinc/"${NETWORK}"/hosts
58-
5950
silent git config --global user.email "${NODE}""@docker"
6051
silent git config --global user.name "${NODE}"
61-
6252
print_debug "Adding new node to Git"
6353
silent git add .
6454
print_debug "Comitting Changes to Git"
65-
silent git commit -m "${NODE} - Reinitialized $(date +%Y%m%d-%H%M%S)"
55+
silent git commit -m "${NODE} - Reinitialized $(TZ="${TIMEZONE}" date +"%Y%m%d-%H%M%S")"
6656
print_debug "Pushing to Git"
6757
silent git push
6858
fi
6959
fi
7060

7161
# Set Runtime Configuration for Tinc
72-
echo "Name = ${NODE}" > /etc/tinc/"${NETWORK}"/tinc.conf
73-
echo "BindToAddress * ${LISTEN_PORT}" >> /etc/tinc/"${NETWORK}"/tinc.conf
74-
echo "AddressFamily = ipv4" >> /etc/tinc/"${NETWORK}"/tinc.conf
75-
echo "Device = /dev/net/tun" >> /etc/tinc/"${NETWORK}"/tinc.conf
76-
echo "Interface = ${INTERFACE}" >> /etc/tinc/"${NETWORK}"/tinc.conf
77-
78-
peers=$(echo "${PEERS}" | tr " " "\n")
79-
for host in $peers
80-
do
81-
echo "ConnectTo = ""$host" >> /etc/tinc/"${NETWORK}"/tinc.conf
62+
cat << EOF > /etc/tinc/"${NETWORK}"/tinc.conf
63+
Name = ${NODE}
64+
BindToAddress * ${LISTEN_PORT}
65+
AddressFamily = ipv4
66+
Device = /dev/net/tun
67+
Interface = ${INTERFACE}
68+
EOF
69+
70+
tinc_peers=$(echo "${PEERS}" | tr " " "\n" | uniq)
71+
for host in $tinc_peers ; do
72+
echo "ConnectTo = ${host}" >> /etc/tinc/"${NETWORK}"/tinc.conf
8273
done
8374

84-
# Edit the tinc-up script
85-
echo "#!/bin/sh" >/etc/tinc/"${NETWORK}"/tinc-up
86-
echo "ifconfig ${INTERFACE} ${PRIVATE_IP} netmask 255.255.255.0" >> /etc/tinc/"${NETWORK}"/tinc-up
75+
# Create the tinc-up / down scripts
76+
cat <<EOF > /etc/tinc/"${NETWORK}"/tinc-up
77+
#!/bin/sh
78+
ifconfig ${INTERFACE} ${PRIVATE_IP} netmask 255.255.255.0
79+
EOF
8780

88-
echo "#!/bin/sh" > /etc/tinc/"${NETWORK}"/tinc-down
89-
echo "ifconfig ${INTERFACE} down" >> /etc/tinc/"${NETWORK}"/tinc-down
81+
cat <<EOF > /etc/tinc/"${NETWORK}"/tinc-down
82+
#!/bin/sh
83+
ifconfig ${INTERFACE} down
84+
EOF
9085

9186
### Grab latest hosts entries from Git
9287
if var_true "${ENABLE_GIT}" ; then
@@ -110,9 +105,9 @@ if [ "$SETUP_TYPE" = "AUTO" ]; then
110105
chmod +x /etc/tinc/${NETWORK}/tinc-up
111106
chmod +x /etc/tinc/${NETWORK}/tinc-down
112107

113-
mkdir -p ${LOG_PATH}
114-
touch ${LOG_PATH}/${NETWORK}.log
115-
create_logrotate tinc ${LOG_PATH}/${NETWORK}.log tinc
108+
mkdir -p "${LOG_PATH}"
109+
touch "${LOG_PATH}"/"${NETWORK}".log
110+
create_logrotate tinc "${LOG_PATH}"/"${NETWORK}".log tinc
116111
fi
117112

118113
liftoff

install/etc/services.available/10-tinc/run

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ liftoff
1010

1111
### Startup Tinc
1212
print_start "Starting Tinc ${TINC_VERSION} for Host '${NODE}' on VPN '${NETWORK}'"
13-
exec tinc --net=${NETWORK} start --no-detach --debug=${DEBUG} --logfile=${LOG_PATH}/${NETWORK}.log
13+
exec tinc --net="${NETWORK}" start --no-detach --debug="${LOG_LEVEL}" --logfile="${LOG_PATH}"/"${NETWORK}".log

install/etc/services.available/11-config-reload/run

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ check_service_initialized init 10-tinc
99

1010
liftoff
1111

12-
while silent inotifywait -q -e create,delete,modify,attrib /etc/tinc/ /etc/tinc/${NETWORK}/ /etc/tinc/${NETWORK}/hosts/ ; do
13-
print_info "[$(date +"%Y%m%d-%H%M%S")] Reloading Tinc due to a detected change"
14-
silent tinc -n ${NETWORK} reload
12+
while silent inotifywait -q -e create,delete,modify,attrib /etc/tinc/ /etc/tinc/"${NETWORK}"/ /etc/tinc/"${NETWORK}"/hosts/ ; do
13+
print_info "[$(TZ="${TIMEZONE}" date +"%Y%m%d-%H%M%S")] Reloading Tinc due to a detected change"
14+
silent tinc -n "${NETWORK}" reload
1515
exit 0
1616
done

install/etc/services.available/12-watchdog/run

+12-13
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@ liftoff
1010
sleep 120
1111

1212
while true ; do
13-
sleep ${WATCHDOG_FREQUENCY}
14-
print_debug "[$(date +"%Y%m%d-%H%M%S")] Checking for ping response for ${WATCHDOG_HOST}"
15-
ping -c1 -t255 ${WATCHDOG_HOST} 2>/dev/null 1>/dev/null
16-
if [ "$?" != "0" ]; then
17-
print_debug "[$(date +"%Y%m%d-%H%M%S")] Watchdog Try #2"
13+
sleep "${WATCHDOG_FREQUENCY}"
14+
print_debug "[$(date +"%Y%m%d-%H%M%S")] Checking for ping response for ${WATCHDOG_HOST}"
1815
ping -c1 -t255 ${WATCHDOG_HOST} 2>/dev/null 1>/dev/null
1916
if [ "$?" != "0" ]; then
20-
print_debug "[$(date +"%Y%m%d-%H%M%S")] Watchdog Try #3"
21-
ping -c1 -t255 ${WATCHDOG_HOST} 2>/dev/null 1>/dev/null
22-
if [ "$?" != "0" ]; then
23-
print_info "[$(date +"%Y%m%d-%H%M%S")] Could not reach watchdog host ${WATCHDOG_HOST} - Restarting Tinc"
24-
silent tinc -n ${NETWORK} stop
25-
fi
17+
print_debug "[$(date +"%Y%m%d-%H%M%S")] Watchdog Try #2"
18+
ping -c1 -t255 ${WATCHDOG_HOST} 2>/dev/null 1>/dev/null
19+
if [ "$?" != "0" ]; then
20+
print_debug "[$(date +"%Y%m%d-%H%M%S")] Watchdog Try #3"
21+
ping -c1 -t255 ${WATCHDOG_HOST} 2>/dev/null 1>/dev/null
22+
if [ "$?" != "0" ]; then
23+
print_info "[$(date +"%Y%m%d-%H%M%S")] Could not reach watchdog host ${WATCHDOG_HOST} - Restarting Tinc"
24+
silent tinc -n "${NETWORK}" stop
25+
fi
26+
fi
2627
fi
27-
fi
28-
2928
done

0 commit comments

Comments
 (0)