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