Commit 8fa62919 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

playbook: ors playbook support UE mode

parent d76dbb14
...@@ -71,10 +71,6 @@ ...@@ -71,10 +71,6 @@
ignore_errors: yes ignore_errors: yes
# Configure systemd-networkd # Configure systemd-networkd
- name: Configure /etc/systemd/network/dhcp.network
copy: src=systemd-dhcp-network dest=/etc/systemd/network/dhcp.network owner=root mode=644
## eNB and MME addresses are on lo interface, using high MTU will result in bad throughput ## eNB and MME addresses are on lo interface, using high MTU will result in bad throughput
## for TCP when using IPv6 and phones with low MTU ## for TCP when using IPv6 and phones with low MTU
- name: Configure /etc/systemd/network/lo.network - name: Configure /etc/systemd/network/lo.network
......
#!/bin/bash
IF_LIST=()
RM_IF_LIST=()
CONF="/etc/re6stnet/re6stnet.conf"
TMP="/tmp/re6stnet.conf.$(date +%s)"
cd /sys/class/net;
for IF in $(find . -type l -printf "%f\n"); do
# If interface is virtual
if ! realpath $(readlink $IF) | grep -q "^/sys/devices/virtual"; then
# If interface is up and has IPv6 neighbours
if [ "$(cat $IF/operstate)" = "up" ] && [ -n "$(ip -6 neigh list dev $IF)" ]; then
RM_IF_LIST+=($IF);
fi
fi
done
cp $CONF $TMP;
REPLACE=0
# Check if configuration is correct
for IF in "${IF_LIST[@]}"; do
if ! grep -q "^interface $IF" $TMP; then
REPLACE=1
fi
done
for IF in "${RM_IF_LIST[@]}"; do
if grep -q "^interface $IF" $TMP; then
REPLACE=1
fi
done
# Reconfigure re6st if configuration not correct
if (( $REPLACE )); then
sed -i '/^interface/d' $TMP
for IF in "${IF_LIST[@]}"; do
echo "interface $IF" >> $TMP
done
mv $TMP $CONF;
systemctl restart re6stnet
fi
rm -rf $TMP;
...@@ -24,6 +24,13 @@ with open('/opt/upgrader/configure-slapos.log', 'w+') as l: ...@@ -24,6 +24,13 @@ with open('/opt/upgrader/configure-slapos.log', 'w+') as l:
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read(CONF_PATH) config.read(CONF_PATH)
# Don't create tun in UE mode
if "lte-ue" in subprocess.run(['slapos', 'node'], check=False, capture_output=True, text=True).stdout:
print("In UE mode: no TUN interfaces")
ors_config['slapformat']['create_tun'] = 'False'
else:
print("In Base Station mode: with TUN interfaces")
def is_slapformat_valid(): def is_slapformat_valid():
for k in ors_config['slapformat']: for k in ors_config['slapformat']:
if ors_config['slapformat'][k] != \ if ors_config['slapformat'][k] != \
......
#!/bin/bash #!/bin/bash
mkdir -p /etc/sudoers.d mkdir -p /etc/sudoers.d
COMMAND_LIST=("rm-tmp-lte" "init-enb" "init-mme" "init-sdr" "get-sdr-info") COMMAND_LIST=("rm-tmp-lte" "init-enb" "init-mme" "init-sdr" "get-sdr-info" "init-ue")
PARTITION_AMOUNT="$(sed -n 's/partition_amount = \(.*\)/\1/gp' /etc/opt/slapos/slapos.cfg)" PARTITION_AMOUNT="$(sed -n 's/partition_amount = \(.*\)/\1/gp' /etc/opt/slapos/slapos.cfg)"
for c in "${COMMAND_LIST[@]}"; do for c in "${COMMAND_LIST[@]}"; do
SLAPUSER_LINES="$(cat /etc/sudoers.d/slapuser-$c 2> /dev/null | wc -l)" SLAPUSER_LINES="$(cat /etc/sudoers.d/slapuser-$c 2> /dev/null | wc -l)"
...@@ -13,14 +13,24 @@ for c in "${COMMAND_LIST[@]}"; do ...@@ -13,14 +13,24 @@ for c in "${COMMAND_LIST[@]}"; do
chmod 440 /etc/sudoers.d/slapuser-$c chmod 440 /etc/sudoers.d/slapuser-$c
fi fi
done done
c="sdr-util"
SLAPUSER_LINES="$(cat /etc/sudoers.d/slapuser-$c 2> /dev/null | wc -l)"
AMARISOFT_PATH="/opt/amarisoft/$(ls -1 /opt/amarisoft | grep "^v[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}$" | sort | tail -n1)" AMARISOFT_PATH="/opt/amarisoft/$(ls -1 /opt/amarisoft | grep "^v[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}$" | sort | tail -n1)"
if [ "$SLAPUSER_LINES" != "$PARTITION_AMOUNT" ]; then
echo "Configuring /etc/sudoers.d/slapuser-$c..."
for i in $(seq 0 $(($PARTITION_AMOUNT-1))); do c="sdr-util"
echo "slapuser$i ALL=NOPASSWD:$AMARISOFT_PATH/trx_sdr/sdr_util -c 0 version" >> slapuser-$c echo "Configuring /etc/sudoers.d/slapuser-$c..."
done for i in $(seq 0 $(($PARTITION_AMOUNT-1))); do
mv slapuser-$c /etc/sudoers.d/ echo "slapuser$i ALL=NOPASSWD:$AMARISOFT_PATH/trx_sdr/sdr_util -c 0 version" >> slapuser-$c
chmod 440 /etc/sudoers.d/slapuser-$c done
fi mv slapuser-$c /etc/sudoers.d/
chmod 440 /etc/sudoers.d/slapuser-$c
c="lteue"
echo "Configuring /etc/sudoers.d/slapuser-$c..."
echo > slapuser-$c
for i in $(seq 0 $(($PARTITION_AMOUNT-1))); do
echo "slapuser$i ALL=NOPASSWD:$AMARISOFT_PATH/ue/lteue" >> slapuser-$c
done
mv slapuser-$c /etc/sudoers.d/
chmod 440 /etc/sudoers.d/slapuser-$c
#!/bin/bash
cd /sys/class/net;
for IF in $(find . -type l -printf "%f\n"); do
# If interface is virtual
if ! realpath $(readlink $IF) | grep -q "^/sys/devices/virtual"; then
# If interface is up
if [ "$(cat $IF/operstate)" = "up" ] ; then
echo -n $IF
exit
fi
fi
done
#!/bin/bash
# get the second /64 range of re6st /48 range
addr=$(ip a show dev lo | grep '::1/48' | sed 's/inet6 //' | sed 's#/48.*##' | sed 's#::1#:1::#' )
echo -n $addr
#!/bin/bash
AMARISOFT_PATH="/opt/amarisoft/$(ls -1 /opt/amarisoft | grep "^v[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}$" | sort | tail -n1)"
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
$AMARISOFT_PATH/ue/lte_init.sh;
...@@ -69,8 +69,18 @@ ...@@ -69,8 +69,18 @@
# Re6st # Re6st
- name: Configure re6st - name: Ensure interface enp0s31f6 is used by re6st
script: configure-re6st lineinfile: dest=/etc/re6stnet/re6stnet.conf line="interface enp0s31f6" state=present
- name: Ensure interface enp1s0 is used by re6st
lineinfile: dest=/etc/re6stnet/re6stnet.conf line="interface enp1s0" state=present
- name: Ensure interface ue1-pdn0 is used by re6st
lineinfile: dest=/etc/re6stnet/re6stnet.conf line="interface ue1-pdn0" state=present
- name: Ensure interface ue1-pdn0 is configured as RTT supporting link
blockinfile: |
dest=/etc/re6stnet/re6stnet.conf
content='
B-C
B"interface ue1-pdn0 type tunnel"'
# Slapos # Slapos
...@@ -97,6 +107,9 @@ ...@@ -97,6 +107,9 @@
- name: Copy init-mme script - name: Copy init-mme script
copy: src=init-mme dest=/opt/amarisoft owner=root mode=770 copy: src=init-mme dest=/opt/amarisoft owner=root mode=770
- name: Copy init-ue script
copy: src=init-ue dest=/opt/amarisoft owner=root mode=770
- name: Copy rm-tmp-lte script - name: Copy rm-tmp-lte script
copy: src=rm-tmp-lte dest=/opt/amarisoft owner=root mode=770 copy: src=rm-tmp-lte dest=/opt/amarisoft owner=root mode=770
...@@ -142,6 +155,21 @@ ...@@ -142,6 +155,21 @@
script: configure-sudoers script: configure-sudoers
# Network # Network
- name: Get ethernet interface name
script: get-eth-interface
register: eth_interface
- name: Get re6stnet second /64 range
script: get-re6st-second-64-range
register: re6st_second_range
- name: Configure /etc/systemd/network/ors.network
template:
src: systemd-ors-network.j2
dest: /etc/systemd/network/ors.network
- name: Remove old /etc/systemd/network/dhcp.network
file: path=/etc/systemd/network/dhcp.network state=absent
- name: Configure firewall - name: Configure firewall
script: configure-firewall script: configure-firewall
......
[Match]
Name=en*
[Network]
DHCP=yes
[Match]
name={{ eth_interface.stdout }}
[Network]
Address={{ re6st_second_range.stdout }}1/64
007dcca4a3c2afdb420092f8b3c7795d2a7c1552efac2bc3635d65ddd8a01dff - 711a63ffbf68a76a43290aada8cb0281391f589ffebe4401e2c8531176b7fe2a -
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment