##WD MyCloud - Delete Public Share
Guide and scripts to remove or restore the public share on WD My Cloud.
Remove Public Share from WD MyCloud
Remove Public Share
curl -L https://gist.github.com/codedecay/02e5dc3d487a38d0a89f/raw | sh
#Backup Files
cp /etc/wdcomp.d/boot/bootscript_005_wd-nas /root/bootscript_005_wd-nas.bkup
cp /usr/local/sbin/createDataVolume.sh /root/createDataVolume.bkup
cp /etc/samba/overall_share /root/overall_share.bkup
#Comment out relevant lines in the boot and create script.
sed -i '209,215 s/^/#/' /etc/wdcomp.d/boot/bootscript_005_wd-nas
sed -i '23,25 s/^/#/' /usr/local/sbin/createDataVolume.sh
sed -i '29,29 s/^/#/' /usr/local/sbin/createDataVolume.sh
#Comment out validation in deleteShare.sh if it is present.
sed -i '/echo \$shareName/ {N;N; /delete Public/ s/^/#!!#/}' /usr/local/sbin/deleteShare.sh
sed -i '/#!!#if/,+4 s/^/#/; s/#!!#//' /usr/local/sbin/deleteShare.sh`
#Delete the public share
/usr/local/sbin/deleteShare.sh "Public"
#Comment out the public share definition from the Samba config.
sed -i '1,10 s/^/#/' /etc/samba/overall_share
#Restart the samba service.
service samba restart
##Restore Public Share
curl -L https://gist.github.com/codedecay/02e5dc3d487a38d0a89f/raw | sh
#Either Restore from your backup files..
/bin/cp /root/bootscript_005_wd-nas.bkup /etc/wdcomp.d/boot/bootscript_005_wd-nas
/bin/cp /root/createDataVolume.bkup /usr/local/sbin/createDataVolume.sh
/bin/cp /root/deleteShare.bkup /usr/local/sbin/deleteShare.sh
/bin/cp /root/overall_share.bkup /etc/samba/overall_share
#Or undo the comments in the existing files.
sed -i '209,215 s/^#//' /etc/wdcomp.d/boot/bootscript_005_wd-nas
sed -i '23,25 s/^#//' /usr/local/sbin/createDataVolume.sh
sed -i '29,29 s/^#//' /usr/local/sbin/createDataVolume.sh
sed -i '1,10 s/^#//' /etc/samba/overall_share
sed -i '/#if.*shareName/,+4 s/#//' /usr/local/sbin/deleteShare.sh
#Recreate the Public Share and Directory Structure
mkdir -p "/DataVolume/shares/Public"
mkdir -p "/DataVolume/shares/Public/Shared Music"
mkdir -p "/DataVolume/shares/Public/Shared Videos"
mkdir -p "/DataVolume/shares/Public/Shared Pictures"
chmod -R 775 /DataVolume/shares
chown -R root:share /DataVolume/shares/Public
#Restart the samba service
service samba restart