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
|
#!/bin/bash
juju-log "nfs-relation-changed called."
logfile=/tmp/nfslog.txt
options=`relation-get options`
mountpoint=`relation-get mountpoint`
fstype=`relation-get fstype`
host=`relation-get private-address`
echo `date` >> $logfile
echo "nfs-relation-changed" >> $logfile
echo "host=$host" >> $logfile
echo "mountpoint=$mountpoint" >> $logfile
if [ -z $mountpoint ] ; then
juju-log "no mountpoint defined.";
exit 0;
fi
cat > /tmp/nfs-mount-info <<EOF
#!/bin/bash
MOUNT_TYPE=$fstype
MOUNT_OPS=$options
MOUNT_SERVER=$host
MOUNT_PATH=$mountpoint
EOF
# We wants several directory to be hosted on a shared fs:
# /var/www/spip/IMG
# /var/www/spip/plugins
# /var/www/spip/squelettes
for i in plugins squelettes IMG ; do
if [ ! -d /var/www/spip/$i ]; then
mkdir /var/www/spip/$i ;
fi
chown -R www-data /var/www/spip/$i ;
done
#Let s make a backup copy of things:
d=`date +"%s"`
mkdir /tmp/$d
for i in plugins squelettes IMG ; do
mkdir /tmp/$d/$i ;
mv /var/www/spip/$i /tmp/$d/ ;
done
#Now we mount the nfs share.
mkdir -p /mnt/spip-nfs
juju-log "mount -t nfs $host:$mountpoint /mnt/spip-nfs"
mount -t nfs $host:$mountpoint /mnt/spip-nfs
for i in plugins squelettes IMG ; do
mv /tmp/$d/$i /mnt/spip-nfs/;
chown -R www-data /mnt/spip-nfs;
ln -s /mnt/spip-nfs/$i/ /var/www/spip/;
done
#We copy back all the stuff that was present locally.
#mv /tmp/$d/* /var/www/spip/IMG/
#and we chmod it back to www-data
#chown -R www-data /var/www/spip/IMG/
|