Commit 76d0bc0e authored by Joanne Hugé's avatar Joanne Hugé

wip

parent 264ee12d
#!/bin/bash
DIR=$(dirname $(realpath $0))
AMARISOFT_DIR=$1
AMARISOFT_VERSION=$2
mkdir -p /etc/sudoers.d
COMMAND_LIST=("rm-tmp-lte" "init-enb" "init-mme" "init-sdr" "get-sdr-info")
PARTITION_AMOUNT="$(sed -n 's/partition_amount = \(.*\)/\1/gp' /etc/opt/slapos/slapos.cfg)"
......@@ -7,7 +10,7 @@ for c in "${COMMAND_LIST[@]}"; do
if [ "$SLAPUSER_LINES" != "$PARTITION_AMOUNT" ]; then
echo "Configuring /etc/sudoers.d/slapuser-$c..."
for i in $(seq 0 $(($PARTITION_AMOUNT-1))); do
echo "slapuser$i ALL=NOPASSWD:/opt/amarisoft/$c" >> slapuser-$c
echo "slapuser$i ALL=NOPASSWD:$AMARISOFT_DIR/$c" >> slapuser-$c
done
mv slapuser-$c /etc/sudoers.d/
chmod 440 /etc/sudoers.d/slapuser-$c
......@@ -15,11 +18,10 @@ for c in "${COMMAND_LIST[@]}"; do
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\}.*[0-9]*$" | 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
echo "slapuser$i ALL=NOPASSWD:$AMARISOFT_PATH/trx_sdr/sdr_util -c 0 version" >> slapuser-$c
echo "slapuser$i ALL=NOPASSWD:$AMARISOFT_DIR/$AMARISOFT_VERSION/trx_sdr/sdr_util -c 0 version" >> slapuser-$c
done
mv slapuser-$c /etc/sudoers.d/
chmod 440 /etc/sudoers.d/slapuser-$c
......
......@@ -18,14 +18,20 @@
- name: Create {{ amarisoft_dir }} directory
file: path={{ amarisoft_dir }} state=directory mode=0755
- name: Copy get-amarisoft-info script
copy: src=get-amarisoft-info dest={{ amarisoft_dir }} owner=root mode=555
- name: Render get-amarisoft-info script
template:
src: get-amarisoft-info.j2
dest: {{ amarisoft_dir }}/get-amarisoft-info
- name: Copy get-license-info script for backwards compatibility
copy: src=get-amarisoft-info dest={{ amarisoft_dir }}/get-license-info owner=root mode=555
- name: Render get-license-info script for backwards compatibility
template:
src: get-amarisoft-info.j2
dest: {{ amarisoft_dir }}/get-license-info
- name: Copy init-sdr script
copy: src=init-sdr dest={{ amarisoft_dir }} owner=root mode=550
- name: Render init-sdr script
template:
src: init-sdr.j2
dest: {{ amarisoft_dir }}/init-sdr
- name: Copy init-enb script
copy: src=init-enb dest={{ amarisoft_dir }} owner=root mode=550
......@@ -359,7 +365,7 @@
ignore_errors: yes
- name: Configure sudoers
script: configure-sudoers
script: configure-sudoers {{ amarisoft_dir }}
# Network
......
......@@ -5,11 +5,13 @@ import argparse, os, re, sys
parser = argparse.ArgumentParser()
parser.add_argument('-e', '--expiration', action='store_true')
parser.add_argument('-v', '--version', action='store_true')
parser.add_argument('-o', '--old-version', action='store_true')
args = parser.parse_args()
amarisoft_dir = '/opt/amarisoft'
amarisoft_dir = "{{ amarisoft_dir }}"
try:
lte_version = sorted(filter(lambda x: re.match(r"v[0-9]{4}-[0-9]{2}-[0-9]{2}", x), os.listdir(amarisoft_dir)))[-1][1:]
old_lte_version = sorted(filter(lambda x: re.match(r"v2021-[0-9]{2}-[0-9]{2}", x), os.listdir(amarisoft_dir)))[-1][1:]
except FileNotFoundError:
lte_version = 'Unknown'
lte_expiration = "Unknown"
......@@ -28,3 +30,5 @@ if args.expiration:
print(lte_expiration, end='')
elif args.version:
print(lte_version, end='')
elif args.old_version:
print(old_lte_version, end='')
#!/bin/bash
OLD_AMARISOFT_PATH="/opt/amarisoft/$(ls -1 /opt/amarisoft | grep "^v2021-[0-9]\{2\}-[0-9]\{2\}.*[0-9]*$" | sort | tail -n1)"
AMARISOFT_PATH="/opt/amarisoft/$(ls -1 /opt/amarisoft | grep "^v[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.*[0-9]*$" | sort | tail -n1)"
DIR=$(dirname $(realpath $0))
OLD_AMARISOFT_PATH={{ amarisoft_dir }}/$($DIR/get-amarisoft-info -o)
AMARISOFT_PATH={{ amarisoft_dir }}/$($DIR/get-amarisoft-info -v)
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
lsmod | grep -q sdr && rmmod sdr;
......
---
install_folder: "/opt/amarisoft"
amarisoft_version: "2023-06-10"
launch_upgrader: True
playbook_report: True
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