Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Oliver Smith | 24ddf9c | 2019-01-30 16:48:18 +0100 | [diff] [blame] | 2 | |
Oliver Smith | cd472bd | 2022-01-17 15:59:31 +0100 | [diff] [blame] | 3 | # tmux: start this script inside a new session |
| 4 | tmux_session="CN" |
| 5 | if [ "${TERMINAL}" = "tmux" ] && [ "$1" != "inside-tmux" ]; then |
| 6 | echo "Starting tmux session '$tmux_session'" |
| 7 | unset TMUX |
| 8 | exec tmux new-session -s "$tmux_session" -n "RUN" "$0" "inside-tmux" |
| 9 | fi |
| 10 | |
Oliver Smith | 24ddf9c | 2019-01-30 16:48:18 +0100 | [diff] [blame] | 11 | if ! ../fill_config.py --check-stale; then |
| 12 | echo |
| 13 | echo "WARNING: STALE CONFIGS - your net configs are older than the templates they should be based on!" |
| 14 | echo " * Hit enter to continue, and use the stale config files" |
| 15 | echo " * Hit ^C and run 'make regen' to regenerate your configs" |
| 16 | read enter_to_continue |
| 17 | fi |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 18 | |
| 19 | dev="${ETH_DEV}" |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 20 | apn="${APN_DEV}" |
| 21 | |
| 22 | sudo true || exit 1 |
| 23 | |
Oliver Smith | 4186b95 | 2021-07-07 16:40:36 +0200 | [diff] [blame] | 24 | if ! sudo iptables -t nat -C POSTROUTING -s ${GGSN_NET} -o $dev -j MASQUERADE 2>/dev/null; then |
| 25 | echo "Adding iptables rule for masquerade" |
| 26 | sudo iptables -t nat -I POSTROUTING -s ${GGSN_NET} -o $dev -j MASQUERADE |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 27 | fi |
| 28 | |
| 29 | if [ "$(sudo cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then |
| 30 | sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" |
| 31 | fi |
| 32 | |
| 33 | if [ -z "$(ip tuntap show | grep $apn)" ]; then |
| 34 | sudo ip tuntap add dev $apn mode tun user $USER group $USER |
| 35 | sudo ip addr add ${GGSN_NET} dev $apn |
| 36 | sudo ip link set $apn up |
| 37 | fi |
| 38 | |
Oliver Smith | 2490f69 | 2019-03-13 15:16:16 +0100 | [diff] [blame] | 39 | if [ -z "$(ip addr show | grep "${TO_RAN_IP}")" ]; then |
| 40 | echo "No interface has IP address ${TO_RAN_IP}! Hit enter to continue anyway." |
Neels Hofmeyr | ede8016 | 2018-09-16 13:49:13 +0200 | [diff] [blame] | 41 | read enter_to_continue |
| 42 | fi |
Oliver Smith | 2490f69 | 2019-03-13 15:16:16 +0100 | [diff] [blame] | 43 | if [ -z "$(ip addr show | grep "${TO_RAN_IU_IP}")" ]; then |
| 44 | echo "No interface has IP address ${TO_RAN_IU_IP}! Hit enter to 'ip addr add ${TO_RAN_IU_IP}/32 dev $dev'" |
Neels Hofmeyr | ede8016 | 2018-09-16 13:49:13 +0200 | [diff] [blame] | 45 | read enter_to_continue |
Oliver Smith | 2490f69 | 2019-03-13 15:16:16 +0100 | [diff] [blame] | 46 | sudo ip addr add ${TO_RAN_IU_IP}/32 dev $dev |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 47 | fi |
| 48 | |
| 49 | logdir="current_log" |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 50 | piddir="run/pids" |
Oliver Smith | 6327371 | 2022-01-18 11:21:37 +0100 | [diff] [blame] | 51 | launcherdir="run/launchers" |
| 52 | rm -rf "$launcherdir" |
| 53 | mkdir -p "$logdir" "$piddir" "$launcherdir" |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 54 | |
Oliver Smith | 4d7072c | 2018-09-28 11:30:46 +0200 | [diff] [blame] | 55 | find_term() { |
| 56 | # Find a terminal program and write to the global "terminal" variable |
Oliver Smith | cd472bd | 2022-01-17 15:59:31 +0100 | [diff] [blame] | 57 | local programs="urxvt xterm tmux" |
Oliver Smith | 4d7072c | 2018-09-28 11:30:46 +0200 | [diff] [blame] | 58 | |
Oliver Smith | b28a910 | 2022-01-17 15:59:02 +0100 | [diff] [blame] | 59 | if [ -z "${TERMINAL}" ]; then |
| 60 | echo "ERROR: TERMINAL is not defined in your osmo-dev net config file. Please add it." |
| 61 | exit 1 |
| 62 | fi |
| 63 | |
| 64 | case " $programs " in |
| 65 | *" ${TERMINAL} "*) |
| 66 | terminal="${TERMINAL}" |
| 67 | |
| 68 | if command -v "$terminal" >/dev/null; then |
| 69 | echo "Terminal: ${TERMINAL}" |
| 70 | return |
| 71 | fi |
| 72 | |
| 73 | echo "ERROR: Terminal '${TERMINAL}' is configured, but not installed" |
| 74 | exit 1 |
| 75 | ;; |
| 76 | esac |
| 77 | |
| 78 | echo "ERROR: Terminal '${TERMINAL}' is not in list of supported terminals ($programs)" |
Oliver Smith | 4d7072c | 2018-09-28 11:30:46 +0200 | [diff] [blame] | 79 | exit 1 |
| 80 | } |
| 81 | |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 82 | pidfiles_must_not_exist() { |
| 83 | local pidfile |
| 84 | |
| 85 | for pidfile in "$@"; do |
| 86 | if [ -e "$pidfile" ]; then |
| 87 | echo |
| 88 | echo "ERROR: pidfile exists: $pidfile" |
| 89 | echo |
| 90 | kill_pids |
| 91 | exit 1 |
| 92 | fi |
| 93 | done |
| 94 | } |
| 95 | |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 96 | term() { |
| 97 | title="$2" |
| 98 | if [ -z "$title" ]; then |
| 99 | title="$(basename $@)" |
| 100 | fi |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 101 | |
| 102 | local pidfile="$piddir/$title.pid" |
| 103 | local pidfile_term="$piddir/$title.term.pid" |
| 104 | pidfiles_must_not_exist "$pidfile" "$pidfile_term" |
| 105 | |
Oliver Smith | 6327371 | 2022-01-18 11:21:37 +0100 | [diff] [blame] | 106 | local launcher="$launcherdir/$title.sh" |
| 107 | |
| 108 | cat << EOF > "$launcher" |
| 109 | #!/bin/sh |
| 110 | |
| 111 | export LD_LIBRARY_PATH='/usr/local/lib' |
| 112 | |
| 113 | $1 & |
| 114 | echo \$! > $pidfile |
| 115 | wait |
| 116 | |
| 117 | echo |
| 118 | |
| 119 | while true; do |
| 120 | echo 'q Enter to close' |
Oliver Smith | e33f85f | 2022-02-21 11:25:37 +0100 | [diff] [blame] | 121 | read q_to_close < /dev/tty |
Oliver Smith | 6327371 | 2022-01-18 11:21:37 +0100 | [diff] [blame] | 122 | if [ "x\$q_to_close" = xq ]; then |
| 123 | break |
| 124 | fi |
| 125 | done |
| 126 | EOF |
| 127 | chmod +x "$launcher" |
| 128 | |
Oliver Smith | cd472bd | 2022-01-17 15:59:31 +0100 | [diff] [blame] | 129 | case "$terminal" in |
| 130 | tmux) |
Oliver Smith | f34a944 | 2022-02-23 12:29:06 +0100 | [diff] [blame] | 131 | tmux new-window -d -n "$title" "$launcher &; echo \$! > $pidfile_term; wait" |
Oliver Smith | cd472bd | 2022-01-17 15:59:31 +0100 | [diff] [blame] | 132 | ;; |
| 133 | *) |
| 134 | $terminal \ |
| 135 | -title "CN:$title" \ |
| 136 | -e sh -c "$launcher" \ |
| 137 | & |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 138 | |
Oliver Smith | cd472bd | 2022-01-17 15:59:31 +0100 | [diff] [blame] | 139 | echo "$!" > "$pidfile_term" |
| 140 | ;; |
| 141 | esac |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | kill_pids() { |
| 145 | local pidfile |
| 146 | local pid |
| 147 | |
| 148 | for pidfile in "$piddir"/*.pid; do |
| 149 | if ! [ -e "$pidfile" ]; then |
| 150 | continue |
| 151 | fi |
| 152 | |
| 153 | pid="$(cat "$pidfile")" |
| 154 | |
| 155 | echo "killing $(basename "$pidfile") ($pid)" |
| 156 | sudo kill "$pid" |
| 157 | rm "$pidfile" |
| 158 | done |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 159 | } |
| 160 | |
Oliver Smith | 4d7072c | 2018-09-28 11:30:46 +0200 | [diff] [blame] | 161 | find_term |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 162 | kill_pids |
Oliver Smith | 4d7072c | 2018-09-28 11:30:46 +0200 | [diff] [blame] | 163 | |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 164 | hnbgw="osmo-hnbgw" |
| 165 | msc="gdb -ex run --args $(which osmo-msc)" |
Neels Hofmeyr | 8e49484 | 2019-08-07 01:35:06 +0200 | [diff] [blame] | 166 | # To enable udtrace on osmo-msc MNCC socket, use this with adjusted /path/to/udtrace: |
| 167 | # - LD_LIBRARY_PATH allows linking to titan if udtrace was compiled with titan support. |
| 168 | # - LD_PRELOAD of libasan allows building osmo-msc with the sanitize.opts. |
| 169 | # - the tee saves the stderr logging as well as the udtrace output to new file current_log/osmo-msc.out, since udtrace |
| 170 | # will not show in osmo-msc.log |
| 171 | #msc="LD_LIBRARY_PATH=/usr/lib/titan LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.5:/path/to/udtrace/libudtrace.so osmo-msc 2>&1 | tee -a current_log/osmo-msc.out" |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 172 | gbproxy="osmo-gbproxy" |
| 173 | sgsn="osmo-sgsn" |
| 174 | ggsn="osmo-ggsn" |
| 175 | mgw4msc="osmo-mgw -c osmo-mgw-for-msc.cfg" |
Oliver Smith | e765819 | 2022-02-21 15:31:20 +0100 | [diff] [blame] | 176 | #mgw4bsc="gdb -ex run --args osmo-mgw" |
| 177 | #mgw4bsc="strace osmo-mgw" |
| 178 | mgw4bsc="osmo-mgw" |
Oliver Smith | 5467ef9 | 2018-12-13 13:27:37 +0100 | [diff] [blame] | 179 | hlr="LD_LIBRARY_PATH=/usr/local/lib gdb -ex run --args osmo-hlr --db-upgrade" |
Oliver Smith | a3a1a0d | 2021-12-14 16:27:10 +0100 | [diff] [blame] | 180 | stp4cn="osmo-stp -c osmo-stp-cn.cfg" |
| 181 | stp4ran="osmo-stp -c osmo-stp-ran.cfg" |
Oliver Smith | e765819 | 2022-02-21 15:31:20 +0100 | [diff] [blame] | 182 | bsc="LD_LIBRARY_PATH=/usr/local/lib gdb -ex run --args osmo-bsc" |
Oliver Smith | a3a1a0d | 2021-12-14 16:27:10 +0100 | [diff] [blame] | 183 | bscnat="osmo-bsc-nat" |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 184 | |
Neels Hofmeyr | cbdd718 | 2019-03-04 00:39:32 +0100 | [diff] [blame] | 185 | if [ "x${MSC_MNCC}" != "xinternal" ]; then |
Oliver Smith | d9f3d34 | 2018-09-26 16:29:00 +0200 | [diff] [blame] | 186 | sipcon="osmo-sip-connector -c osmo-sip-connector.cfg" |
Oliver Smith | d9f3d34 | 2018-09-26 16:29:00 +0200 | [diff] [blame] | 187 | |
Neels Hofmeyr | ba0a828 | 2019-12-04 03:57:56 +0100 | [diff] [blame] | 188 | case "${PBX_SERVER}" in |
Oliver Smith | 667f19b | 2019-11-08 18:16:30 +0100 | [diff] [blame] | 189 | "kamailio") |
| 190 | # Require kamailio (PATH hack is needed for Debian) |
| 191 | kamailio="$(PATH="$PATH:/usr/sbin:/sbin" which kamailio)" |
| 192 | if [ -z "$kamailio" ]; then |
| 193 | echo "ERROR: kamailio is not installed." |
| 194 | echo "After installing it, make sure that it does *not* run as daemon." |
| 195 | exit 1 |
| 196 | fi |
| 197 | kamailio="$kamailio -f kamailio.cfg -D -e -E" |
| 198 | ;; |
| 199 | "freeswitch") |
| 200 | if [ -z "$(which freeswitch)" ]; then |
| 201 | echo "ERROR: freeswitch is not installed." |
| 202 | echo "Guide: https://freeswitch.org/confluence/display/FREESWITCH/Debian+10+Buster" |
| 203 | echo "After installing it, make sure that it does *not* run as daemon." |
| 204 | exit 1 |
| 205 | fi |
| 206 | ;; |
| 207 | "none") |
| 208 | ;; |
| 209 | *) |
Neels Hofmeyr | ba0a828 | 2019-12-04 03:57:56 +0100 | [diff] [blame] | 210 | echo "ERROR: unknown value ${PBX_SERVER} for SIPCON_SERVER!" |
Oliver Smith | 667f19b | 2019-11-08 18:16:30 +0100 | [diff] [blame] | 211 | exit 1 |
| 212 | ;; |
| 213 | esac |
Oliver Smith | d9f3d34 | 2018-09-26 16:29:00 +0200 | [diff] [blame] | 214 | fi |
| 215 | |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 216 | PIDFILE_TCPDUMP_DEV="$piddir/tcpdump.$dev.pid" |
| 217 | PIDFILE_TCPDUMP_LO="$piddir/tcpdump.lo.pid" |
| 218 | pidfiles_must_not_exist "$PIDFILE_TCPDUMP_DEV" "$PIDFILE_TCPDUMP_LO" |
| 219 | |
Oliver Smith | d9f3d34 | 2018-09-26 16:29:00 +0200 | [diff] [blame] | 220 | sudo tcpdump -i $dev -n -w current_log/$dev.single.pcap -U not port 22 & |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 221 | echo "$!" > "$PIDFILE_TCPDUMP_DEV" |
Oliver Smith | d9f3d34 | 2018-09-26 16:29:00 +0200 | [diff] [blame] | 222 | sudo tcpdump -i lo -n -w current_log/lo.single.pcap -U not port 22 & |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 223 | echo "$!" > "$PIDFILE_TCPDUMP_LO" |
Oliver Smith | d9f3d34 | 2018-09-26 16:29:00 +0200 | [diff] [blame] | 224 | |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 225 | term "$ggsn" GGSN |
Oliver Smith | 8fd5098 | 2021-12-14 18:12:54 +0100 | [diff] [blame] | 226 | |
Oliver Smith | a3a1a0d | 2021-12-14 16:27:10 +0100 | [diff] [blame] | 227 | if [ "${STP_CN_IP}" = "${STP_RAN_IP}" ]; then |
| 228 | sleep .2 |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 229 | term "$stp4cn" STP |
Oliver Smith | a3a1a0d | 2021-12-14 16:27:10 +0100 | [diff] [blame] | 230 | else |
| 231 | sleep .2 |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 232 | term "$stp4cn" STP4CN |
Oliver Smith | a3a1a0d | 2021-12-14 16:27:10 +0100 | [diff] [blame] | 233 | |
| 234 | sleep .2 |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 235 | term "$stp4ran" STP4RAN |
Oliver Smith | a3a1a0d | 2021-12-14 16:27:10 +0100 | [diff] [blame] | 236 | |
| 237 | sleep .2 |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 238 | term "$bscnat" BSCNAT |
Oliver Smith | a3a1a0d | 2021-12-14 16:27:10 +0100 | [diff] [blame] | 239 | fi |
Oliver Smith | 8fd5098 | 2021-12-14 18:12:54 +0100 | [diff] [blame] | 240 | |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 241 | sleep .2 |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 242 | term "$hlr" HLR |
Oliver Smith | 8fd5098 | 2021-12-14 18:12:54 +0100 | [diff] [blame] | 243 | |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 244 | sleep .2 |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 245 | term "$sgsn" SGSN |
Oliver Smith | 8fd5098 | 2021-12-14 18:12:54 +0100 | [diff] [blame] | 246 | |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 247 | sleep .2 |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 248 | term "$gbproxy" GBPROXY |
Oliver Smith | 8fd5098 | 2021-12-14 18:12:54 +0100 | [diff] [blame] | 249 | |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 250 | sleep .2 |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 251 | term "$mgw4msc" MGW4MSC |
Oliver Smith | 8fd5098 | 2021-12-14 18:12:54 +0100 | [diff] [blame] | 252 | |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 253 | sleep .2 |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 254 | term "$msc" MSC |
Oliver Smith | 8fd5098 | 2021-12-14 18:12:54 +0100 | [diff] [blame] | 255 | |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 256 | sleep 2 |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 257 | term "$hnbgw" HNBGW |
Oliver Smith | 8fd5098 | 2021-12-14 18:12:54 +0100 | [diff] [blame] | 258 | |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 259 | sleep .2 |
Oliver Smith | e765819 | 2022-02-21 15:31:20 +0100 | [diff] [blame] | 260 | |
| 261 | if [ "$BSC_COUNT" = 1 ]; then |
| 262 | term "$mgw4bsc -c osmo-mgw-for-bsc-0.cfg" MGW4BSC |
| 263 | sleep .2 |
| 264 | term "$bsc -c osmo-bsc-0.cfg" BSC |
| 265 | else |
| 266 | term "$mgw4bsc -c osmo-mgw-for-bsc-0.cfg" MGW4BSC0 |
| 267 | sleep .2 |
| 268 | term "$mgw4bsc -c osmo-mgw-for-bsc-1.cfg" MGW4BSC1 |
| 269 | sleep .2 |
| 270 | term "$bsc -c osmo-bsc-0.cfg" BSC0 |
| 271 | sleep .2 |
| 272 | term "$bsc -c osmo-bsc-1.cfg" BSC1 |
| 273 | fi |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 274 | |
Neels Hofmeyr | cbdd718 | 2019-03-04 00:39:32 +0100 | [diff] [blame] | 275 | if [ "x${MSC_MNCC}" != "xinternal" ]; then |
Oliver Smith | d9f3d34 | 2018-09-26 16:29:00 +0200 | [diff] [blame] | 276 | sleep .2 |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 277 | term "$sipcon" SIPCON |
Oliver Smith | 8fd5098 | 2021-12-14 18:12:54 +0100 | [diff] [blame] | 278 | |
Oliver Smith | d9f3d34 | 2018-09-26 16:29:00 +0200 | [diff] [blame] | 279 | sleep .2 |
Neels Hofmeyr | ba0a828 | 2019-12-04 03:57:56 +0100 | [diff] [blame] | 280 | case "${PBX_SERVER}" in |
Oliver Smith | 8fd5098 | 2021-12-14 18:12:54 +0100 | [diff] [blame] | 281 | "kamailio") |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 282 | term "$kamailio" KAMAILIO |
Oliver Smith | 8fd5098 | 2021-12-14 18:12:54 +0100 | [diff] [blame] | 283 | ;; |
| 284 | "freeswitch") |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 285 | term "./freeswitch/freeswitch.sh" FREESWITCH |
Oliver Smith | 8fd5098 | 2021-12-14 18:12:54 +0100 | [diff] [blame] | 286 | ;; |
Oliver Smith | 667f19b | 2019-11-08 18:16:30 +0100 | [diff] [blame] | 287 | esac |
Oliver Smith | d9f3d34 | 2018-09-26 16:29:00 +0200 | [diff] [blame] | 288 | fi |
| 289 | |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 290 | #ssh bts rm /tmp/bts.log /tmp/pcu.log |
| 291 | #ssh bts neels/run_remote.sh & |
| 292 | |
| 293 | echo enter to close |
| 294 | read enter_to_close |
| 295 | echo Closing... |
| 296 | |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 297 | #ssh bts neels/stop_remote.sh |
| 298 | |
Oliver Smith | 669f1db | 2022-01-17 15:59:24 +0100 | [diff] [blame] | 299 | kill_pids |
Neels Hofmeyr | fecf156 | 2019-08-07 01:34:12 +0200 | [diff] [blame] | 300 | |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 301 | set +e |
| 302 | cp *.cfg "$logdir"/ |
| 303 | |
| 304 | echo |
| 305 | echo enter name to save log |
| 306 | read log_name |
| 307 | if [ -n "$log_name" ]; then |
| 308 | newlogdir="log/$log_name" |
| 309 | #scp "bts:/tmp/{bts,pcu}.log" "bts:neels/osmo-{bts,pcu}.cfg" "$logdir" |
| 310 | else |
Oliver Smith | 2cfd792 | 2022-02-17 10:08:14 +0100 | [diff] [blame] | 311 | log_name="log_$(date +%Y-%m-%d_%H-%M-%S)" |
| 312 | newlogdir="autolog/$log_name" |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 313 | fi |
| 314 | mkdir -p "$(dirname "$newlogdir")" |
| 315 | |
| 316 | mergecap -w "$logdir/trace.pcap" "$logdir/"*.single.pcap && rm -f "$logdir/"*.single.pcap |
Oliver Smith | 2cfd792 | 2022-02-17 10:08:14 +0100 | [diff] [blame] | 317 | mv "$logdir/trace.pcap" "$logdir/trace-$log_name.pcap" |
Neels Hofmeyr | 697a617 | 2018-08-22 17:32:21 +0200 | [diff] [blame] | 318 | |
| 319 | if [ -x "$newlogdir" ]; then |
| 320 | echo "already exists, move it manually: $newlogdir" |
| 321 | else |
| 322 | echo mv "$logdir" "$newlogdir" |
| 323 | mv "$logdir" "$newlogdir" |
| 324 | mkdir -p "$logdir" |
| 325 | logdir="$newlogdir" |
| 326 | fi |
| 327 | rm lastlog |
| 328 | ln -s "$logdir" lastlog |