update permissions
Costa Tsaousis (ktsaou) committed
Apr 1, 2017 at 20:20 UTC
861548f8d90ae3f996006bf8d2e5213c0ea629f5
2 files changed
+80
-14
makeself/install-or-update.sh
+71
-2
@@ -33,6 +33,7 @@ do
33
34
# find the checksum of the existing file
35
md5="$(cat "${t}" | ${md5sum} | cut -d ' ' -f 1)"
36
+ echo >&2 "debug md5 of '${t}': ${md5}"
37
38
# check if it matches
39
if [ "${configs_signatures[${md5}]}" = "${f}" ]
@@ -47,6 +48,8 @@ done
48
# -----------------------------------------------------------------------------
49
progress "Add user netdata to required user groups"
50
51
+NETDATA_USER=root
52
+NETDATA_GROUP=root
53
NETDATA_ADDED_TO_DOCKER=0
54
NETDATA_ADDED_TO_NGINX=0
55
NETDATA_ADDED_TO_VARNISH=0
@@ -55,8 +58,8 @@ NETDATA_ADDED_TO_ADM=0
58
NETDATA_ADDED_TO_NSD=0
59
if [ ${UID} -eq 0 ]
60
then
58
- portable_add_group netdata
59
- portable_add_user netdata
61
+ portable_add_group netdata && NETDATA_USER=netdata
62
+ portable_add_user netdata && NETDATA_GROUP=netdata
63
portable_add_user_to_group docker netdata && NETDATA_ADDED_TO_DOCKER=1
64
portable_add_user_to_group nginx netdata && NETDATA_ADDED_TO_NGINX=1
65
portable_add_user_to_group varnish netdata && NETDATA_ADDED_TO_VARNISH=1
@@ -103,3 +106,69 @@ else
106
run_failed "The installer does not run as root."
107
fi
108
109
+
110
+# -----------------------------------------------------------------------------
111
+progress "creating quick links"
112
+
113
+dir_should_be_link() {
114
+ local p="${1}" t="${2}" d="${3}" old
115
+
116
+ old="$(pwd)"
117
+ cd "${p}" || return 0
118
+
119
+ if [ -e "${d}" ]
120
+ then
121
+ if [ -h "${d}" ]
122
+ then
123
+ run rm "${d}"
124
+ else
125
+ run mv -f "${d}" "${d}.old.$$"
126
+ fi
127
+ fi
128
+
129
+ run ln -s "${t}" "${d}"
130
+ cd "${old}"
131
+}
132
+
133
+dir_should_be_link . bin sbin
134
+dir_should_be_link usr ../bin bin
135
+dir_should_be_link usr ../bin sbin
136
+dir_should_be_link usr . local
137
+
138
+dir_should_be_link . etc/netdata netdata-configs
139
+dir_should_be_link . usr/share/netdata/web netdata-web-files
140
+dir_should_be_link . usr/libexec/netdata netdata-plugins
141
+dir_should_be_link . var/lib/netdata netdata-dbs
142
+dir_should_be_link . var/cache/netdata netdata-metrics
143
+dir_should_be_link . var/log/netdata netdata-logs
144
+
145
+
146
+# -----------------------------------------------------------------------------
147
+progress "fix permissions"
148
+
149
+for x in etc/netdata var/log/netdata var/lib/netdata var/cache/netdata usr/share/netdata
150
+do
151
+ if [ -d "${x}" ]
152
+ then
153
+ run chown -R ${NETDATA_USER}:${NETDATA_GROUP} ${x}
154
+ fi
155
+done
156
+
157
+
158
+# -----------------------------------------------------------------------------
159
+progress "fix plugin permissions"
160
+
161
+for x in apps.plugin freeipmi.plugin
162
+do
163
+ f="usr/libexec/netdata/plugins.d/${x}"
164
+
165
+ if [ -f "${f}" ]
166
+ then
167
+ run chown root:${NETDATA_GROUP} "${f}"
168
+ run chmod 4750 "${d}"
169
+ fi
170
+done
171
+
172
+
173
+# -----------------------------------------------------------------------------
174
+netdata_banner "is installed now!"
makeself/jobs/99-makeself.install.sh
+9
-12
@@ -3,18 +3,6 @@
3
. $(dirname "${0}")/../functions.sh "${@}" || exit 1
4
5
6
-# -----------------------------------------------------------------------------
7
-# create a few quick links
8
-
9
-run cd "${NETDATA_INSTALL_PATH}"
10
-run ln -s etc/netdata netdata-configs
11
-run ln -s usr/share/netdata/web netdata-web-files
12
-run ln -s usr/libexec/netdata netdata-plugins
13
-run ln -s var/lib/netdata netdata-dbs
14
-run ln -s var/cache/netdata netdata-metrics
15
-run ln -s var/log/netdata netdata-logs
16
-
17
-
6
# -----------------------------------------------------------------------------
7
# copy the files needed by makeself installation
8
@@ -63,6 +51,15 @@ if [ -d "${NETDATA_INSTALL_PATH}/etc/netdata" ]
51
fi
52
53
54
+# -----------------------------------------------------------------------------
55
+# remove the links to allow the untaring the archive
56
+
57
+rm "${NETDATA_INSTALL_PATH}/sbin" \
58
+ "${NETDATA_INSTALL_PATH}/usr/bin" \
59
+ "${NETDATA_INSTALL_PATH}/usr/sbin" \
60
+ "${NETDATA_INSTALL_PATH}/usr/local"
61
+
62
+
63
# -----------------------------------------------------------------------------
64
# create the makeself archive
65