-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmounter.sh
70 lines (51 loc) · 2.36 KB
/
mounter.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Save the script to an appropriate location on your system, such as /usr/local/bin/mounter.sh, and make it executable with the command sudo chmod +x /usr/local/bin/mounter.sh
# Create a systemd service to run the script on boot. For example, create a service file called mounter.service in /etc/systemd/system/:
# sudo nano /etc/systemd/system/mounter.service
# Inside this file, insert the following content:
# [Unit]
# Description=Mount Retry Script
# [Service]
# Type=oneshot
# ExecStart=/usr/local/bin/mounter.sh
# [Install]
# WantedBy=multi-user.target
# enable the service to start during boot:
# sudo systemctl enable mounter.service
downMount=0
moviesMount=0
seriesMount=0
# Loop to attempt editing at 30 second intervals
# Replace the objects in brackets with the appropriate location of your NAS, path you would like to mount the folder, your username, and your password
while true; do
if [ $downMount -eq 0 ]; then
sudo mount -t cifs [//IP-ADDRESS/PATH] [/PATH-TO-MOUNT default: /DATA/Downloads] -o username=[USERNAME-HERE],password=[PASSWORD-HERE],vers=3.0,rw,uid=1000,gid=1000,forceuid,forcegid,file_mode=0777,dir_mode=0777,nounix
if [ $? -eq 0 ]; then
echo "downloads mount successful!"
downMount=1
fi
fi
if [ $moviesMount -eq 0 ]; then
sudo mount -t cifs [//IP-ADDRESS/PATH] [/PATH-TO-MOUNT default: /DATA/Media/Movies] -o username=[USERNAME-HERE],password=[PASSWORD-HERE],vers=3.0,rw,uid=1000,gid=1000,forceuid,forcegid,file_mode=0777,dir_mode=0777,nounix
if [ $? -eq 0 ]; then
echo "movies mount successful!"
moviesMount=1
fi
fi
if [ $seriesMount -eq 0 ]; then
sudo mount -t cifs [//IP-ADDRESS/PATH] [/PATH-TO-MOUNT default: /DATA/Media/TV\ Shows] -o username=[USERNAME-HERE],password=[PASSWORD-HERE],vers=3.0,rw,uid=1000,gid=1000,forceuid,forcegid,file_mode=0777,dir_mode=0777,nounix
if [ $? -eq 0 ]; then
echo "shows mount successful!"
seriesMount=1
fi
fi
# If all mounts were successful, exit the loop
if [[ $downMount -eq 1 && $moviesMount -eq 1 && $seriesMount -eq 1 ]]; then
echo "All mounts successful!"
break
fi
# Please wait 30 seconds before trying again
echo "An error has occurred, retrying in 30secs"
sleep 30
done
echo "Done!"