-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmkGwDirs
executable file
·36 lines (33 loc) · 865 Bytes
/
mkGwDirs
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
#!/bin/bash
SCRIPT=${0##*/}
SCRIPT_VERSION="1.0"
DIRS=`cat << EOF
/tmp/P2-RPi-ioT-gateway
/var/P2-RPi-ioT-gateway
/var/P2-RPi-ioT-gateway/status
/var/log/P2-RPi-ioT-gateway
/var/P2-RPi-ioT-gateway/mail
/var/P2-RPi-ioT-gateway/proc
EOF
`
# create all dirs but our new .../control dir
for DIR in $DIRS; do
echo " -- ${DIR} -- "
mkdir ${DIR} 2>/dev/null
sudo chown daemon:users ${DIR}
sudo chmod 775 ${DIR}
ls -ld ${DIR}
done
# Special for web-server .../control dir
DIR=/var/www/html/P2-RPi-ioT-gateway/control
echo " -- ${DIR} -- "
sudo mkdir -p ${DIR} 2>/dev/null
sudo chown pi:www-data ${DIR}
sudo chmod g+w ${DIR}
ls -ld ${DIR}
# and remove old dir if present
OLDDIR=/var/P2-RPi-ioT-gateway/control
if [ -d ${OLDDIR} ]; then
echo "${SCRIPT}: removing outdated directory:" >&2
(set -x;sudo rm -rf ${OLDDIR})
fi