-
Notifications
You must be signed in to change notification settings - Fork 0
/
10_folder_setup.sh
executable file
·67 lines (58 loc) · 1.79 KB
/
10_folder_setup.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
#!/bin/bash
#
# Folder setup
#
echo "=> Folder setup started"
USER=`id -un`
if [ ! -e .env ]
then
echo "<!> Please create proper .env file! Exiting."
exit 1
fi
set -o allexport
source .env
set +o allexport
# ${STACKDIR} is from .env
cd ${STACKDIR}
echo "Stack directory: ${STACKDIR}"
mkdir -p ${STACKDIR}
sudo chown -R ${USER}:docker ${STACKDIR}
echo "Creating subdirs under ${STACKDIR}"
mkdir -p ${STACKDIR}/shared
mkdir -p ${STACKDIR}/portainer/data
mkdir -p ${STACKDIR}/mosquitto/config
mkdir -p ${STACKDIR}/mosquitto/data
mkdir -p ${STACKDIR}/mosquitto/log
mkdir -p ${STACKDIR}/homeassistant
mkdir -p ${STACKDIR}/grafana
mkdir -p ${STACKDIR}/influxdb/db
mkdir -p ${STACKDIR}/telegraf
mkdir -p ${STACKDIR}/zigbee2mqtt/data
# mkdir -p ${STACKDIR}/postgresql/data
# mkdir -p ${STACKDIR}/mariadb/data
# mkdir -p ${STACKDIR}/adminer
cd ${STACKDIR}
##find . -type d -exec touch {}/.gitignore \;
if [ -e ${STACKDIR}/mosquitto/log/.gitignore ]
then
rm ${STACKDIR}/mosquitto/log/.gitignore
fi
echo "Creating some files under ${SUBDIR}"
touch ${STACKDIR}/mosquitto/config/mosquitto.conf
touch ${STACKDIR}/mosquitto/config/passwd
touch ${STACKDIR}/mosquitto/log/mosquitto.log
touch ${STACKDIR}/influxdb/influxdb.conf
touch ${STACKDIR}/telegraf/telegraf.conf
# for accessing telegraf log from outside
touch ${STACKDIR}/telegraf/telegraf.log
touch ${STACKDIR}/zigbee2mqtt/data/configuration.yaml
echo "Setting file permissions"
sudo chown -R ${USER}:docker ${STACKDIR}
sudo setfacl -Rdm g:docker:rw ${STACKDIR}
sudo chmod -R ug+rw ${STACKDIR}
sudo chmod -R o+r ${STACKDIR}
sudo chmod -R ugo+x ${STACKDIR}/*.sh
sudo chmod -R ugo-x ${STACKDIR}/telegraf/telegraf.log
sudo chmod -R ugo-x ${STACKDIR}/mosquitto/log/mosquitto.log
sudo chmod -R ugo-x ${STACKDIR}/zigbee2mqtt/data/configuration.yaml
echo "=> Folder setup completed"