Skip to content

Instantly share code, notes, and snippets.

@nna774

nna774/encap.sh Secret

Last active October 7, 2023 10:25
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 nna774/7ec7481a0f8ef8dc96a8627964507ab1 to your computer and use it in GitHub Desktop.
Save nna774/7ec7481a0f8ef8dc96a8627964507ab1 to your computer and use it in GitHub Desktop.
#!/bin/bash
temp="node.def"
interface_templates_dir=/opt/vyatta/share/vyatta-cfg/templates/interfaces
ip4ip6_dir=`find ${interface_templates_dir} -type d -name node\.tag | egrep '\/ipv6-tunnel\/node\.tag$'`
ip4ip6_encaplimit_dir="${ip4ip6_dir}/encaplimit"
ip4ip4_dir=`find ${interface_templates_dir} -type d -name node\.tag | egrep '\/tunnel\/node\.tag$'`
ip4ip4_encaplimit_dir="${ip4ip4_dir}/encaplimit"
if [ ! -e ${ip4ip6_encaplimit_dir} ]; then
echo "Creating ${ip4ip6_encaplimit_dir}"
sudo mkdir ${ip4ip6_encaplimit_dir}
fi
cat << 'EOF' > ${temp}
type: txt
help: Encaplimit field
val_help: txt; Encaplimit (default 4)
val_help: <0-255>; Sets a fixed encapsulation limit. Default is 4.
val_help: none; Sets no encapsulation limit.
syntax:expression: ($VAR(@) == "none" || (pattern $VAR(@) "[0-9]*")) ; "Must be 'none' or a number between 0-255"
update: sudo ip -6 tunnel change $VAR(../@) encaplimit $VAR(@);
delete: sudo ip -6 tunnel change $VAR(../@) encaplimit 4
EOF
sudo mv ${temp} ${ip4ip6_encaplimit_dir}
if [ ! -e ${ip4ip4_encaplimit_dir} ]; then
echo "Creating ${ip4ip4_encaplimit_dir}"
sudo mkdir ${ip4ip4_encaplimit_dir}
fi
cat << 'EOF' > ${temp}
type: txt
help: Encaplimit field
val_help: txt; Encaplimit (default 4)
val_help: <0-255>; Sets a fixed encapsulation limit. Default is 4.
val_help: none; Sets no encapsulation limit.
syntax:expression: ($VAR(@) == "none" || (pattern $VAR(@) "[0-9]*")) ; "Must be 'none' or a number between 0-255"
update: sudo ip tunnel change $VAR(../@) encaplimit $VAR(@);
delete: sudo ip tunnel change $VAR(../@) encaplimit 4
EOF
sudo mv ${temp} ${ip4ip4_encaplimit_dir}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment