diff --git a/common/scripts/generate_keys.sh b/common/scripts/generate_keys.sh index e9147f638..500de7037 100755 --- a/common/scripts/generate_keys.sh +++ b/common/scripts/generate_keys.sh @@ -15,6 +15,8 @@ output_path="/opt" # list the available slots and check if the token label exists token_label="secccoms" +slot_id="" +free_slot_id="" ### Check if a directory does not exist ### if [ ! -d "$output_path" ] @@ -22,6 +24,12 @@ then mkdir -p "$output_path" fi +set_openssl_env() +{ + export OPENSSL_CONF=/opt/comms_openssl.cnf + echo "OPENSSL_CONF=$OPENSSL_CONF" +} + initialize_hsm() { #add line at the beginning of the file @@ -81,12 +89,63 @@ else pin=$(tr -dc '0-9' $LOG_FILE 2>&1" + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} +stop() { + printf 'Stopping %s: ' "$DAEMON" + start-stop-daemon -K -q -p "$PIDFILE" + status=$? + if [ "$status" -eq 0 ]; then + rm -f "$PIDFILE" + echo "OK" + else + echo "FAIL" + fi + return "$status" +} +restart() { + stop + sleep 1 + start +} +case "$1" in + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac + +exit 0 diff --git a/modules/utils/docker/entrypoint_nats.sh b/modules/utils/docker/entrypoint_nats.sh index 77a6dc28d..a374042bb 100755 --- a/modules/utils/docker/entrypoint_nats.sh +++ b/modules/utils/docker/entrypoint_nats.sh @@ -35,7 +35,34 @@ else echo "starting provisioning agent" # blocks execution until provisioning is done or timeout (30s) # IP address and port are passed as arguments and hardcoded. TODO: mDNS - python /opt/nats/src/comms_provisioning.py -t 30 -s 192.168.1.254 -p 8080 -o /opt > /opt/comms_provisioning.log 2>&1 + + # TODO commented out to test ms1.5 + #python /opt/nats/src/comms_provisioning.py -t 30 -s 192.168.1.254 -p 8080 -o /opt > /opt/comms_provisioning.log 2>&1 + + ############### 1.5 begin ############### + + # TODO: move this copy to mesh_start.sh, currently for debugging purposes + if [ ! -f "/opt/S90MS15" ]; then + + # TODO: remove this when the root cert is provided by the provisioning server + MESH_FOLDER="/opt/mesh_com" + ROOT_CERT="$MESH_FOLDER/modules/sc-mesh-secure-deployment/src/1_5/common/test/root_cert.der" + cp "$ROOT_CERT" "/etc/ssl/certs/" + # TODO: modify it to provisoning server root + /opt/mesh_com/common/scripts/generate_keys.sh + + # TODO: remove whole installation step when need libraries are included in host image + # install the python packages + install_python_packages + meshcom_path="/opt/mesh_com/" + cp $meshcom_path/modules/sc-mesh-secure-deployment/src/nats/initd/S90MS15 /opt/. + cp -r $meshcom_path/modules/sc-mesh-secure-deployment/src/1_5/. /opt/. + chmod +x /opt/S90MS15 + fi + cd /opt/ + /opt/S90MS15 start + + ############### 1.5 end ############### echo "Start nats server and client nodes" /opt/S90nats_discovery start