WD MyCloud gen1 2TB virgin disk image

Hi everyone,

This is my first post on this forum.
I want to replace hard disk in my old WD MyCloud 2TB device to a 4TB one (Seagate Ironwolf, if it matters). Now I’m on firmware v04.05.00-342.

According to the topic from WSGVET I try to do my own virgin image but there’s some error when I typing even first command.
https://community.wd.com/t/how-can-i-make-the-virgin-disk-imgae-of-my-cloud-2tb/91142

When I type:

/usr/local/sbin/factoryRestore.sh noreformat

I get this error:

/usr/local/sbin/deleteDeviceInfo.sh: line 22: cs_status: command not found

Here is the text inside this deleteDeviceInfo.sh file:

#!/bin/bash

###set -x

#© 2015 Western Digital Technologies, Inc. All rights reserved.

#deleteDeviceInfo.sh
#This script deletes device info from the central server

PATH=/sbin:/bin/:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
TMP_FILE=$(mktemp)

#Inquiry status of Central Server.
check_cs_status()
{
cs_status_url="“http://wd2go.com/api/1.0/rest/remote_access_status”"
http_response=(curl -s -w %{http_code} {cs_status_url} -o {TMP_FILE}) if [ {http_response} != 200 ]; then
wdlog -s {0} -l WARN -m {0} error:string=“cs:remote_access_status failed” code:int=$http_response
cs_status = “unknown”
fi

   v_action=$( grep -o '<action>.*</action>' ${TMP_FILE} | sed 's/\(<action>\|<\/action>\)//g')
   v_wait_time=$( grep -o '<wait_time>.*</wait_time>' ${TMP_FILE} | sed 's/\(<wait_time>\|<\/wait_time>\)//g')

   case $v_action in
           proceed)
                   cs_status="online"
                   ;;
           wait)
                   sleep $v_wait_time
                   cs_status="waited"
                   ;;
           *)
                   cs_status="unknown"
                   wdlog -s ${0} -l WARN -m ${0} error:string="remote_access_status: unknown"
           ;;
   esac

}

#delete device info on Central Server
delete_device_info()
{
#Inquiry device ID and authorization token
dev_id_url="http://localhost/api/2.1/rest/config?format=xml&rest_method=get&config_id=dynamicconfig&module=config&par$
http_response=(curl -s -w %{http_code} {dev_id_url} -o {TMP_FILE}) if [ {http_response} != 200 ]; then
wdlog -s {0} -l WARN -m {0} error:string=“get DEVICEID failed” code:int=http_response return 1 fi v_dev_id=(grep -o ‘.*’ ${TMP_FILE} | sed ‘s/(|</value>)//g’)

   dev_token_url="http://localhost/api/2.1/rest/config?format=xml&rest_method=get&config_id=dynamicconfig&module=config&$
   http_response=$(curl -s -w %{http_code} ${dev_token_url} -o ${TMP_FILE})

Could anyone help me with this?
I’m doing it of course on root account via SSH (Putty).

Best regards to everyone
Pawel