tmchow Posted September 20, 2016 Share Posted September 20, 2016 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. Quote Link to comment
Solution RobJ Posted September 20, 2016 Solution Share Posted September 20, 2016 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 1 1 Quote Link to comment
Squid Posted September 20, 2016 Share Posted September 20, 2016 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 Quote Link to comment
tmchow Posted September 20, 2016 Author Share Posted September 20, 2016 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 Quote Link to comment
RobJ Posted September 20, 2016 Share Posted September 20, 2016 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. Quote Link to comment
Recommended Posts
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.