|
<!DOCTYPE html><html><head><title>WD MyCloud - Delete Public Share</title><meta charset='utf-8'><link href='https://d31qtcb7c58z3n.cloudfront.net/res-min/themes/marxico.css' rel='stylesheet'></head><body><div id='preview-contents' class='note-content'> |
|
<div id="wmd-preview" class="preview-content"></div> |
|
<div id="wmd-preview-section-46509" class="wmd-preview-section preview-content"> |
|
|
|
</div><div id="wmd-preview-section-47688" class="wmd-preview-section preview-content"> |
|
|
|
<h2 id="wd-mycloud-delete-public-share"><center>WD MyCloud - Delete Public Share</center></h2> |
|
<img style="float:right" src="http://i.imgur.com/dyz3EVt.png"/> |
|
|
|
<hr> |
|
|
|
<p> </p> |
|
|
|
<p>This is a step by step guide for <strong>removing the public share from a WD MyCloud NAS</strong> device. My devices are on the latest firmware so you may find some slight differences if you are on an older firmware or have different devices then I have. Hopefully the info here will allow you to jump over that hurdle. I have tried to explain where things may be different and how to handle them but I don’t have every MyCloud device. Please understand that you are invalidating your warranty and could possibly mess up or brick your hardware (If your here probably not). You will need to login to your MyCloud via SSH to make these changes. </p> |
|
|
|
<p>I have taken the time to make a fairly detailed guide but feel free to skip ahead and go for the Quick and Easy way it you understand what you are doing. <a href="#1">Skip the Instructions and Get to the Scripts</a></p> |
|
|
|
|
|
|
|
<hr> |
|
|
|
<blockquote> |
|
<h3 id="table-of-contents"><center><strong>Table of Contents</strong></center></h3> |
|
|
|
<div><div class="toc"><div class="toc"> |
|
<ul> |
|
<li><ul> |
|
<li><a href="#wd-mycloud-delete-public-share">WD MyCloud - Delete Public Share</a><ul> |
|
<li><a href="#table-of-contents">Table of Contents</a></li> |
|
<li><a href="#1-backup-the-system-files-that-we-will-modify">1. Backup the System Files that we will Modify</a></li> |
|
<li><a href="#2-prevent-wd-mycloud-from-re-creating-the-public-share">2. Prevent WD MyCloud from Re-Creating the Public Share</a></li> |
|
<li><a href="#3-prevent-directory-structure-creation">3. Prevent Directory Structure Creation</a></li> |
|
<li><a href="#4-delete-the-public-share">4. Delete the Public share</a></li> |
|
<li><a href="#5-remove-public-folder-from-smb-config">5. Remove Public Folder from SMB Config</a></li> |
|
<li><a href="#6-restart-the-samba-service">6. Restart the Samba Service</a></li> |
|
<li><a href="#7-the-quick-way-scripts">7. The Quick Way - Scripts</a></li> |
|
<li><a href="#8-restore-the-public-folder">8. Restore the Public Folder</a></li> |
|
</ul> |
|
</li> |
|
</ul> |
|
</li> |
|
</ul> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<p><br></p> |
|
</blockquote> |
|
|
|
<hr></div><div id="wmd-preview-section-44035" class="wmd-preview-section preview-content"> |
|
|
|
<h3 id="1-backup-the-system-files-that-we-will-modify">1. Backup the System Files that we will Modify</h3></div><div id="wmd-preview-section-36203" class="wmd-preview-section preview-content"> |
|
|
|
<pre class="prettyprint hljs-dark"><code class="language-bash hljs"> /bin/cp /etc/wdcomp.d/boot/bootscript_005_wd-nas /root/bootscript_005_wd-nas.bkup <br> /bin/cp /usr/<span class="hljs-built_in">local</span>/sbin/createDataVolume.sh /root/createDataVolume.sh.bkup<br> /bin/cp /etc/samba/overall_share /root/overall_share.bkup<br></code></pre></div><div id="wmd-preview-section-44056" class="wmd-preview-section preview-content"> |
|
|
|
<h3 id="2-prevent-wd-mycloud-from-re-creating-the-public-share">2. Prevent WD MyCloud from Re-Creating the Public Share</h3> |
|
|
|
<p><sub> This script runs at boottime and creates a new Public share if one is not found.</sub> <br> |
|
<br></p> |
|
|
|
<p><strong>Comment out the following lines from –</strong> <code>/etc/wdcomp.d/boot//bootscript_005_wd-nas</code></p> |
|
|
|
<ul><li>To comment out a line in a bash script simply prepend a <strong><code>#</code></strong> sign to the beginning of the line.</li> |
|
</ul></div><div id="wmd-preview-section-31300" class="wmd-preview-section preview-content"> |
|
|
|
<pre class="prettyprint hljs-dark"><code class="language-bash hljs">><span class="hljs-number">209</span> uniqShareName=$(createUniqueShare <span class="hljs-string">"Public"</span> <span class="hljs-string">"Public"</span> <span class="hljs-string">"any"</span>)<span class="hljs-string">" <br>>210 result=$? <br>>211 if [<span class="hljs-variable">$result</span> -eq 0]; then <br>>212 logger -s -p local2.debug "</span><span class="hljs-variable">$0</span>: DEBUG: createUniqueShare <span class="hljs-variable">${uniqShareName}</span> returned$ <br>><span class="hljs-number">213</span> <span class="hljs-keyword">else</span> <br>><span class="hljs-number">214</span> logger <span class="hljs-operator">-s</span> -p <span class="hljs-built_in">local</span>2.err <span class="hljs-string">"<span class="hljs-variable">$0</span>: ERROR: createUniqueShare <span class="hljs-variable">${uniqShareName}</span> returned $$ <br>>215 fi </span><br></code></pre> |
|
|
|
<p><strong>Comment out lines 209-215:</strong> <strong><code>sed -i '209,215 s/^/#/' /etc/wdcomp.d/boot/bootscript_005_wd-nas</code></strong></p> |
|
|
|
</div><div id="wmd-preview-section-44077" class="wmd-preview-section preview-content"> |
|
|
|
<h3 id="3-prevent-directory-structure-creation">3. Prevent Directory Structure Creation</h3> |
|
|
|
<p>The next script creates the folder structure for the Public share. Now that the public share is not going to exist we need to prevent the script from running into errors.</p> |
|
|
|
<p><strong>Comment out the folowing lines from – <em>*</em></strong><code>/usr/local/sbin/createDataVolume.sh</code>*</p></div><div id="wmd-preview-section-31303" class="wmd-preview-section preview-content"> |
|
|
|
<pre class="prettyprint hljs-dark"><code class="language-bash hljs">> mkdir -p <span class="hljs-string">"/DataVolume/shares/Public/Shared Music"</span><br>> mkdir -p <span class="hljs-string">"/DataVolume/shares/Public/Shared Videos"</span><br>> mkdir -p <span class="hljs-string">"/DataVolume/shares/Public/Shared Pictures"</span><br>> chown -R root:share /DataVolume/shares/Public<br></code></pre> |
|
|
|
</div><div id="wmd-preview-section-44117" class="wmd-preview-section preview-content"> |
|
|
|
<h3 id="4-delete-the-public-share">4. Delete the Public share</h3> |
|
|
|
<p><strong><em>Everything in the Public folder will be deleted for good. Make sure you have moved your data.</em></strong></p> |
|
|
|
<p><strong><sub> We are using WD MyClouds deleteShare script to remove the share since it does alot of the cleanup for us. Depending on what version firmware you have you might need to comment out a few lines in this file as well. But it won’t do any harm to try running it first. </sub></strong></p></div><div id="wmd-preview-section-37397" class="wmd-preview-section preview-content"> |
|
|
|
<pre class="prettyprint hljs-dark"><code class="language-bash hljs">/usr/<span class="hljs-built_in">local</span>/sbin/deleteShare.sh <span class="hljs-string">"Public"</span><br></code></pre> |
|
|
|
<p><strong>If you get an error: <code>Cannot delete Public share</code> then you need to comment out the following lines.</strong></p> |
|
|
|
</div><div id="wmd-preview-section-41985" class="wmd-preview-section preview-content"> |
|
|
|
<pre class="prettyprint hljs-dark"><code class="language-bash hljs">> lowerCaseShare=<span class="hljs-built_in">echo</span> <span class="hljs-variable">$shareName</span> | tr <span class="hljs-string">'[:upper:]'</span> <span class="hljs-string">'[:lower:]'</span><br>> <span class="hljs-keyword">if</span> [<span class="hljs-variable">$lowerCaseShare</span> == <span class="hljs-string">"public"</span>]; <span class="hljs-keyword">then</span><br>> <span class="hljs-built_in">echo</span> <span class="hljs-string">"Cannot delete Public share"</span><br>> <span class="hljs-built_in">exit</span> <span class="hljs-number">1</span><br>> <span class="hljs-keyword">fi</span><br></code></pre> |
|
|
|
<p><strong><em>Comments out the code causing the “Cannot delete Public share” error</em></strong> <br> |
|
<strong><code>sed -i '/echo \$shareName/ {N;N; /delete Public/ s/^/#!!#/}' /usr/local/sbin/deleteShare.sh</code></strong> <br> |
|
<strong><code>sed -i '/#!!#if/,+4 s/^/#/; s/#!!#//' /usr/local/sbin/deleteShare.sh</code></strong></p></div><div id="wmd-preview-section-44139" class="wmd-preview-section preview-content"> |
|
|
|
<h3 id="5-remove-public-folder-from-smb-config">5. Remove Public Folder from SMB Config</h3> |
|
|
|
<p><strong>Comment out the following lines from–<em>*</em></strong>/etc/samba/overall_share* <br> |
|
<sub> If your listing is slightly different that is okay. We just want to comment out the Public Share Settings </sub></p></div><div id="wmd-preview-section-38353" class="wmd-preview-section preview-content"> |
|
|
|
<pre class="prettyprint hljs-dark"><code class="language-bash hljs">> <span class="hljs-number">1</span> [Public]<br>> <span class="hljs-number">2</span> comment = Public<br>> <span class="hljs-number">3</span> path = /shares/Public<br>> <span class="hljs-number">4</span> browseable = yes<br>> <span class="hljs-number">5</span> public = yes<br>> <span class="hljs-number">6</span> available = yes<br>> <span class="hljs-number">7</span> oplocks = yes<br>> <span class="hljs-number">8</span> map archive = no<br>> <span class="hljs-number">9</span> guest ok = yes<br>> <span class="hljs-number">10</span> writable = yes<br></code></pre> |
|
|
|
<p><strong>Comment out lines 1-10: <code>sed -i '1,10 s/^/#/' overall_share</code></strong></p> |
|
|
|
</div><div id="wmd-preview-section-44179" class="wmd-preview-section preview-content"> |
|
|
|
<h3 id="6-restart-the-samba-service">6. Restart the Samba Service</h3></div><div id="wmd-preview-section-44009" class="wmd-preview-section preview-content"> |
|
|
|
<pre class="prettyprint hljs-dark"><code class="language-bash hljs">service samba restart<br></code></pre> |
|
|
|
<p><strong>Thats all there is to it. Check to ensure that you don’t see the Pubic Share in the WebUI or Network shares to confirm that it worked.</strong></p> |
|
|
|
<hr></div><div id="wmd-preview-section-46451" class="wmd-preview-section preview-content"> |
|
|
|
<h3 id="7-the-quick-way-scripts">7. The Quick Way - Scripts</h3> |
|
|
|
<p><strong>I've provided a remove and restore script that I've tested on my devices.</strong></p></div><div id="wmd-preview-section-41804" class="wmd-preview-section preview-content"> |
|
|
|
<p><code>curl -L https://gist.githubusercontent.com/codedecay/7d30df8d12b506407d26/raw | sh</code> |
|
|
|
<pre class="prettyprint hljs-dark"><code class="language-bash hljs"><span class="hljs-comment">#Backup Files</span><br>cp /etc/wdcomp.d/boot/bootscript_005_wd-nas /root/bootscript_005_wd-nas.bkup<br>cp /usr/<span class="hljs-built_in">local</span>/sbin/createDataVolume.sh /root/createDataVolume.bkup<br>cp /etc/samba/overall_share /root/overall_share.bkup<br><br><span class="hljs-comment">#Comment out relevant lines in the boot and create script.</span><br>sed -i <span class="hljs-string">'209,215 s/^/#/'</span> /etc/wdcomp.d/boot/bootscript_005_wd-nas<br>sed -i <span class="hljs-string">'23,25 s/^/#/'</span> /usr/<span class="hljs-built_in">local</span>/sbin/createDataVolume.sh<br>sed -i <span class="hljs-string">'29,29 s/^/#/'</span> /usr/<span class="hljs-built_in">local</span>/sbin/createDataVolume.sh<br><br><span class="hljs-comment">#Comment out validation in deleteShare.sh if it is present.</span><br>sed -i <span class="hljs-string">'/echo \$shareName/ {N;N; /delete Public/ s/^/#!!#/}'</span> /usr/<span class="hljs-built_in">local</span>/sbin/deleteShare.sh <br>sed -i <span class="hljs-string">'/#!!#if/,+4 s/^/#/; s/#!!#//'</span> /usr/<span class="hljs-built_in">local</span>/sbin/deleteShare.sh`<br><br><span class="hljs-comment">#Delete the public share</span><br>/usr/<span class="hljs-built_in">local</span>/sbin/deleteShare.sh <span class="hljs-string">"Public"</span><br><br><span class="hljs-comment">#Comment out the public share definition from the Samba config.</span><br>sed -i <span class="hljs-string">'1,10 s/^/#/'</span> /etc/samba/overall_share<br><br><span class="hljs-comment">#Restart the samba service.</span><br>service samba restart<br></code></pre></div><div id="wmd-preview-section-46982" class="wmd-preview-section preview-content"> |
|
|
|
<h3 id="8-restore-the-public-folder">8. Restore the Public Folder</h3> |
|
|
|
<p><code>curl -L https://gist.github.com/codedecay/02e5dc3d487a38d0a89f/raw | sh</code></p></div><div id="wmd-preview-section-45250" class="wmd-preview-section preview-content"> |
|
|
|
<pre class="prettyprint hljs-dark"><code class="language-bash hljs"><span class="hljs-comment">#Either Restore from your backup files..</span><br>/bin/cp /root/bootscript_005_wd-nas.bkup /etc/wdcomp.d/boot/bootscript_005_wd-nas<br>/bin/cp /root/createDataVolume.bkup /usr/<span class="hljs-built_in">local</span>/sbin/createDataVolume.sh<br>/bin/cp /root/deleteShare.bkup /usr/<span class="hljs-built_in">local</span>/sbin/deleteShare.sh<br>/bin/cp /root/overall_share.bkup /etc/samba/overall_share<br><br><span class="hljs-comment">#Or undo the comments in the existing files.</span><br>sed -i <span class="hljs-string">'209,215 s/^#//'</span> /etc/wdcomp.d/boot/bootscript_005_wd-nas<br>sed -i <span class="hljs-string">'23,25 s/^#//'</span> /usr/<span class="hljs-built_in">local</span>/sbin/createDataVolume.sh<br>sed -i <span class="hljs-string">'29,29 s/^#//'</span> /usr/<span class="hljs-built_in">local</span>/sbin/createDataVolume.sh<br>sed -i <span class="hljs-string">'1,10 s/^#//'</span> /etc/samba/overall_share<br>sed -i <span class="hljs-string">'/#if.*shareName/,+4 s/#//'</span> /usr/<span class="hljs-built_in">local</span>/sbin/deleteShare.sh<br><br><span class="hljs-comment">#Recreate the Public Share and Directory Structure</span><br>mkdir -p <span class="hljs-string">"/DataVolume/shares/Public"</span><br>mkdir -p <span class="hljs-string">"/DataVolume/shares/Public/Shared Music"</span><br>mkdir -p <span class="hljs-string">"/DataVolume/shares/Public/Shared Videos"</span><br>mkdir -p <span class="hljs-string">"/DataVolume/shares/Public/Shared Pictures"</span><br>chmod -R <span class="hljs-number">775</span> /DataVolume/shares<br>chown -R root:share /DataVolume/shares/Public<br><br><span class="hljs-comment">#Restart the samba service</span><br>service samba restart<br></code></pre> |
|
|
|
<hr></div><div id="wmd-preview-section-footnotes" class="preview-content"></div></div></body></html> |