Created
March 25, 2017 09:03
-
-
Save tomoyk/a8782865506c3abb5e8f6f28e66d23a0 to your computer and use it in GitHub Desktop.
Script of configure TimeMachine on samba.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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