Every now and then while attempting to access my mounted Amazon Cloud Drive I would receive the error message “Bad Address”. To fix this issue I copied a script I had found on Reddit  called remount.sh. This script is set to run every minute in crontab, it attempts to list the mounted folder and if it fails, it will attempt to remount the Amazon Cloud Drive.

I’m currently using this setup as a READ ONLY drive.

I adjusted the code to work with my encfsplex and acd_cli setup.

echo "Remount Initiated $(date)"
appname=$(basename $0)

# Change this to the location of your Amazon Cloud Mountpoint

if [ $(ls -l $acdmount  | grep -v '^total' | wc -l) -gt 0 ]; then
    echo Everything Looks ok

if [ $(ps -Al | grep $appname | wc -l) -gt 2 ]; then
        echo "Already Running! Count $(ps -Al | grep $appname | wc -l)"
echo "Remounting $(date)"

# umount -f "$acdmount"

echo "Unmounting"
/usr/local/bin/acd_cli umount /home/plex/e
/usr/local/bin/acd_cli umount /home/plex/cloud

echo "Deleting"
rm -rf /home/plex/cloud
rm -rf /home/plex/e

echo "Making"
mkdir /home/plex/cloud
mkdir /home/plex/e

syncresult=$(/usr/local/bin/acdcli sync 2>&1)
if [ $(echo $syncresult | grep -i error | wc -l) -gt 0 ]; then
        echo Error with the DB
        rm ~/.cache/acd_cli/nodes.db
        /usr/local/bin/acdcli sync
        sleep 10
echo $syncresult

/usr/local/bin/acd_cli mount /home/plex/e

ENCFS6_CONFIG='/home/plex/encfs.xml' encfs --extpass="ENCFS PASS" /home/plex/e/ /home/plex/cloud/

echo "Remount Done $(date)"


Crontab Code

*/1 * * * * /path/fixmount.sh > /path/fixmount.log 2>&1

The only thing missing is a function to check if fixmount.sh is running too long.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s