Václav Kubernát | d1beedc | 2020-09-07 12:09:05 +0200 | [diff] [blame] | 1 | set -eux |
| 2 | |
| 3 | if [[ $(dirname "$(dirname "$(realpath "$SYSREPO_REPOSITORY_PATH")")") != "@CMAKE_CURRENT_BINARY_DIR@" ]]; then |
| 4 | echo "\$SYSREPO_REPOSITORY_PATH is not inside the build dir! Aborting. ($SYSREPO_REPOSITORY_PATH)" |
| 5 | exit 1 |
| 6 | fi |
| 7 | |
| 8 | if [[ -z "$SYSREPO_SHM_PREFIX" ]]; then |
| 9 | echo '$SYSREPO_SHM_PREFIX is empty! Aborting.' |
| 10 | exit 1 |
| 11 | fi |
| 12 | |
| 13 | BACKEND="$1" |
| 14 | shift |
| 15 | if [[ "$BACKEND" = "netconf" ]]; then |
| 16 | # The `-f` argument is neccessary so that pkill matches the whole command |
| 17 | # line, including stuff set by `exec -a`. Otherwise it matches the name in |
| 18 | # /proc/{pid}/stat and that is usually limited to 15 characters, so |
| 19 | # netopeer2-server appears as netopeer2-serve |
Václav Kubernát | c331a31 | 2020-11-19 01:24:43 +0100 | [diff] [blame] | 20 | NETOPEER_PID="$(pgrep -f "${SYSREPO_SHM_PREFIX}_netopeer2-server")" |
Václav Kubernát | d1beedc | 2020-09-07 12:09:05 +0200 | [diff] [blame] | 21 | pkill -f "${SYSREPO_SHM_PREFIX}_netopeer2-server" |
Václav Kubernát | c331a31 | 2020-11-19 01:24:43 +0100 | [diff] [blame] | 22 | |
| 23 | # Wait until netopeer actually exits, because I don't want to remove its repository/shm files while it is still |
| 24 | # running. |
| 25 | # |
| 26 | # One would think, that this is a job for the `wait` command, but that one unfortunately only works for child |
| 27 | # processes of the current shell. The `tail` command does implement this mechanism, so I can use that. |
| 28 | # https://stackoverflow.com/a/41613532 |
| 29 | tail --pid="$NETOPEER_PID" -f /dev/null |
| 30 | |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 31 | rm -f "$NETOPEER_SOCKET" |
Václav Kubernát | d1beedc | 2020-09-07 12:09:05 +0200 | [diff] [blame] | 32 | fi |
| 33 | |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 34 | rm -rf "$SYSREPO_REPOSITORY_PATH" |
Jan Kundrát | 0651966 | 2021-01-07 15:39:23 +0100 | [diff] [blame] | 35 | rm -rf "/dev/shm/$SYSREPO_SHM_PREFIX"* |