blob: 6585b548cf2c3cc5e20f9eeb1d007c963034ed2b [file] [log] [blame]
Jan Kundrát2f100fc2020-11-02 22:10:16 +01001#!/bin/bash
2
3set -ex
4
5IETF_HW_STATE=0
6YANG_ROADM=0
7YANG_COHERENT=0
8YANG_INLINE=0
9YANG_CALIBRATION=0
10
11YANG_DIR=/usr/share/cla-sysrepo/yang
12REPO=/etc/sysrepo/yang
13
14for ARG in $(cat /proc/cmdline); do
15 case "${ARG}" in
16 czechlight=*)
17 CZECHLIGHT="${ARG:11}"
18 ;;
19 esac
20done
21
22case "${CZECHLIGHT}" in
23 sdn-roadm-line)
24 YANG_ROADM=1
25 WITH_FEATURE=hw-line-9
26 IETF_HW_STATE=1
27 ;;
28 sdn-roadm-add-drop)
29 YANG_ROADM=1
30 WITH_FEATURE=hw-add-drop-20
31 IETF_HW_STATE=1
32 ;;
33 sdn-roadm-coherent-a-d)
34 IETF_HW_STATE=1
35 YANG_COHERENT=1
36 ;;
37 sdn-inline)
38 IETF_HW_STATE=1
39 YANG_INLINE=1
40 ;;
41 calibration-box)
42 YANG_CALIBRATION=1
43 ;;
44esac
45
46if [[ ${IETF_HW_STATE} == 1 && ! -f ${REPO}/ietf-hardware-state@2018-03-13.yang ]]; then
47 sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/iana-hardware@2018-03-13.yang
48 sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/ietf-hardware-state@2018-03-13.yang
49 sysrepoctl --change ietf-hardware-state --permissions 0664 --enable-feature hardware-sensor --apply
50fi
51
52if [[ ${YANG_ROADM} == 1 && ! -f ${REPO}/czechlight-roadm-device@2019-09-30.yang ]]; then
Jan Kundrátcf5dd8a2020-11-05 15:59:11 +010053 sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/czechlight-roadm-device@2019-09-30.yang
Jan Kundrát2f100fc2020-11-02 22:10:16 +010054 sysrepoctl --change czechlight-roadm-device --group optics --permissions 0664 --apply
55 if [[ ${WITH_FEATURE} ]]; then
56 sysrepoctl --change czechlight-roadm-device --enable-feature ${WITH_FEATURE}
57 fi
58 sysrepocfg --datastore=startup --format=json --module=czechlight-roadm-device --import="${YANG_DIR}/${CZECHLIGHT}.json"
59fi
60
61if [[ ${YANG_COHERENT} == 1 && ! -f ${REPO}/czechlight-coherent-add-drop@2019-09-30.yang ]]; then
Jan Kundrátcf5dd8a2020-11-05 15:59:11 +010062 sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/czechlight-coherent-add-drop@2019-09-30.yang
Jan Kundrát2f100fc2020-11-02 22:10:16 +010063 sysrepoctl --change czechlight-coherent-add-drop --group optics --permissions 0664 --apply
64 sysrepocfg --datastore=startup --format=json --module=czechlight-coherent-add-drop --new-data="${YANG_DIR}/${CZECHLIGHT}.json"
65fi
66
67if [[ ${YANG_INLINE} == 1 && ! -f ${REPO}/czechlight-inline-amp@2019-09-30.yang ]]; then
Jan Kundrátcf5dd8a2020-11-05 15:59:11 +010068 sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/czechlight-inline-amp@2019-09-30.yang
Jan Kundrát2f100fc2020-11-02 22:10:16 +010069 sysrepoctl --change czechlight-inline-amp --group optics --permissions 0664 --apply
70 sysrepocfg --datastore=startup --format=json --module=czechlight-inline-amp --import="${YANG_DIR}/${CZECHLIGHT}.json"
71fi
72
73if [[ ${YANG_CALIBRATION} == 1 && ! -f ${REPO}/czechlight-calibration-device@2019-06-25.yang ]]; then
Jan Kundrátcf5dd8a2020-11-05 15:59:11 +010074 sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/czechlight-calibration-device@2019-06-25.yang
Jan Kundrát2f100fc2020-11-02 22:10:16 +010075 sysrepoctl --change czechlight-calibration-device --group optics --permissions 0664 --apply
76 sysrepocfg --datastore=startup --format=json --module=czechlight-calibration-device --import="${YANG_DIR}/${CZECHLIGHT}.json"
77fi
78
Jan Kundrátcf5dd8a2020-11-05 15:59:11 +010079if [[ ! -f ${REPO}/czechlight-lldp@2020-11-04.yang ]]; then
80 if compgen -G "${REPO}/czechlight-lldp@*.yang" >/dev/null; then
81 sysrepoctl --search-dirs /usr/share/lldp-systemd-networkd-sysrepo/yang --update /usr/share/lldp-systemd-networkd-sysrepo/yang/czechlight-lldp@2020-11-04.yang
82 else
83 sysrepoctl --search-dirs /usr/share/lldp-systemd-networkd-sysrepo/yang --install /usr/share/lldp-systemd-networkd-sysrepo/yang/czechlight-lldp@2020-11-04.yang
84 fi
Jan Kundrát2f100fc2020-11-02 22:10:16 +010085 sysrepoctl --change czechlight-lldp --permissions 0664 --apply
86fi
87
88mkdir -p /cfg/etc/sysrepo/
89cp -a /etc/sysrepo/data /etc/sysrepo/yang /cfg/etc/sysrepo/