Skip to content

Instantly share code, notes, and snippets.

@konosukef
Last active May 29, 2021 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konosukef/d0a3b8fa73458defd4f61c95649dd029 to your computer and use it in GitHub Desktop.
Save konosukef/d0a3b8fa73458defd4f61c95649dd029 to your computer and use it in GitHub Desktop.
#!/bin/sh /etc/rc.common
# Jool NAT64 service for OpenWrt
START=15
MODULE_NAME=jool
JOOL_BIN=/usr/bin/$MODULE_NAME
CONFIG_FILE=/etc/jool/$MODULE_NAME.conf
check_workspace() {
[ -f "$JOOL_BIN" ] || exit
[ -f "$CONFIG_FILE" ] || exit
}
compute_status() {
STATUS=$($JOOL_BIN -f "$CONFIG_FILE" instance status 2>/dev/null | head -1)
[ "$STATUS" = Running -o "$STATUS" = Dead ] || exit
}
add_module() {
/sbin/modprobe $MODULE_NAME || exit
}
add_instance() {
$JOOL_BIN file handle "$CONFIG_FILE" || exit
}
remove_instance() {
$JOOL_BIN -f "$CONFIG_FILE" instance remove || exit
}
start() {
check_workspace
compute_status
[ "$STATUS" = Running ] && return
add_module
add_instance
}
stop() {
check_workspace
compute_status
[ "$STATUS" = Dead ] && return
remove_instance
}
reload() {
check_workspace
add_module
add_instance
}
{
"comment": "Configuration for the NAT64 Jool service.",
"instance": "example",
"framework": "iptables",
"global": {
"pool6": "64:ff9b::/96"
}
}
/etc/init.d/jool
/etc/jool/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment