Skip to content

Instantly share code, notes, and snippets.

@codedecay
Created November 6, 2015 02:16
Show Gist options
  • Save codedecay/7d30df8d12b506407d26 to your computer and use it in GitHub Desktop.
Save codedecay/7d30df8d12b506407d26 to your computer and use it in GitHub Desktop.
Removes Public Share from WD MyCloud - Warning all data in the Public folder will be deleted.
#!/bin/sh
echo "Backing up files"
#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
echo "Processing Files"
#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`
echo "Deleting the public Share"
#Delete the public share
/usr/local/sbin/deleteShare.sh "Public"
echo "Restarting Samba Service"
#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment