1
0
mirror of https://git.openwrt.org/feed/packages.git synced 2024-06-16 12:23:59 +02:00
openwrt-packages/net/jool/files/jool.init
Tiago Gaspar 98ac608fb8 jool: update to 4.1.6, add init files and default configuration
This commit adds support for starting and running jool through init
scripts, with default config files as examples.

Signed-off-by: Tiago Gaspar <tiagogaspar8@gmail.com>
2022-01-12 04:00:30 -08:00

58 lines
1.1 KiB
Bash

#!/bin/sh /etc/rc.common
START=54
STOP=54
PROG_NAT64="/usr/bin/jool"
PROG_SIIT="/usr/bin/jool_siit"
CONFIGFILE_NAT64="/etc/jool/jool-nat64.conf.json"
CONFIGFILE_SIIT="/etc/jool/jool-siit.conf.json"
config_parser(){
enabled=0
enabled_nat64=0
enabled_siit=0
config_load "jool"
#verify if the services are enabled in the configuration and populate it's variables
config_get_bool enabled general enabled 0
config_get_bool enabled_nat64 nat64 enabled 0
config_get_bool enabled_siit siit enabled 0
#If the main service is not enabled exit
[ "$enabled" -eq 0 ] && return 1
#if nat64 is enabled continue
if [ "$enabled_nat64" -gt 0 ]; then
#check if the orer is to start or stop
if [ "$1" -gt 0 ]; then
#start jool
$PROG_NAT64 file handle $CONFIGFILE_NAT64
else
$PROG_NAT64 -f $CONFIGFILE_NAT64 instance remove
fi
fi
#if siit is enabled continue
if [ "$enabled_siit" -gt 0 ]; then
#check if the orer is to start or stop
if [ "$1" -gt 0 ]; then
#start jool
$PROG_SIIT file handle $CONFIGFILE_SIIT
else
$PROG_SIIT -f $CONFIGFILE_SIIT instance remove
fi
fi
}
start() {
config_parser 1
}
stop() {
config_parser 0
}