Jump to content

Have script check for Array being up before executing?


tmchow
Go to solution Solved by RobJ,

Recommended Posts

My array is currently offline as I'm investigating an issue with one of the disks. I noticed that one of my seedbox sync scripts still runs and runs amuck because the array isn't online and it starts creating folders within /mnt/user.

 

This leads me to the question of how do I get a script to check for array being up correctly before it executes?  IOW, if the array is down, I want to abort the script.

Link to comment
  • Solution

Don't know if this is what you want, but hopefully you can derive something from this bash script piece.

 

# Check if array is started
ls /mnt/disk[1-9]* 1>/dev/null 2>/dev/null
if [ $? -ne 0 ]
then
   echo "ERROR:  Array must be started before using this script"
   exit
fi

  • Like 1
  • Thanks 1
Link to comment

Don't know if this is what you want, but hopefully you can derive something from this bash script piece.

 

# Check if array is started
ls /mnt/disk[1-9]* 1>/dev/null 2>/dev/null
if [ $? -ne 0 ]
then
   echo "ERROR:  Array must be started before using this script"
   exit
fi

Funny....  I was going to have him parse vars.ini, and never thought about a simple check for directory existing.  Simple solutions are usually the best  ;)
Link to comment

Don't know if this is what you want, but hopefully you can derive something from this bash script piece.

 

# Check if array is started
ls /mnt/disk[1-9]* 1>/dev/null 2>/dev/null
if [ $? -ne 0 ]
then
   echo "ERROR:  Array must be started before using this script"
   exit
fi

 

Is checking for the disks enough? Any reason why I couldn't just check for /mnt/user existing?

 

e.g.

 

if [ -d "/mnt/user"]
  <do something>
else
  <do something else>
fi

Link to comment

I can't take any credit, I took it from others scripts!

 

Is checking for the disks enough? Any reason why I couldn't just check for /mnt/user existing?

 

Checking for the disks is enough to know if the array is started.  Checking for /mnt/user is also fine, *if* you know the user has User Shares enabled.  If they don't, there won't be a /mnt/user, ever.  I don't have it in my system.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...