-
Notifications
You must be signed in to change notification settings - Fork 8
/
mount_shares_locally
executable file
·67 lines (58 loc) · 1.37 KB
/
mount_shares_locally
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
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: mount_shares_locally
# Required-Start: $network $local_fs $remote_fs smb mysqld
# Required-Stop: $network $local_fs $remote_fs smb
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: mount Samba shares locally
### END INIT INFO
username="***set this string to your username!***";
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi
start () {
uid=`id -u $username`
gid=`id -g $username`
echo -n $"Mounting Samba shares locally: "
mkdir -p /mnt/samba/
cd /mnt/samba/
mysql -u amahihda -pAmahiHDARulez -e "select name from shares" hda_production | grep -v "^name$" | xargs -d "\n" mkdir -p
sleep 10
ls -1 | while read d; do
/sbin/mount.cifs "//127.0.0.1/$d" "$d" -o credentials=/home/${username}/.smb_credentials,uid=${uid},gid=${gid},file_mode=0660,dir_mode=0770,nobrl,hard,_netdev,iocharset=utf8,noserverino,mfsymlinks
done
touch /var/lock/subsys/mount_shares_locally
success $"$base startup"
echo
return 0
}
stop () {
echo -n $"Unmounting locally mounted Samba shares: "
/bin/umount -l /mnt/samba/*
rm -f /var/lock/subsys/mount_shares_locally
success $"$base shutdown"
echo
return 0
}
restart () {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $?