treewide: fix indentation in .sh files
to match the editorconfig awk code in contrib/sign.sh and contrib/sigtest.sh reformatted as gawk does
This commit is contained in:
parent
2b4d3c1b73
commit
2aa3527fdc
@ -37,6 +37,8 @@ indent_size = 4
|
|||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.sh]
|
||||||
|
|
||||||
[*.yml]
|
[*.yml]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
# Then you enter the command mode of qemu and can exit by typing "quit".
|
# Then you enter the command mode of qemu and can exit by typing "quit".
|
||||||
|
|
||||||
qemu-system-x86_64 \
|
qemu-system-x86_64 \
|
||||||
-d 'cpu_reset' \
|
-d 'cpu_reset' \
|
||||||
-enable-kvm \
|
-enable-kvm \
|
||||||
-gdb tcp::1234 \
|
-gdb tcp::1234 \
|
||||||
-nographic \
|
-nographic \
|
||||||
-netdev user,id=wan,hostfwd=tcp::2223-10.0.2.15:22 \
|
-netdev user,id=wan,hostfwd=tcp::2223-10.0.2.15:22 \
|
||||||
-device virtio-net-pci,netdev=wan,addr=0x06,id=nic1 \
|
-device virtio-net-pci,netdev=wan,addr=0x06,id=nic1 \
|
||||||
-netdev user,id=lan,hostfwd=tcp::6080-192.168.1.1:80,hostfwd=tcp::2222-192.168.1.1:22,net=192.168.1.100/24 \
|
-netdev user,id=lan,hostfwd=tcp::6080-192.168.1.1:80,hostfwd=tcp::2222-192.168.1.1:22,net=192.168.1.100/24 \
|
||||||
-device virtio-net-pci,netdev=lan,addr=0x05,id=nic2 \
|
-device virtio-net-pci,netdev=lan,addr=0x05,id=nic2 \
|
||||||
"$@"
|
"$@"
|
||||||
|
@ -29,11 +29,22 @@ lower="$(mktemp)"
|
|||||||
|
|
||||||
trap 'rm -f "$upper" "$lower"' EXIT
|
trap 'rm -f "$upper" "$lower"' EXIT
|
||||||
|
|
||||||
awk 'BEGIN { sep=0 }
|
awk 'BEGIN {
|
||||||
/^---$/ { sep=1; next }
|
sep = 0
|
||||||
{ if(sep==0) print > "'"$upper"'";
|
}
|
||||||
else print > "'"$lower"'"}' \
|
|
||||||
"$manifest"
|
/^---$/ {
|
||||||
|
sep = 1;
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
if(sep == 0) {
|
||||||
|
print > "'"$upper"'"
|
||||||
|
} else {
|
||||||
|
print > "'"$lower"'"
|
||||||
|
}
|
||||||
|
}' "$manifest"
|
||||||
|
|
||||||
ecdsasign "$upper" < "$SECRET" >> "$lower"
|
ecdsasign "$upper" < "$SECRET" >> "$lower"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ $# -eq 0 ] || [ "-h" = "$1" ] || [ "-help" = "$1" ] || [ "--help" = "$1" ]; then
|
if [ $# -eq 0 ] || [ "-h" = "$1" ] || [ "-help" = "$1" ] || [ "--help" = "$1" ]; then
|
||||||
cat <<EOHELP
|
cat <<EOHELP
|
||||||
Usage: $0 <public> <signed manifest>
|
Usage: $0 <public> <signed manifest>
|
||||||
|
|
||||||
sigtest.sh checks if a manifest is signed by the public key <public>. There is
|
sigtest.sh checks if a manifest is signed by the public key <public>. There is
|
||||||
@ -12,7 +12,7 @@ See also:
|
|||||||
* https://gluon.readthedocs.io/en/latest/features/autoupdater.html
|
* https://gluon.readthedocs.io/en/latest/features/autoupdater.html
|
||||||
|
|
||||||
EOHELP
|
EOHELP
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
public="$1"
|
public="$1"
|
||||||
@ -21,18 +21,29 @@ upper="$(mktemp)"
|
|||||||
lower="$(mktemp)"
|
lower="$(mktemp)"
|
||||||
ret=1
|
ret=1
|
||||||
|
|
||||||
awk "BEGIN { sep=0 }
|
awk 'BEGIN {
|
||||||
/^---\$/ { sep=1; next }
|
sep = 0
|
||||||
{ if(sep==0) print > \"$upper\";
|
}
|
||||||
else print > \"$lower\"}" \
|
|
||||||
"$manifest"
|
/^---$/ {
|
||||||
|
sep = 1;
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
if(sep == 0) {
|
||||||
|
print > "'"$upper"'"
|
||||||
|
} else {
|
||||||
|
print > "'"$lower"'"
|
||||||
|
}
|
||||||
|
}' "$manifest"
|
||||||
|
|
||||||
while read -r line
|
while read -r line
|
||||||
do
|
do
|
||||||
if ecdsaverify -s "$line" -p "$public" "$upper"; then
|
if ecdsaverify -s "$line" -p "$public" "$upper"; then
|
||||||
ret=0
|
ret=0
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done < "$lower"
|
done < "$lower"
|
||||||
|
|
||||||
rm -f "$upper" "$lower"
|
rm -f "$upper" "$lower"
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
if [ -x /etc/init.d/"$1" ]; then
|
if [ -x /etc/init.d/"$1" ]; then
|
||||||
echo "Stopping $1..."
|
echo "Stopping $1..."
|
||||||
/etc/init.d/"$1" stop
|
/etc/init.d/"$1" stop
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
start_enabled() {
|
start_enabled() {
|
||||||
if [ -x /etc/init.d/"$1" ] && /etc/init.d/"$1" enabled; then
|
if [ -x /etc/init.d/"$1" ] && /etc/init.d/"$1" enabled; then
|
||||||
echo "Starting $1..."
|
echo "Starting $1..."
|
||||||
/etc/init.d/"$1" start
|
/etc/init.d/"$1" start
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -5,90 +5,90 @@
|
|||||||
init_proto "$@"
|
init_proto "$@"
|
||||||
|
|
||||||
proto_gluon_wired_init_config() {
|
proto_gluon_wired_init_config() {
|
||||||
proto_config_add_boolean transitive
|
proto_config_add_boolean transitive
|
||||||
proto_config_add_int index
|
proto_config_add_int index
|
||||||
proto_config_add_boolean vxlan
|
proto_config_add_boolean vxlan
|
||||||
proto_config_add_string vxpeer6addr
|
proto_config_add_string vxpeer6addr
|
||||||
}
|
}
|
||||||
|
|
||||||
xor2() {
|
xor2() {
|
||||||
echo -n "${1:0:1}"
|
echo -n "${1:0:1}"
|
||||||
echo -n "${1:1:1}" | tr '0123456789abcdef' '23016745ab89efcd'
|
echo -n "${1:1:1}" | tr '0123456789abcdef' '23016745ab89efcd'
|
||||||
}
|
}
|
||||||
|
|
||||||
is_layer3_device () {
|
is_layer3_device () {
|
||||||
local addrlen="$(cat "/sys/class/net/$1/addr_len")"
|
local addrlen="$(cat "/sys/class/net/$1/addr_len")"
|
||||||
test "$addrlen" -eq 0
|
test "$addrlen" -eq 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
interface_linklocal() {
|
interface_linklocal() {
|
||||||
if is_layer3_device "$1"; then
|
if is_layer3_device "$1"; then
|
||||||
if ! ubus call network.interface dump | \
|
if ! ubus call network.interface dump | \
|
||||||
jsonfilter -e "@.interface[@.l3_device='$1']['ipv6-address'][*].address" | \
|
jsonfilter -e "@.interface[@.l3_device='$1']['ipv6-address'][*].address" | \
|
||||||
grep -e '^fe[89ab][0-9a-f]' -m 1; then
|
grep -e '^fe[89ab][0-9a-f]' -m 1; then
|
||||||
proto_notify_error "$config" "MISSING_LL_ADDR_ON_LOWER_IFACE"
|
proto_notify_error "$config" "MISSING_LL_ADDR_ON_LOWER_IFACE"
|
||||||
proto_block_restart "$config"
|
proto_block_restart "$config"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local macaddr="$(ubus call network.device status '{"name": "'"$1"'"}' | jsonfilter -e '@.macaddr')"
|
local macaddr="$(ubus call network.device status '{"name": "'"$1"'"}' | jsonfilter -e '@.macaddr')"
|
||||||
local oldIFS="$IFS"; IFS=':'; set -- $macaddr; IFS="$oldIFS"
|
local oldIFS="$IFS"; IFS=':'; set -- $macaddr; IFS="$oldIFS"
|
||||||
|
|
||||||
echo "fe80::$(xor2 "$1")$2:$3ff:fe$4:$5$6"
|
echo "fe80::$(xor2 "$1")$2:$3ff:fe$4:$5$6"
|
||||||
}
|
}
|
||||||
|
|
||||||
proto_gluon_wired_setup() {
|
proto_gluon_wired_setup() {
|
||||||
local config="$1"
|
local config="$1"
|
||||||
local ifname="$2"
|
local ifname="$2"
|
||||||
|
|
||||||
local meshif="$config"
|
local meshif="$config"
|
||||||
|
|
||||||
local transitive index vxlan vxpeer6addr
|
local transitive index vxlan vxpeer6addr
|
||||||
json_get_vars transitive index vxlan vxpeer6addr
|
json_get_vars transitive index vxlan vxpeer6addr
|
||||||
|
|
||||||
# default args
|
# default args
|
||||||
[ -z "$vxlan" ] && vxlan=1
|
[ -z "$vxlan" ] && vxlan=1
|
||||||
[ -z "$vxpeer6addr" ] && vxpeer6addr='ff02::15c'
|
[ -z "$vxpeer6addr" ] && vxpeer6addr='ff02::15c'
|
||||||
|
|
||||||
proto_init_update "$ifname" 1
|
proto_init_update "$ifname" 1
|
||||||
proto_send_update "$config"
|
proto_send_update "$config"
|
||||||
|
|
||||||
if [ "$vxlan" -eq 1 ]; then
|
if [ "$vxlan" -eq 1 ]; then
|
||||||
meshif="vx_$config"
|
meshif="vx_$config"
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_string name "$meshif"
|
json_add_string name "$meshif"
|
||||||
[ -n "$index" ] && json_add_string macaddr "$(lua -e "print(require('gluon.util').generate_mac($index))")"
|
[ -n "$index" ] && json_add_string macaddr "$(lua -e "print(require('gluon.util').generate_mac($index))")"
|
||||||
json_add_string proto 'vxlan6'
|
json_add_string proto 'vxlan6'
|
||||||
json_add_string tunlink "$config"
|
json_add_string tunlink "$config"
|
||||||
# ip6addr (the lower interface ip6) is used by the vxlan.sh proto
|
# ip6addr (the lower interface ip6) is used by the vxlan.sh proto
|
||||||
json_add_string ip6addr "$(interface_linklocal "$ifname")"
|
json_add_string ip6addr "$(interface_linklocal "$ifname")"
|
||||||
json_add_string peer6addr "$vxpeer6addr"
|
json_add_string peer6addr "$vxpeer6addr"
|
||||||
json_add_int vid "$(lua -e 'print(tonumber(require("gluon.util").domain_seed_bytes("gluon-mesh-vxlan", 3), 16))')"
|
json_add_int vid "$(lua -e 'print(tonumber(require("gluon.util").domain_seed_bytes("gluon-mesh-vxlan", 3), 16))')"
|
||||||
json_add_boolean rxcsum '0'
|
json_add_boolean rxcsum '0'
|
||||||
json_add_boolean txcsum '0'
|
json_add_boolean txcsum '0'
|
||||||
json_close_object
|
json_close_object
|
||||||
ubus call network add_dynamic "$(json_dump)"
|
ubus call network add_dynamic "$(json_dump)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_string name "${config}_mesh"
|
json_add_string name "${config}_mesh"
|
||||||
json_add_string ifname "@${meshif}"
|
json_add_string ifname "@${meshif}"
|
||||||
json_add_string proto 'gluon_mesh'
|
json_add_string proto 'gluon_mesh'
|
||||||
json_add_boolean fixed_mtu 1
|
json_add_boolean fixed_mtu 1
|
||||||
[ -n "$transitive" ] && json_add_boolean transitive "$transitive"
|
[ -n "$transitive" ] && json_add_boolean transitive "$transitive"
|
||||||
json_close_object
|
json_close_object
|
||||||
ubus call network add_dynamic "$(json_dump)"
|
ubus call network add_dynamic "$(json_dump)"
|
||||||
}
|
}
|
||||||
|
|
||||||
proto_gluon_wired_teardown() {
|
proto_gluon_wired_teardown() {
|
||||||
local config="$1"
|
local config="$1"
|
||||||
|
|
||||||
proto_init_update "*" 0
|
proto_init_update "*" 0
|
||||||
proto_send_update "$config"
|
proto_send_update "$config"
|
||||||
}
|
}
|
||||||
|
|
||||||
add_protocol gluon_wired
|
add_protocol gluon_wired
|
||||||
|
Loading…
Reference in New Issue
Block a user