forked from dmoll1974/targets-io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-graphite-container-volumes.sh
executable file
·61 lines (40 loc) · 1.35 KB
/
init-graphite-container-volumes.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
#!/bin/sh
set -e
set -x
LOG_DIR=/var/lib/targets-io/graphite/log
DATA_DIR=/var/lib/targets-io/graphite/storage
VOLUMES_INIT_CONTAINER_NAME=graphite-volumes-init
# this will fail if one of the volume directories already exists, this prevents you from accidentally deleting your existing data
mkdir /var/lib/targets-io
mkdir /var/lib/targets-io/graphite
mkdir $LOG_DIR
mkdir $DATA_DIR
#sudo restorecon -Rv /$HOME/graphite-volumes
#sudo chcon -Rt svirt_sandbox_file_t $LOG_DIR
#sudo chcon -Rt svirt_sandbox_file_t $DATA_DIR
docker rm -f $VOLUMES_INIT_CONTAINER_NAME || true
docker pull hopsoft/graphite-statsd
docker run -d \
--name $VOLUMES_INIT_CONTAINER_NAME \
hopsoft/graphite-statsd
sleep 2
docker logs $VOLUMES_INIT_CONTAINER_NAME
docker cp $VOLUMES_INIT_CONTAINER_NAME:/opt/graphite/storage $DATA_DIR
mv $DATA_DIR/storage/* $DATA_DIR
rmdir $DATA_DIR/storage
docker cp $VOLUMES_INIT_CONTAINER_NAME:/var/log $LOG_DIR
mv $LOG_DIR/log/* $LOG_DIR
rmdir $LOG_DIR/log
docker rm -f $VOLUMES_INIT_CONTAINER_NAME
echo sleep 5 seconds
sleep 5
echo "Removing .pid files"
myarray=`find /var/lib/targets-io/graphite/storage/ -maxdepth 1 -name "*.pid"`
if [ ${#myarray[@]} -gt 0 ]; then
rm -f /var/lib/targets-io/graphite/storage/*.pid
fi
echo "Content of storage directory"
ls -alFtr $DATA_DIR
echo "Content of log directory"
ls -alFtr $LOG_DIR
echo "Success"