diff options
Diffstat (limited to 'contrib/scripts')
-rw-r--r-- | contrib/scripts/Makefile.am | 14 | ||||
-rw-r--r-- | contrib/scripts/changelog_delta.sh | 3 | ||||
-rwxr-xr-x | contrib/scripts/doc/warningfilter.py | 134 | ||||
-rwxr-xr-x | contrib/scripts/generate-release-triplet.sh | 21 | ||||
-rw-r--r-- | contrib/scripts/gnunet-logread/Makefile.am | 4 | ||||
-rw-r--r-- | contrib/scripts/meson.build | 4 | ||||
-rwxr-xr-x | contrib/scripts/netjail/netjail_core.sh | 217 | ||||
-rwxr-xr-x | contrib/scripts/netjail/netjail_setup_internet.sh | 166 | ||||
-rwxr-xr-x | contrib/scripts/news_delta.sh | 6 | ||||
-rwxr-xr-x | contrib/scripts/testbed_cleanup.sh | 14 | ||||
-rwxr-xr-x | contrib/scripts/update_news.sh | 15 |
11 files changed, 189 insertions, 409 deletions
diff --git a/contrib/scripts/Makefile.am b/contrib/scripts/Makefile.am index 2d4f5584b..204167e82 100644 --- a/contrib/scripts/Makefile.am +++ b/contrib/scripts/Makefile.am | |||
@@ -1,5 +1,6 @@ | |||
1 | # This Makefile.am is in the public domain | 1 | # This Makefile.am is in the public domain |
2 | AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_builddir)/src/include | 2 | AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_builddir)/src/include |
3 | libexecdir= $(pkglibdir)/libexec/ | ||
3 | 4 | ||
4 | SUBDIRS = gnunet-logread | 5 | SUBDIRS = gnunet-logread |
5 | 6 | ||
@@ -21,7 +22,10 @@ noinst_SCRIPTS = \ | |||
21 | $(awkSCRIPTS) | 22 | $(awkSCRIPTS) |
22 | 23 | ||
23 | bin_SCRIPTS = \ | 24 | bin_SCRIPTS = \ |
24 | gnunet-bugreport \ | 25 | gnunet-bugreport |
26 | |||
27 | # This script is not documented and its usage is quite uncommon. | ||
28 | libexec_SCRIPTS = \ | ||
25 | gnunet-suidfix | 29 | gnunet-suidfix |
26 | 30 | ||
27 | EXTRA_DIST = \ | 31 | EXTRA_DIST = \ |
@@ -39,15 +43,11 @@ EXTRA_DIST = \ | |||
39 | find_typedefs.py \ | 43 | find_typedefs.py \ |
40 | pydmesg \ | 44 | pydmesg \ |
41 | visualize_stats.sh \ | 45 | visualize_stats.sh \ |
42 | changelog_delta.sh \ | ||
43 | debug \ | 46 | debug \ |
44 | build_cscope.sh \ | 47 | build_cscope.sh \ |
45 | testbed_cleanup.sh \ | ||
46 | lint/lint-man.sh \ | 48 | lint/lint-man.sh \ |
47 | lint/lint-python.sh \ | 49 | lint/lint-python.sh \ |
48 | revisionary.sh \ | 50 | revisionary.sh \ |
49 | netjail/netjail_core.sh \ | ||
50 | netjail/netjail_setup_internet.sh \ | ||
51 | regression.sh \ | 51 | regression.sh \ |
52 | doc/texinfo-hacks.el \ | 52 | doc/texinfo-hacks.el \ |
53 | afferify \ | 53 | afferify \ |
@@ -72,11 +72,11 @@ CLEANFILES = \ | |||
72 | SUFFIXES = .py.in .py | 72 | SUFFIXES = .py.in .py |
73 | 73 | ||
74 | .py.in.py: | 74 | .py.in.py: |
75 | $(AWK) -v py="$(PYTHON)" -f $(top_srcdir)/bin/dosubst.awk < $< > $@ | 75 | $(AWK) -v py="$(PYTHON)" -f $(top_srcdir)/scripts/dosubst.awk < $< > $@ |
76 | chmod +x $@ | 76 | chmod +x $@ |
77 | 77 | ||
78 | if HAVE_AWK | 78 | if HAVE_AWK |
79 | check-texinfo.awk: check-texinfo.awk.in Makefile | 79 | check-texinfo.awk: check-texinfo.awk.in Makefile |
80 | $(AWK) -v awkay="$(AWK_BINARY)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/check-texinfo.awk.in > check-texinfo.awk | 80 | $(AWK) -v awkay="$(AWK_BINARY)" -f $(top_srcdir)/scripts/dosubst.awk < $(srcdir)/check-texinfo.awk.in > check-texinfo.awk |
81 | chmod +x check-texinfo.awk | 81 | chmod +x check-texinfo.awk |
82 | endif | 82 | endif |
diff --git a/contrib/scripts/changelog_delta.sh b/contrib/scripts/changelog_delta.sh deleted file mode 100644 index f115f1ef1..000000000 --- a/contrib/scripts/changelog_delta.sh +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | LASTHASH=$(head -n1 ChangeLog | cut -d " " -f 7 | tr -d \( | tr -d \)) | ||
3 | git log --invert-grep --grep="^-" --no-merges --no-color --format="%aD (%h)%n%s - %cN%n" $LASTHASH..HEAD | ||
diff --git a/contrib/scripts/doc/warningfilter.py b/contrib/scripts/doc/warningfilter.py new file mode 100755 index 000000000..31ac5865c --- /dev/null +++ b/contrib/scripts/doc/warningfilter.py | |||
@@ -0,0 +1,134 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | """ | ||
3 | Filters and processes warnings generated by Doxygen, which are | ||
4 | annoyingly inconsistent and verbose, for greater readability. | ||
5 | |||
6 | (Neo)vim commands to go to the file and linenumber listed on a | ||
7 | line, in the reports this program generates: | ||
8 | :exe "let linenumber =" split(getline("."))[1] | ||
9 | :exe "edit" fnameescape(split(getline("."))[0]) "|" linenumber | ||
10 | |||
11 | It's easy to put a workflow together to clear up redundant doc | ||
12 | comments (which generate "multiple @param docs" warnings), using | ||
13 | simple vim commands to move the cursor and close buffers, Neovim's | ||
14 | support for the Language Server Protocol or related tooling, and | ||
15 | the command shown above. | ||
16 | |||
17 | A useful sequence, for rapidly deleting a doc comment from its last | ||
18 | line, is, in normal mode, `$v%ddd`. | ||
19 | |||
20 | For setting up LSP integration in Neovim, refer to the lsp_config | ||
21 | plugin. | ||
22 | |||
23 | You may additionally need to generate compile_commands.json in the | ||
24 | repository root, to allow the language server to find everything. | ||
25 | This can be done using Bear (found at https://github.com/rizsotto/Bear). | ||
26 | |||
27 | @author: willow <willow@howhill.com> | ||
28 | """ | ||
29 | |||
30 | import argparse as ap | ||
31 | import re | ||
32 | |||
33 | # Regular expression construction | ||
34 | |||
35 | def sep_re(field, separator): | ||
36 | "Constructs regex for a list" | ||
37 | return rf"{field}(?:{separator}{field})*" | ||
38 | |||
39 | # File names and paths | ||
40 | fileclass = r"[\w-]" | ||
41 | filename = rf"{fileclass}+" | ||
42 | # filename = rf"(/{fileclass}+)+\.\w" | ||
43 | filepath = rf"{sep_re(filename, '/')}\.(?:\w+)" | ||
44 | main_match = rf"(?P<path>/{filepath}|\[generated\]):(?P<linenumber>\d+): warning:" | ||
45 | |||
46 | # Symbols | ||
47 | type_name = rf"(?:const )?(?:unsigned (?:long )?|struct |enum )?(?:\w+)(?: \*?const)? \*{{0,3}}" | ||
48 | var_def = rf"{type_name}\w+(?:\[(?:\(\d+/\d+\))?\])?" | ||
49 | func_params = rf"\({sep_re(var_def, ', ')}(?:,\.\.\.)?\)" | ||
50 | simple_name = r"\w+" | ||
51 | func_name = simple_name | ||
52 | verbose_name = rf"{sep_re(simple_name, ' ')}" | ||
53 | command_re = "(?:</[^>]+>|\\\w+)" | ||
54 | macro_params = rf"\({sep_re(simple_name, ', ')}(?:,\.\.\.)?\)" | ||
55 | |||
56 | |||
57 | matches = { | ||
58 | "not an input @file": re.compile(rf"{main_match} the name '(?P<name>{filepath}|{simple_name})' supplied as the argument in the \\file statement is not an input file"), | ||
59 | "multiple @param docs": re.compile(rf"{main_match} argument '(?P<arg_name>\w+)' from the argument list of ({func_name}) has multiple @param documentation sections"), | ||
60 | "undocumented param": re.compile(rf"{main_match} The following parameters? of ({func_name})(?:{func_params}|{macro_params}) (?:is|are) not documented:"), | ||
61 | "undocumented param (name)": re.compile(r" parameter '([\w.]+)'"), | ||
62 | "explicit link not resolved": re.compile(rf"{main_match} explicit link request to '(\w+(?:\(\))?)' could not be resolved"), | ||
63 | "unknown command": re.compile(rf"{main_match} Found unknown command '(\\\w+)'"), | ||
64 | "missing argument": re.compile(rf"{main_match} argument '(\w+)' of command @param is not found in the argument list of ({func_name})(?:{func_params}|{macro_params})"), | ||
65 | "eof inside group": re.compile(rf"{main_match} end of file while inside a group"), | ||
66 | "eof inside comment": re.compile(rf"{main_match} Reached end of file while still inside a \(nested\) comment. Nesting level \d+ \(probable line reference: (\d+)\)"), | ||
67 | "eof inside code block": re.compile(rf"{main_match} reached end of file while inside a 'code' block!"), | ||
68 | "eof inside code block (line 2)": re.compile(rf"The command that should end the block seems to be missing!"), | ||
69 | "title mismatch": re.compile(rf"{main_match} group (?P<group_id>\w+): ignoring title \"(?P<new_title>{verbose_name})\" that does not match old title \"(?P<old_title>{verbose_name})\""), | ||
70 | "end of comment expecting command": re.compile(rf"{main_match} end of comment block while expecting command ({command_re})"), | ||
71 | "no matching tag": re.compile(rf"{main_match} found </(?P<tag>[^>]+)> tag without matching <(?P=tag)>"), | ||
72 | "documented empty return type": re.compile(rf"{main_match} documented empty return type of {func_name}"), | ||
73 | "unsupported tag": re.compile(rf"{main_match} Unsupported xml/html tag <(?P<tag>[^>]+)> found"), | ||
74 | "expected whitespace after command": re.compile(rf"{main_match} expected whitespace after \\(?P<command>\w+) command"), | ||
75 | "illegal command": re.compile(rf"{main_match} Illegal command (?P<illegal_cmd>(?:@|\\)\w+) as part of a \\(?P<command>\w+) command"), | ||
76 | "undeclared symbol": re.compile(rf"{main_match} documented symbol '(\w+)' was not declared or defined\."), | ||
77 | "nameless member": re.compile(rf"{main_match} member with no name found."), | ||
78 | "end of empty list": re.compile(rf"{main_match} End of list marker found without any preceding list items"), | ||
79 | "blank": re.compile(rf"^\s*$"), | ||
80 | # "": re.compile(rf"{main_match} "), | ||
81 | } | ||
82 | |||
83 | parser_choices = set(matches.keys()) - {"blank", | ||
84 | "eof inside code block (line 2)", | ||
85 | "undocumented param (name)"} | ||
86 | |||
87 | parser = ap.ArgumentParser() | ||
88 | parser.add_argument("filename") | ||
89 | parser.add_argument("--summary", "-s", action="store_true") | ||
90 | parser.add_argument("--key", "-k", choices=parser_choices, action="append", dest="keys") | ||
91 | args = parser.parse_args() | ||
92 | |||
93 | sorted_lines = {k:[] for k in matches.keys()} | ||
94 | unsorted_lines = [] | ||
95 | |||
96 | with open(args.filename, "r") as file: | ||
97 | for line in file.readlines(): | ||
98 | for key, value in matches.items(): | ||
99 | if match := value.match(line): | ||
100 | sorted_lines[key].append(match) | ||
101 | break | ||
102 | else: | ||
103 | unsorted_lines.append(line.strip("\n")) | ||
104 | |||
105 | |||
106 | processed_lines = {k: [" ".join(g for g in match.groups()) | ||
107 | for match in matches] | ||
108 | for k, matches in sorted_lines.items()} | ||
109 | |||
110 | # Combining multiline warnings | ||
111 | processed_lines["undocumented param"] = [ | ||
112 | l1+" "+l2 for l1, l2 in zip(processed_lines["undocumented param"], | ||
113 | processed_lines["undocumented param (name)"]) | ||
114 | ] | ||
115 | |||
116 | # Removing chaff | ||
117 | del processed_lines["blank"] | ||
118 | del processed_lines["eof inside code block (line 2)"] | ||
119 | del processed_lines["undocumented param (name)"] | ||
120 | |||
121 | # Preparing count dictionary and summarising the results | ||
122 | counts = {k: len(v) for k, v in processed_lines.items()} | ||
123 | if args.summary: | ||
124 | for k, v in counts.items(): | ||
125 | print(k+":", v) | ||
126 | print("") | ||
127 | |||
128 | if args.keys is not None: | ||
129 | for key in args.keys: | ||
130 | print(f"{key}: {counts[key]}") | ||
131 | for line in processed_lines[key]: | ||
132 | print(line) | ||
133 | print("") | ||
134 | |||
diff --git a/contrib/scripts/generate-release-triplet.sh b/contrib/scripts/generate-release-triplet.sh new file mode 100755 index 000000000..7dc890dc0 --- /dev/null +++ b/contrib/scripts/generate-release-triplet.sh | |||
@@ -0,0 +1,21 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | PACKAGE=$1 | ||
4 | VERSION=$2 | ||
5 | |||
6 | cat << EOF >> $PACKAGE-$VERSION.directive | ||
7 | version: 1.2 | ||
8 | directory: gnunet | ||
9 | filename: $PACKAGE-$VERSION.tar.gz | ||
10 | symlink: $PACKAGE-$VERSION.tar.gz $PACKAGE-latest.tar.gz | ||
11 | EOF | ||
12 | |||
13 | gpg --clearsign $PACKAGE-$VERSION.directive | ||
14 | gpg -b $PACKAGE-$VERSION.tar.gz | ||
15 | exit | ||
16 | ftp -inv ftp-upload.gnu.org <<EOF | ||
17 | user anonymous | ||
18 | cd incoming/ftp | ||
19 | mput $PACKAGE-$VERSION.tar.gz $PACKAGE-$VERSION.tar.gz.sig $PACKAGE-$VERSION.tar.gz.directive.asc | ||
20 | bye | ||
21 | EOF | ||
diff --git a/contrib/scripts/gnunet-logread/Makefile.am b/contrib/scripts/gnunet-logread/Makefile.am index d0054391c..d53a8b8cf 100644 --- a/contrib/scripts/gnunet-logread/Makefile.am +++ b/contrib/scripts/gnunet-logread/Makefile.am | |||
@@ -4,11 +4,11 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_builddir)/src/include | |||
4 | SUFFIXES = .in | 4 | SUFFIXES = .in |
5 | 5 | ||
6 | gnunet-logread: gnunet-logread.in Makefile | 6 | gnunet-logread: gnunet-logread.in Makefile |
7 | $(AWK) -v prl="$(PERL)" -v pfx="$(prefix)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/gnunet-logread.in > gnunet-logread | 7 | $(AWK) -v prl="$(PERL)" -v pfx="$(prefix)" -f $(top_srcdir)/scripts/dosubst.awk < $(srcdir)/gnunet-logread.in > gnunet-logread |
8 | chmod +x gnunet-logread | 8 | chmod +x gnunet-logread |
9 | 9 | ||
10 | gnunet-logread-ipc-sdedit: gnunet-logread-ipc-sdedit.in Makefile | 10 | gnunet-logread-ipc-sdedit: gnunet-logread-ipc-sdedit.in Makefile |
11 | $(AWK) -v prl="$(PERL)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/gnunet-logread-ipc-sdedit.in > gnunet-logread-ipc-sdedit | 11 | $(AWK) -v prl="$(PERL)" -f $(top_srcdir)/scripts/dosubst.awk < $(srcdir)/gnunet-logread-ipc-sdedit.in > gnunet-logread-ipc-sdedit |
12 | chmod +x gnunet-logread-ipc-sdedit | 12 | chmod +x gnunet-logread-ipc-sdedit |
13 | 13 | ||
14 | CLEANFILES= \ | 14 | CLEANFILES= \ |
diff --git a/contrib/scripts/meson.build b/contrib/scripts/meson.build new file mode 100644 index 000000000..d56ba2b76 --- /dev/null +++ b/contrib/scripts/meson.build | |||
@@ -0,0 +1,4 @@ | |||
1 | install_data('gnunet-bugreport', | ||
2 | install_dir: get_option('bindir')) | ||
3 | install_data('gnunet-suidfix', | ||
4 | install_dir: get_option('libdir')/'gnunet'/'libexec') | ||
diff --git a/contrib/scripts/netjail/netjail_core.sh b/contrib/scripts/netjail/netjail_core.sh deleted file mode 100755 index d53315052..000000000 --- a/contrib/scripts/netjail/netjail_core.sh +++ /dev/null | |||
@@ -1,217 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | |||
4 | JAILOR=${SUDO_USER:?must run in sudo} | ||
5 | PREFIX=${PPID:?must run from a parent process} | ||
6 | |||
7 | # running with `sudo` is required to be | ||
8 | # able running the actual commands as the | ||
9 | # original user. | ||
10 | |||
11 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | ||
12 | |||
13 | export RESULT= | ||
14 | export NAMESPACE_NUM=0 | ||
15 | export INTERFACE_NUM=0 | ||
16 | |||
17 | netjail_next_namespace() { | ||
18 | local NUM=$NAMESPACE_NUM | ||
19 | NAMESPACE_NUM=$(($NAMESPACE_NUM + 1)) | ||
20 | RESULT=$NUM | ||
21 | } | ||
22 | |||
23 | netjail_next_interface() { | ||
24 | local NUM=$INTERFACE_NUM | ||
25 | INTERFACE_NUM=$(($INTERFACE_NUM + 1)) | ||
26 | RESULT=$NUM | ||
27 | } | ||
28 | |||
29 | netjail_opt() { | ||
30 | local OPT=$1 | ||
31 | shift 1 | ||
32 | |||
33 | INDEX=1 | ||
34 | |||
35 | while [ $# -gt 0 ]; do | ||
36 | if [ "$1" = "$OPT" ]; then | ||
37 | RESULT=$INDEX | ||
38 | return | ||
39 | fi | ||
40 | |||
41 | INDEX=$(($INDEX + 1)) | ||
42 | shift 1 | ||
43 | done | ||
44 | |||
45 | RESULT=0 | ||
46 | } | ||
47 | |||
48 | netjail_opts() { | ||
49 | local OPT=$1 | ||
50 | local DEF=$2 | ||
51 | shift 2 | ||
52 | |||
53 | while [ $# -gt 0 ]; do | ||
54 | if [ "$1" = "$OPT" ]; then | ||
55 | printf "$2" | ||
56 | return | ||
57 | fi | ||
58 | |||
59 | shift 1 | ||
60 | done | ||
61 | |||
62 | RESULT="$DEF" | ||
63 | } | ||
64 | |||
65 | netjail_check() { | ||
66 | local NODE_COUNT=$1 | ||
67 | local FD_COUNT=$(($(ls /proc/self/fd | wc -w) - 4)) | ||
68 | |||
69 | # quit if `$FD_COUNT < ($LOCAL_M * $GLOBAL_N * 2)`: | ||
70 | # the script also requires `sudo -C ($FD_COUNT + 4)` | ||
71 | # so you need 'Defaults closefrom_override' in the | ||
72 | # sudoers file. | ||
73 | |||
74 | if [ $FD_COUNT -lt $(($NODE_COUNT * 2)) ]; then | ||
75 | echo "File descriptors do not match requirements!" >&2 | ||
76 | exit 1 | ||
77 | fi | ||
78 | } | ||
79 | |||
80 | netjail_check_bin() { | ||
81 | local PROGRAM=$1 | ||
82 | local MATCH=$(ls $(echo $PATH | tr ":" "\n") | grep "^$PROGRAM\$" | tr "\n" " " | awk '{ print $1 }') | ||
83 | |||
84 | # quit if the required binary $PROGRAM can not be | ||
85 | # found in the used $PATH. | ||
86 | |||
87 | if [ "$MATCH" != "$PROGRAM" ]; then | ||
88 | echo "Required binary not found: $PROGRAM" >&2 | ||
89 | exit 1 | ||
90 | fi | ||
91 | } | ||
92 | |||
93 | netjail_bridge() { | ||
94 | netjail_next_interface | ||
95 | local NUM=$RESULT | ||
96 | local BRIDGE=$(printf "%06x-%08x" $PREFIX $NUM) | ||
97 | |||
98 | ip link add $BRIDGE type bridge | ||
99 | ip link set dev $BRIDGE up | ||
100 | |||
101 | RESULT=$BRIDGE | ||
102 | } | ||
103 | |||
104 | netjail_bridge_clear() { | ||
105 | local BRIDGE=$1 | ||
106 | |||
107 | ip link delete $BRIDGE | ||
108 | } | ||
109 | |||
110 | netjail_node() { | ||
111 | netjail_next_namespace | ||
112 | local NUM=$RESULT | ||
113 | local NODE=$(printf "%06x-%08x" $PREFIX $NUM) | ||
114 | |||
115 | ip netns add $NODE | ||
116 | |||
117 | RESULT=$NODE | ||
118 | } | ||
119 | |||
120 | netjail_node_clear() { | ||
121 | local NODE=$1 | ||
122 | |||
123 | ip netns delete $NODE | ||
124 | } | ||
125 | |||
126 | netjail_node_link_bridge() { | ||
127 | local NODE=$1 | ||
128 | local BRIDGE=$2 | ||
129 | local ADDRESS=$3 | ||
130 | local MASK=$4 | ||
131 | |||
132 | netjail_next_interface | ||
133 | local NUM_IF=$RESULT | ||
134 | netjail_next_interface | ||
135 | local NUM_BR=$RESULT | ||
136 | |||
137 | local LINK_IF=$(printf "%06x-%08x" $PREFIX $NUM_IF) | ||
138 | local LINK_BR=$(printf "%06x-%08x" $PREFIX $NUM_BR) | ||
139 | |||
140 | ip link add $LINK_IF type veth peer name $LINK_BR | ||
141 | ip link set $LINK_IF netns $NODE | ||
142 | ip link set $LINK_BR master $BRIDGE | ||
143 | |||
144 | ip -n $NODE addr add "$ADDRESS/$MASK" dev $LINK_IF | ||
145 | ip -n $NODE link set $LINK_IF up | ||
146 | ip -n $NODE link set up dev lo | ||
147 | |||
148 | ip link set $LINK_BR up | ||
149 | |||
150 | RESULT=$LINK_BR | ||
151 | } | ||
152 | |||
153 | netjail_node_unlink_bridge() { | ||
154 | local LINK_BR=$1 | ||
155 | |||
156 | ip link delete $LINK_BR | ||
157 | } | ||
158 | |||
159 | netjail_node_add_nat() { | ||
160 | local NODE=$1 | ||
161 | local ADDRESS=$2 | ||
162 | local MASK=$3 | ||
163 | |||
164 | ip netns exec $NODE iptables -t nat -A POSTROUTING -s "$ADDRESS/$MASK" -j MASQUERADE | ||
165 | } | ||
166 | |||
167 | netjail_node_add_default() { | ||
168 | local NODE=$1 | ||
169 | local ADDRESS=$2 | ||
170 | |||
171 | ip -n $NODE route add default via $ADDRESS | ||
172 | } | ||
173 | |||
174 | netjail_node_exec() { | ||
175 | local NODE=$1 | ||
176 | local FD_IN=$2 | ||
177 | local FD_OUT=$3 | ||
178 | shift 3 | ||
179 | |||
180 | ip netns exec $NODE sudo -u $JAILOR -- $@ 1>& $FD_OUT 0<& $FD_IN | ||
181 | } | ||
182 | |||
183 | netjail_kill() { | ||
184 | local PID=$1 | ||
185 | local MATCH=$(ps --pid $PID | awk "{ if ( \$1 == $PID ) { print \$1 } }" | wc -l) | ||
186 | |||
187 | if [ $MATCH -gt 0 ]; then | ||
188 | kill -n 19 $PID | ||
189 | |||
190 | for CHILD in $(ps -o pid,ppid -ax | awk "{ if ( \$2 == $PID ) { print \$1 } }"); do | ||
191 | netjail_kill $CHILD | ||
192 | done | ||
193 | |||
194 | kill $PID | ||
195 | fi | ||
196 | } | ||
197 | |||
198 | netjail_killall() { | ||
199 | if [ $# -gt 0 ]; then | ||
200 | local PIDS=$1 | ||
201 | |||
202 | for PID in $PIDS; do | ||
203 | netjail_kill $PID | ||
204 | done | ||
205 | fi | ||
206 | } | ||
207 | |||
208 | netjail_waitall() { | ||
209 | if [ $# -gt 0 ]; then | ||
210 | local PIDS=$1 | ||
211 | |||
212 | for PID in $PIDS; do | ||
213 | wait $PID | ||
214 | done | ||
215 | fi | ||
216 | } | ||
217 | |||
diff --git a/contrib/scripts/netjail/netjail_setup_internet.sh b/contrib/scripts/netjail/netjail_setup_internet.sh deleted file mode 100755 index ea820f38c..000000000 --- a/contrib/scripts/netjail/netjail_setup_internet.sh +++ /dev/null | |||
@@ -1,166 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | . "./netjail_core.sh" | ||
4 | |||
5 | set -eu | ||
6 | set -x | ||
7 | |||
8 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | ||
9 | |||
10 | PREFIX=$PPID | ||
11 | LOCAL_M=$1 | ||
12 | GLOBAL_N=$2 | ||
13 | |||
14 | shift 2 | ||
15 | |||
16 | netjail_check $(($LOCAL_M * $GLOBAL_N)) | ||
17 | |||
18 | # Starts optionally an amount of nodes without NAT starting with "92.68.151.1" | ||
19 | netjail_opt '--known' $@ | ||
20 | KNOWN=$RESULT | ||
21 | netjail_opts '--known' 0 $@ | ||
22 | KNOWN_NUM=$RESULT | ||
23 | |||
24 | # Starts optionally 'stunserver' on "92.68.150.254": | ||
25 | netjail_opt '--stun' $@ | ||
26 | STUN=$RESULT | ||
27 | |||
28 | if [ $KNOWN -gt 0 ]; then | ||
29 | shift 2 | ||
30 | |||
31 | KNOWN=$KNOWN_NUM | ||
32 | |||
33 | netjail_check $(($LOCAL_M * $GLOBAL_N + $KNOWN)) | ||
34 | fi | ||
35 | |||
36 | if [ $STUN -gt 0 ]; then | ||
37 | netjail_check_bin stunserver | ||
38 | |||
39 | shift 1 | ||
40 | fi | ||
41 | |||
42 | netjail_check_bin $1 | ||
43 | |||
44 | LOCAL_GROUP="192.168.15" | ||
45 | GLOBAL_GROUP="92.68.150" | ||
46 | KNOWN_GROUP="92.68.151" | ||
47 | |||
48 | CLEANUP=0 | ||
49 | echo "Start [local: $LOCAL_GROUP.0/24, global: $GLOBAL_GROUP.0/16, stun: $STUN]" | ||
50 | |||
51 | netjail_bridge | ||
52 | NETWORK_NET=$RESULT | ||
53 | |||
54 | for X in $(seq $KNOWN); do | ||
55 | netjail_node | ||
56 | KNOWN_NODES[$X]=$RESULT | ||
57 | netjail_node_link_bridge ${KNOWN_NODES[$X]} $NETWORK_NET "$KNOWN_GROUP.$X" 16 | ||
58 | KNOWN_LINKS[$X]=$RESULT | ||
59 | done | ||
60 | |||
61 | declare -A NODES | ||
62 | declare -A NODE_LINKS | ||
63 | |||
64 | for N in $(seq $GLOBAL_N); do | ||
65 | netjail_node | ||
66 | ROUTERS[$N]=$RESULT | ||
67 | netjail_node_link_bridge ${ROUTERS[$N]} $NETWORK_NET "$GLOBAL_GROUP.$N" 16 | ||
68 | NETWORK_LINKS[$N]=$RESULT | ||
69 | netjail_bridge | ||
70 | ROUTER_NETS[$N]=$RESULT | ||
71 | |||
72 | for M in $(seq $LOCAL_M); do | ||
73 | netjail_node | ||
74 | NODES[$N,$M]=$RESULT | ||
75 | netjail_node_link_bridge ${NODES[$N,$M]} ${ROUTER_NETS[$N]} "$LOCAL_GROUP.$M" 24 | ||
76 | NODE_LINKS[$N,$M]=$RESULT | ||
77 | done | ||
78 | |||
79 | ROUTER_ADDR="$LOCAL_GROUP.$(($LOCAL_M+1))" | ||
80 | netjail_node_link_bridge ${ROUTERS[$N]} ${ROUTER_NETS[$N]} $ROUTER_ADDR 24 | ||
81 | ROUTER_LINKS[$N]=$RESULT | ||
82 | |||
83 | netjail_node_add_nat ${ROUTERS[$N]} $ROUTER_ADDR 24 | ||
84 | |||
85 | for M in $(seq $LOCAL_M); do | ||
86 | netjail_node_add_default ${NODES[$N,$M]} $ROUTER_ADDR | ||
87 | done | ||
88 | done | ||
89 | |||
90 | WAITING="" | ||
91 | KILLING="" | ||
92 | |||
93 | if [ $STUN -gt 0 ]; then | ||
94 | netjail_node | ||
95 | STUN_NODE=$RESULT | ||
96 | netjail_node_link_bridge $STUN_NODE $NETWORK_NET "$GLOBAL_GROUP.254" 16 | ||
97 | STUN_LINK=$RESULT | ||
98 | |||
99 | netjail_node_exec $STUN_NODE 0 1 stunserver & | ||
100 | KILLING="$!" | ||
101 | fi | ||
102 | |||
103 | for X in $(seq $KNOWN); do | ||
104 | INDEX=$(($X - 1)) | ||
105 | |||
106 | FD_X=$(($INDEX * 2 + 3 + 0)) | ||
107 | FD_Y=$(($INDEX * 2 + 3 + 1)) | ||
108 | |||
109 | netjail_node_exec ${KNOWN_NODES[$X]} $FD_X $FD_Y $@ & | ||
110 | WAITING="$! $WAITING" | ||
111 | done | ||
112 | |||
113 | for N in $(seq $GLOBAL_N); do | ||
114 | for M in $(seq $LOCAL_M); do | ||
115 | INDEX=$(($LOCAL_M * ($N - 1) + $M - 1 + $KNOWN)) | ||
116 | |||
117 | FD_X=$(($INDEX * 2 + 3 + 0)) | ||
118 | FD_Y=$(($INDEX * 2 + 3 + 1)) | ||
119 | |||
120 | netjail_node_exec ${NODES[$N,$M]} $FD_X $FD_Y $@ & | ||
121 | WAITING="$! $WAITING" | ||
122 | done | ||
123 | done | ||
124 | |||
125 | cleanup() { | ||
126 | if [ $STUN -gt 0 ]; then | ||
127 | netjail_node_unlink_bridge $STUN_LINK | ||
128 | netjail_node_clear $STUN_NODE | ||
129 | fi | ||
130 | |||
131 | for X in $(seq $KNOWN); do | ||
132 | netjail_node_unlink_bridge ${KNOWN_LINKS[$X]} | ||
133 | netjail_node_clear ${KNOWN_NODES[$X]} | ||
134 | done | ||
135 | |||
136 | for N in $(seq $GLOBAL_N); do | ||
137 | for M in $(seq $LOCAL_M); do | ||
138 | netjail_node_unlink_bridge ${NODE_LINKS[$N,$M]} | ||
139 | netjail_node_clear ${NODES[$N,$M]} | ||
140 | done | ||
141 | |||
142 | netjail_node_unlink_bridge ${ROUTER_LINKS[$N]} | ||
143 | netjail_bridge_clear ${ROUTER_NETS[$N]} | ||
144 | netjail_node_unlink_bridge ${NETWORK_LINKS[$N]} | ||
145 | netjail_node_clear ${ROUTERS[$N]} | ||
146 | done | ||
147 | |||
148 | netjail_bridge_clear $NETWORK_NET | ||
149 | } | ||
150 | |||
151 | trapped_cleanup() { | ||
152 | netjail_killall $WAITING | ||
153 | netjail_killall $KILLING | ||
154 | |||
155 | cleanup | ||
156 | } | ||
157 | |||
158 | trap 'trapped_cleanup' ERR | ||
159 | |||
160 | netjail_waitall $WAITING | ||
161 | netjail_killall $KILLING | ||
162 | wait | ||
163 | |||
164 | cleanup | ||
165 | |||
166 | echo "Done" | ||
diff --git a/contrib/scripts/news_delta.sh b/contrib/scripts/news_delta.sh new file mode 100755 index 000000000..20fb98649 --- /dev/null +++ b/contrib/scripts/news_delta.sh | |||
@@ -0,0 +1,6 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | OLDVERSION=$1 | ||
4 | |||
5 | git --no-pager log --grep="^NEWS: " -i --no-merges --no-color --format="%s%n%b" $1..HEAD | grep -i "^NEWS:\s[a-zA-Z][a-zA-Z]*" | sed 's/NEWS:/ -/i' | ||
6 | echo "" | ||
diff --git a/contrib/scripts/testbed_cleanup.sh b/contrib/scripts/testbed_cleanup.sh deleted file mode 100755 index ee0200d44..000000000 --- a/contrib/scripts/testbed_cleanup.sh +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | ################################################################################### | ||
4 | # Script to clean a previous run of testbed which has crashed. This scripts kills # | ||
5 | # the peers and cleans the temporary files created for those peers # | ||
6 | # # | ||
7 | # Author: Sree Harsha Totakura # | ||
8 | ################################################################################### | ||
9 | |||
10 | for host in `cut -d : -f 1 < infiniband_cluster.hosts | cut -d @ -f 2` | ||
11 | do | ||
12 | echo "ssh --> $host" | ||
13 | ssh $host 'pkill -SIGKILL gnunet; rm -rf /tmp/gnunet-pipe*; rm -rf /tmp/testbed*' | ||
14 | done | ||
diff --git a/contrib/scripts/update_news.sh b/contrib/scripts/update_news.sh new file mode 100755 index 000000000..014ac8bd7 --- /dev/null +++ b/contrib/scripts/update_news.sh | |||
@@ -0,0 +1,15 @@ | |||
1 | #!/bin/bash | ||
2 | NEW_VERSION=$1 | ||
3 | if [ -z $NEW_VERSION ]; then | ||
4 | NEW_VERSION="Unreleased" | ||
5 | fi | ||
6 | DELTA_SH="contrib/scripts/news_delta.sh" | ||
7 | LASTVER=$(head -n1 NEWS | tr -d :) | ||
8 | |||
9 | echo "$NEW_VERSION:" > NEWS.delta || exit 1 | ||
10 | $DELTA_SH $LASTVER >> NEWS.delta || exit 1 | ||
11 | cp NEWS NEWS.bak || exit 1 | ||
12 | cat NEWS.delta > NEWS || exit 1 | ||
13 | cat NEWS.bak >> NEWS || exit 1 | ||
14 | rm NEWS.bak NEWS.delta | ||
15 | |||