Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -ex |
| 4 | |
| 5 | IETF_HW_STATE=0 |
| 6 | YANG_ROADM=0 |
| 7 | YANG_COHERENT=0 |
| 8 | YANG_INLINE=0 |
| 9 | YANG_CALIBRATION=0 |
| 10 | |
| 11 | YANG_DIR=/usr/share/cla-sysrepo/yang |
| 12 | REPO=/etc/sysrepo/yang |
| 13 | |
| 14 | for ARG in $(cat /proc/cmdline); do |
| 15 | case "${ARG}" in |
| 16 | czechlight=*) |
| 17 | CZECHLIGHT="${ARG:11}" |
| 18 | ;; |
| 19 | esac |
| 20 | done |
| 21 | |
| 22 | case "${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 | ;; |
| 44 | esac |
| 45 | |
| 46 | if [[ ${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 |
| 50 | fi |
| 51 | |
| 52 | if [[ ${YANG_ROADM} == 1 && ! -f ${REPO}/czechlight-roadm-device@2019-09-30.yang ]]; then |
Jan Kundrát | cf5dd8a | 2020-11-05 15:59:11 +0100 | [diff] [blame] | 53 | sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/czechlight-roadm-device@2019-09-30.yang |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 54 | 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" |
| 59 | fi |
| 60 | |
| 61 | if [[ ${YANG_COHERENT} == 1 && ! -f ${REPO}/czechlight-coherent-add-drop@2019-09-30.yang ]]; then |
Jan Kundrát | cf5dd8a | 2020-11-05 15:59:11 +0100 | [diff] [blame] | 62 | sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/czechlight-coherent-add-drop@2019-09-30.yang |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 63 | 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" |
| 65 | fi |
| 66 | |
| 67 | if [[ ${YANG_INLINE} == 1 && ! -f ${REPO}/czechlight-inline-amp@2019-09-30.yang ]]; then |
Jan Kundrát | cf5dd8a | 2020-11-05 15:59:11 +0100 | [diff] [blame] | 68 | sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/czechlight-inline-amp@2019-09-30.yang |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 69 | 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" |
| 71 | fi |
| 72 | |
| 73 | if [[ ${YANG_CALIBRATION} == 1 && ! -f ${REPO}/czechlight-calibration-device@2019-06-25.yang ]]; then |
Jan Kundrát | cf5dd8a | 2020-11-05 15:59:11 +0100 | [diff] [blame] | 74 | sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/czechlight-calibration-device@2019-06-25.yang |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 75 | 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" |
| 77 | fi |
| 78 | |
Jan Kundrát | cf5dd8a | 2020-11-05 15:59:11 +0100 | [diff] [blame] | 79 | if [[ ! -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át | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 85 | sysrepoctl --change czechlight-lldp --permissions 0664 --apply |
| 86 | fi |
| 87 | |
| 88 | mkdir -p /cfg/etc/sysrepo/ |
| 89 | cp -a /etc/sysrepo/data /etc/sysrepo/yang /cfg/etc/sysrepo/ |