Skip to content

Commit d79d871

Browse files
committed
Added finish hook & sorting names
Added finish hook to container system, which executes before container shutdown, sorted hook names, updated run_hooks help
1 parent df6b4cc commit d79d871

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,17 @@ Sections:
5151
hook # Example hook configs
5252
module # Modules for openvpn
5353
hooks # Put your custom scripts in one of subfolders
54+
auth # On authentication (needs to be enabled in config)
55+
client-connect # Client connected
56+
client-disconnect # Client disconnected
57+
down # After interface is down
58+
finish # Deinit container
5459
init # Init container
60+
learn-address
5561
route-up # After routes are added
5662
route-pre-down # Before routes are removed
5763
up # After interface is up
58-
down # After interface is down
59-
client-connect # Client connected
60-
client-disconnect # Client disconnected
61-
learn-address
6264
tls-verify # Check certificate
63-
auth # On authentication (needs to be enabled in config)
6465
system.conf # System OpenVPN config file (do not edit, unless instructed)
6566
include-server.conf # File that includes all server configuration files (automatically generated)
6667
donotdelete # Leave this file alone, if deleted it triggers full setup

root/app/bin/run_hooks

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@ function usage() {
1010
echo "Usage: run_hooks HOOK_NAME [ARGS]"
1111
echo ""
1212
echo "Hooks:"
13-
echo " up saasas"
14-
echo " down-pre asasss"
15-
echo " down-post asasda"
16-
echo " auth asdasd"
13+
echo " auth On OpenVPN client authentication"
14+
echo " client-connect On OpenVPN client connected"
15+
echo " client-disconnect On OpenVPN client disconnected"
16+
echo " finish On container shutdown"
17+
echo " init On container power on"
18+
echo " learn-address Client Address & Routes validation"
19+
echo " down Before/After TUN interface closed"
20+
echo " route-up After routes are added"
21+
echo " route-pre-down Before routes are removed"
22+
echo " tls-verify On OpenVPN client certificate verificaton"
23+
echo " up After TUN interface opened"
1724
}
1825

1926
# Check if hook name is set

root/defaults/system.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ script-security 2
2020
route-up "/app/bin/run_hooks route-up"
2121
route-pre-down "/app/bin/run_hooks route-pre-down"
2222
up "/app/bin/run_hooks up"
23+
down-pre
2324
down "/app/bin/run_hooks down"
2425
client-connect "/app/bin/run_hooks client-connect"
2526
client-disconnect "/app/bin/run_hooks client-disconnect"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
#
4+
# Runs custom finish scripts in /config/hooks/finish
5+
#
6+
7+
run_hooks finish
8+
9+
exit $?

root/etc/cont-init.d/50-config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# File which indicates that full init was already done before
44
FLAG_FILE=/config/donotdelete
55

6-
HOOKS_DIR=(init route-up route-pre-down up down client-connect client-disconnect learn-address tls-verify auth)
6+
HOOKS_DIR=(auth client-connect client-disconnect finish down init learn-address route-pre-down route-up up tls-verify)
77
OVPN_DIR=(ccd client server)
88

99
FIRST_SETUP=0

0 commit comments

Comments
 (0)