Skip to content

Commit

Permalink
Release 7.10.0 - See CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tiredofit committed Jul 5, 2024
1 parent 9117e6a commit 8a81dcb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 7.10.0 2024-07-05 <dave at tiredofit dot ca>

### Added
- Add host_override function


## 7.9.1 2024-06-26 <dave at tiredofit dot ca>

### Changed
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Dockerfile to build an [alpine](https://www.alpinelinux.org/) linux container im
- [Log Shipping Parsing](#log-shipping-parsing)
- [Fluent-Bit Options](#fluent-bit-options)
- [Firewall Options|](#firewall-options)
- [Host Override Options](#host-override-options)
- [IPTables Options](#iptables-options)
- [Fail2Ban Options](#fail2ban-options)
- [Permissions](#permissions)
Expand Down Expand Up @@ -372,6 +373,19 @@ FIREWALL_RULE_00=-I INPUT -p tcp -m tcp -s 101.69.69.101 --dport 389 -j ACCEPT
FIREWALL_RULE_01=-I INPUT -p tcp -m tcp -s 0.0.0.0/0 --dport 389 -j DROP
````

##### Host Override Options

Sometimes you may need to do some host file trickery. This will add an entry to the contains hosts file.

Instead of relying on environment variables one can put a `iptables-restore` compatible ruleset below and it will be imported on container start.

| Parameter | Description | Default |
| ---------------------------- | ------------------------- | ------- |
| `CONTAINER_HOST_OVERRIDE_01` | Create manual hosts entry | |

Make the value `<destination> override1 override2` eg `1.2.3.4 example.org example.com`. If you omit an IP Address and instead use a domain name it will attempt to look it up to an IP eg `proxy example.com example.org`


##### IPTables Options

Instead of relying on environment variables one can put a `iptables-restore` compatible ruleset below and it will be imported on container start.
Expand Down
19 changes: 19 additions & 0 deletions install/assets/functions/00-container
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,25 @@ grant_sudo() {
output_on
}

host_override() {
## Adds entry to /etc/hosts file
## Usage CONTAINER_HOST_OVERRIDE01=destination_ip domain1 domain2 domain3
## If you use a host name instead of destination_ip it will attempt to resolve it
_hostnum=$(printenv | sort | grep -cE '^CONTAINER_HOST_OVERRIDE_([0-9].)')
for (( _host = 01; _host <= _hostnum; _host++ )) ; do
_host=$(printf "%02d" $_host)
host_line=CONTAINER_HOST_OVERRIDE_${_host}
host_ip=$(echo ${!host_line} | awk '{print $1}')

if [[ ! "${host_ip}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
host_ip="$(getent ahostsv4 "${host_ip}" | grep -m 1 STREAM | awk '{print $1}')"
fi

echo "# Added automatically by CONTAINER_HOST_OVERRIDE_${_host}" >> /etc/hosts
echo "${host_ip} $(echo ${!host_line} | cut -d' ' -f2-)" >> /etc/hosts
done
}

install_template() {
## Copies configuration template to the destination as the specified USER
## Usage install_template <copy-as-user> <source_file> <desintation_location+file> <optional chmod mode>
Expand Down
1 change: 1 addition & 0 deletions install/etc/cont-init.d/00-startup
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,6 @@ zcat () {
}
EOF

host_override
liftoff
output_on

0 comments on commit 8a81dcb

Please sign in to comment.