Hi All,
I have got a box here running FreeNAS and have started to hack at someone else's script to make it do what I want. I know this is not the Freenas forums but i have not had much luck there and its FreeBSD based.....
In particular his script was;
1) encrypting the USB attached device - which I don't need.
2) repeated beeping when finished (one long beep would be fine)
3) I dont know what the A16P echoing is all about
I am not quite there yet, and hope someone here can help. What I want
to do it:
1. Automount USB disk when plugged in
2. Rysnc certain directories
3. Dismount when finished
4. Send email with some sort of details (ie failure of 1,2,3 or 4, and
also upon success of 2 (rsync)).
So far this is what I have ended up with, some of the folders I have
hard coded.
Thanks in advance,
-Al
I have got a box here running FreeNAS and have started to hack at someone else's script to make it do what I want. I know this is not the Freenas forums but i have not had much luck there and its FreeBSD based.....
In particular his script was;
1) encrypting the USB attached device - which I don't need.
2) repeated beeping when finished (one long beep would be fine)
3) I dont know what the A16P echoing is all about
I am not quite there yet, and hope someone here can help. What I want
to do it:
1. Automount USB disk when plugged in
2. Rysnc certain directories
3. Dismount when finished
4. Send email with some sort of details (ie failure of 1,2,3 or 4, and
also upon success of 2 (rsync)).
So far this is what I have ended up with, some of the folders I have
hard coded.
Code:
#!/bin/bash -x
key_file=/temp/ukey.key
device=da${1//[a-z]/}
origin=/mnt/DATA/
target=/mnt/secret
echo ${device}
echo ${target}
_start() {
if [ ! -f /var/run/${0##*/}.pid ];then
echo $$ > /var/run/${0##*/}.pid
else
/usr/bin/logger "Error syncing $origin on $device";
echo "A16P16A16P16A16P16CP8CP8CP8A16P16A16P16A16" > /dev/
speaker
_finish;
fi
}
_finish() {
if [ -f /var/run/${0##*/}.pid ];then
rm /var/run/${0##*/}.pid;
fi
exit
}
_mount() {
/sbin/geli attach -p -k ${key_file} /dev/$device
/bin/mkdir -p ${target} &&
/sbin/mount /dev/${device}.eli ${target}/ &&
/sbin/fsck_ufs -pB ${target};
}
_umount() {
/sbin/umount /dev/${device}.eli;
/bin/rm -r ${target};
/bin/sync /dev/${device}.eli
/sbin/geli detach /dev/${device};
/bin/sync /dev/${device}
}
_sync_func() {
/usr/local/bin/rsync -a --log-file=${origin}/backup.log ${origin}/
${target}/
/usr/bin/logger "Finish syncing $origin on $device";
}
_start; _mount; _sync_func; _umount;
while [ -e /dev/da0 ];do echo "A8P8A8P8A8" > /dev/speaker;sleep
10;done
_finish;
Thanks in advance,
-Al