Skip to content

Instantly share code, notes, and snippets.

@tomoyk
Created March 25, 2017 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomoyk/a8782865506c3abb5e8f6f28e66d23a0 to your computer and use it in GitHub Desktop.
Save tomoyk/a8782865506c3abb5e8f6f28e66d23a0 to your computer and use it in GitHub Desktop.
Script of configure TimeMachine on samba.
#!/bin/bash
# 変数の定義
mountPath="/Volumes/TimeMachineData"
imagePath="/Volumes/TimeMachineData/{yourHostName}_macAddress.sparsebundle"
imgMountPath="/Volumes/TimeMachine"
# マウントの確認(マウントされていない時)
isSmbMount=`mount -t smbfs | grep "on $mountPath (" | wc -l`
# echo $isMount
if [ $isSmbMount -ne 1 ] ; then
echo "It is not mounted on $mountPath"
exit 1
else
echo "[OK] NetworkDrive is mounted on $mountPath"
fi
# === イメージファイルが存在しないとき ===
if [ ! -e $imagePath ] ; then
echo "No such file $imagePath"
exit 1
else
echo "[OK] Image file is found"
fi
# === イメージファイルがマウントされているとき ===
isImgMount=`mount | grep "on $imgMountPath (" | wc -l`
if [ $isImgMount -eq 1 ] ; then
echo "Image is mounted on $imgMountPath"
exit 1
else
echo "[OK] Image is not mounted on $imgMountPath"
fi
# === イメージファイルのマウントを実行 ===
echo "[OK] Mount image on $imgMountPath"
hdiutil attach $imagePath
# === TimeMachineの保存先に指定 ===
#echo "[OK] Set TimeMachine"
#sudo tmutil setdestination $imgMountPath
#Note:: sudo destionationinfo <- check destionation
echo "[OK] Script has just finished"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment