Commit c1332e4f authored by Joanne Hugé's avatar Joanne Hugé

ors-amarisoft: update playbook and run it after reboot

parent 5920d2c3
#!/bin/bash
CONF="/etc/default/grub"
BAK="/tmp/default.grub"
cp $CONF $BAK;
if ! grep -q idle=halt /proc/cmdline; then
sed -i 's/^\(GRUB_CMDLINE_LINUX_DEFAULT.*\)idle=[a-z]* *\(.*\)/\1\2/g' $CONF;
sed -i 's/^\(GRUB_CMDLINE_LINUX_DEFAULT.*\)"/\1 idle=halt"/g' $CONF;
if ! update-grub; then
cp $BAK $CONF;
update-grub;
fi
fi
rm -f $BAK;
#!/bin/bash
CONF="/etc/network/interfaces"
BAK="/tmp/interfaces.$(date +%s)"
IFACE="$(ip route | grep default | sed 's/.*dev \(\w*\)\( .*$\|$\)/\1/g')"
cp $CONF $BAK;
if ! grep -q ip6tables $CONF; then
sed -i 's#^\(\s*post-up \)iptables\(.*\)$#\1iptables\2\n\1ip6tables\2#g' $CONF;
fi
if ! ifup --no-act $IFACE; then
cp $BAK $CONF;
fi
rm -rf $BAK;
CONF="/etc/re6stnet/re6stnet.conf"
sed -i '/^interface/d' $CONF
echo "interface $IFACE" >> $CONF
if ! ps -ax -o cmd | grep babeld | grep -q $IFACE; then
# Don't run re6st with interface option at Lille Office
if ping6 -q -c2 -w3 fe80::20d:b9ff:fe3f:9055%$IFACE; then
systemctl stop re6stnet;
elif ! ps -ax -o cmd | grep babeld | grep -q $IFACE; then
systemctl restart re6stnet;
fi
#!/bin/bash
CONF="/etc/ssh/sshd_config"
if ! grep -q "^PermitRootLogin yes$" $CONF; then
sed -i '/^PermitRootLogin/d' $CONF;
echo "PermitRootLogin yes" >> $CONF;
systemctl restart sshd;
fi
if ! grep -q "^PasswordAuthentication yes$" $CONF; then
sed -i '/^PasswordAuthentication/d' $CONF;
echo "PasswordAuthentication yes" >> $CONF;
systemctl restart sshd;
fi
#!/bin/sh
### BEGIN INIT INFO
# Provides: Init SDR
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Init SDR
### END INIT INFO
case "$1" in
start)
cd /root/trx_sdr/kernel;
make clean;
bash init.sh 2>> /opt/amarisoft/init-sdr.log >> /opt/amarisoft/init-sdr.log
/opt/amarisoft/v2022-07-29/lteenb-linux-2022-07-29/lte_init.sh 2>> /opt/amarisoft/init-sdr.log >> /opt/amarisoft/init-sdr.log
;;
*)
true
esac
cd /root/trx_sdr/kernel;
make clean;
bash init.sh 2>> /opt/amarisoft/init-sdr.log >> /opt/amarisoft/init-sdr.log
$(find /opt/amarisoft -type f -wholename "*v*/*lteenb*/*lte_init.sh*") 2>> /opt/amarisoft/init-sdr.log >> /opt/amarisoft/init-sdr.log
auto lo
iface lo inet loopback
auto enp2s0
iface enp2s0 inet dhcp
post-up echo 1 > /proc/sys/net/ipv4/conf/all/forwarding
post-up iptables -t nat -A POSTROUTING -o enp2s0 -j MASQUERADE
post-up ip6tables -t nat -A POSTROUTING -o enp2s0 -j MASQUERADE
auto enp0s31f6
iface enp0s31f6 inet dhcp
post-up echo 1 > /proc/sys/net/ipv4/conf/all/forwarding
post-up iptables -t nat -A POSTROUTING -o enp0s31f6 -j MASQUERADE
post-up ip6tables -t nat -A POSTROUTING -o enp0s31f6 -j MASQUERADE
......@@ -12,17 +12,23 @@
- name: Give permission to slapuser to remove tmp files owned by other slapuser
copy: src=slapuser-rm-tmp dest=/etc/sudoers.d owner=root mode=440
- name: Add init-sdr service
copy: src=init-sdr dest=/etc/init.d owner=root mode=755
- name: Init SDR
script: init-sdr.sh
- name: Enable init-sdr
systemd: name=init-sdr enabled=yes
- name: Configure re6st
script: configure-re6st.sh
- name: Configure network
script: configure-network.sh
- name: Configure /etc/network/interfaces
copy: src=interfaces dest=/etc/network/interfaces owner=root mode=644
- name: Configure dhcp timeout
lineinfile: dest=/etc/dhcp/dhclient.conf regexp="^timeout (.*)" line="timeout 15" state=present
- name: Configure ssh
lineinfile: dest=/etc/ssh/sshd_config regexp="^PermitRootLogin (.*)" line="PermitRootLogin yes" state=present
- name: Configure ssh
script: configure-ssh.sh
lineinfile: dest=/etc/ssh/sshd_config regexp="^PasswordAuthentication (.*)" line="PasswordAuthentication yes" state=present
- name: Configure slapos
script: configure-slapos.py
......@@ -32,3 +38,6 @@
- name: Copy keys for SR
copy: src=/root/.amarisoft dest=/opt/amarisoft owner=root mode=644
- name: Add kernel parameter
script: configure-grub.sh
---
- name: Install upgrader
shell: ansible-playbook upgrader-run.yml --extra-vars "upgrader_playbook=ors-upgrade.yml upgrade_kernel=False"
- name: Set Cron
cron: name="Launch Startup with ansible" special_time=reboot job='cd /opt/upgrader/playbook && ansible-playbook ors-upgrade.yml -i hosts 2>>/opt/upgrader/startup.log >> /opt/upgrader/startup.log'
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