developer | 15a4331 | 2022-04-12 11:23:23 +0800 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | ########################################################################## |
| 3 | # If not stated otherwise in this file or this component's Licenses.txt |
| 4 | # file the following copyright and licenses apply: |
| 5 | # |
| 6 | # Copyright 2020 RDK Management |
| 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | # you may not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
| 19 | ########################################################################## |
| 20 | |
| 21 | BINPATH="/usr/bin" |
| 22 | GET="dmcli eRT getv" |
| 23 | SET="" |
| 24 | |
| 25 | echo "Check parodusCmd.cmd in /tmp" |
| 26 | |
| 27 | if [ -e /tmp/parodusCmd.cmd ]; then |
| 28 | parodusCmd=`cat /tmp/parodusCmd.cmd` |
| 29 | $parodusCmd & |
| 30 | else |
| 31 | echo "parodusCmd.cmd does not exist in tmp" |
| 32 | echo "Fetching PAM Health status " |
| 33 | |
| 34 | while [ 1 ] |
| 35 | do |
| 36 | pamState=`$GET com.cisco.spvtg.ccsp.pam.Health | grep value| tr -s ' ' |cut -f5 -d" "` |
| 37 | if [ "$pamState" = "Green" ]; then |
| 38 | break |
| 39 | else |
| 40 | echo "Waiting for PAM to come up" |
| 41 | fi |
| 42 | sleep 10 |
| 43 | done |
| 44 | |
| 45 | echo "Fetching CMAgent Health status " |
| 46 | |
| 47 | |
| 48 | echo "Fetching values to form parodus command line arguments" |
| 49 | |
| 50 | ModelName=`$GET Device.DeviceInfo.ModelName | grep value| tr -s ' ' |cut -f5 -d" "` |
| 51 | SerialNumber=`$GET Device.DeviceInfo.SerialNumber | grep value| tr -s ' ' |cut -f5 -d" "` |
| 52 | Manufacturer=`$GET Device.DeviceInfo.Manufacturer | grep value| tr -s ' ' |cut -f5 -d" "` |
| 53 | HW_MAC=`$GET Device.X_CISCO_COM_CableModem.MACAddress | grep value| tr -s ' ' |cut -f5 -d" "` |
| 54 | HW_MAC=`ifconfig erouter0 | grep HWaddr | tr -s ' ' | cut -d ' ' -f5` |
| 55 | LastRebootReason=`$GET Device.DeviceInfo.X_RDKCENTRAL-COM_LastRebootReason | grep value| tr -s ' ' |cut -f5 -d" "` |
| 56 | FirmwareName=`$GET Device.DeviceInfo.X_CISCO_COM_FirmwareName | grep value| tr -s ' ' |cut -f5 -d" "` |
| 57 | BootTime=`$GET Device.DeviceInfo.X_RDKCENTRAL-COM_BootTime | grep value| tr -s ' ' |cut -f5 -d" "` |
| 58 | MaxPingWaitTimeInSec=180; |
| 59 | DeviceNetworkInterface="erouter0"; |
| 60 | ServerURL=http://54.166.121.187:8080; |
| 61 | BackOffMax=9; |
| 62 | PARODUS_URL=tcp://127.0.0.1:6666; |
| 63 | SSL_CERT_PATH=/etc/ssl/certs/ca-certificates.crt |
| 64 | |
| 65 | echo "Framing command for parodus" |
| 66 | |
| 67 | # command="/usr/bin/parodus --hw-model=$ModelName --hw-serial-number=$SerialNumber --hw-manufacturer=$Manufacturer --hw-mac=$HW_MAC --hw-last-reboot-reason=$LastRebootReason --fw-name=$FirmwareName --boot-time=$BootTime --webpa-ping-time=$MaxPingWaitTimeInSec --webpa-inteface-used=$DeviceNetworkInterface --webpa-url=$ServerURL --webpa-backoff-max=$BackOffMax" |
| 68 | command="/usr/bin/parodus --hw-model=$ModelName --hw-serial-number=$SerialNumber --hw-manufacturer=$Manufacturer --hw-last-reboot-reason=$LastRebootReason --fw-name=$FirmwareName --boot-time=$BootTime --hw-mac=$HW_MAC --webpa-ping-time=180 --webpa-interface-used=erouter0 --webpa-url=$ServerURL --webpa-backoff-max=$BackOffMax --parodus-local-url=$PARODUS_URL --partner-id=comcast --ssl-cert-path=$SSL_CERT_PATH --force-ipv4 " |
| 69 | |
| 70 | echo $command >/tmp/parodusCmd.cmd |
| 71 | |
| 72 | echo "Starting parodus with the following arguments" |
| 73 | echo "ModelName=$ModelName SerialNumber=$SerialNumber Manufacturer=$Manufacturer HW_MAC=$HW_MAC LastRebootReason=$LastRebootReason FirmwareName=$FirmwareName BootTime=$BootTime MaxPingWaitTimeInSec=$MaxPingWaitTimeInSec DeviceNetworkInterface=$DeviceNetworkInterface ServerURL=$ServerURL BackOffMax=$BackOffMax" |
| 74 | |
| 75 | $command & |
| 76 | fi |