diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-04-01 20:20:48 +0300 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-04-01 20:20:48 +0300 |
commit | 861548f8d90ae3f996006bf8d2e5213c0ea629f5 (patch) | |
tree | 1a69cdb2917afed5ea966671cf94f16c689c6517 /makeself | |
parent | 32d4f0b4a487a6174c1018790672ec9f7466f3cc (diff) |
update permissions
Diffstat (limited to 'makeself')
-rwxr-xr-x | makeself/install-or-update.sh | 73 | ||||
-rwxr-xr-x | makeself/jobs/99-makeself.install.sh | 21 |
2 files changed, 80 insertions, 14 deletions
diff --git a/makeself/install-or-update.sh b/makeself/install-or-update.sh index 8afa08ad7a..0ea8ee5cd6 100755 --- a/makeself/install-or-update.sh +++ b/makeself/install-or-update.sh @@ -33,6 +33,7 @@ do # find the checksum of the existing file md5="$(cat "${t}" | ${md5sum} | cut -d ' ' -f 1)" + echo >&2 "debug md5 of '${t}': ${md5}" # check if it matches if [ "${configs_signatures[${md5}]}" = "${f}" ] @@ -47,6 +48,8 @@ done # ----------------------------------------------------------------------------- progress "Add user netdata to required user groups" +NETDATA_USER=root +NETDATA_GROUP=root NETDATA_ADDED_TO_DOCKER=0 NETDATA_ADDED_TO_NGINX=0 NETDATA_ADDED_TO_VARNISH=0 @@ -55,8 +58,8 @@ NETDATA_ADDED_TO_ADM=0 NETDATA_ADDED_TO_NSD=0 if [ ${UID} -eq 0 ] then - portable_add_group netdata - portable_add_user netdata + portable_add_group netdata && NETDATA_USER=netdata + portable_add_user netdata && NETDATA_GROUP=netdata portable_add_user_to_group docker netdata && NETDATA_ADDED_TO_DOCKER=1 portable_add_user_to_group nginx netdata && NETDATA_ADDED_TO_NGINX=1 portable_add_user_to_group varnish netdata && NETDATA_ADDED_TO_VARNISH=1 @@ -103,3 +106,69 @@ else run_failed "The installer does not run as root." fi + +# ----------------------------------------------------------------------------- +progress "creating quick links" + +dir_should_be_link() { + local p="${1}" t="${2}" d="${3}" old + + old="$(pwd)" + cd "${p}" || return 0 + + if [ -e "${d}" ] + then + if [ -h "${d}" ] + then + run rm "${d}" + else + run mv -f "${d}" "${d}.old.$$" + fi + fi + + run ln -s "${t}" "${d}" + cd "${old}" +} + +dir_should_be_link . bin sbin +dir_should_be_link usr ../bin bin +dir_should_be_link usr ../bin sbin +dir_should_be_link usr . local + +dir_should_be_link . etc/netdata netdata-configs +dir_should_be_link . usr/share/netdata/web netdata-web-files +dir_should_be_link . usr/libexec/netdata netdata-plugins +dir_should_be_link . var/lib/netdata netdata-dbs +dir_should_be_link . var/cache/netdata netdata-metrics +dir_should_be_link . var/log/netdata netdata-logs + + +# ----------------------------------------------------------------------------- +progress "fix permissions" + +for x in etc/netdata var/log/netdata var/lib/netdata var/cache/netdata usr/share/netdata +do + if [ -d "${x}" ] + then + run chown -R ${NETDATA_USER}:${NETDATA_GROUP} ${x} + fi +done + + +# ----------------------------------------------------------------------------- +progress "fix plugin permissions" + +for x in apps.plugin freeipmi.plugin +do + f="usr/libexec/netdata/plugins.d/${x}" + + if [ -f "${f}" ] + then + run chown root:${NETDATA_GROUP} "${f}" + run chmod 4750 "${d}" + fi +done + + +# ----------------------------------------------------------------------------- +netdata_banner "is installed now!" diff --git a/makeself/jobs/99-makeself.install.sh b/makeself/jobs/99-makeself.install.sh index 4e4724548e..efed25069d 100755 --- a/makeself/jobs/99-makeself.install.sh +++ b/makeself/jobs/99-makeself.install.sh @@ -4,18 +4,6 @@ # ----------------------------------------------------------------------------- -# create a few quick links - -run cd "${NETDATA_INSTALL_PATH}" -run ln -s etc/netdata netdata-configs -run ln -s usr/share/netdata/web netdata-web-files -run ln -s usr/libexec/netdata netdata-plugins -run ln -s var/lib/netdata netdata-dbs -run ln -s var/cache/netdata netdata-metrics -run ln -s var/log/netdata netdata-logs - - -# ----------------------------------------------------------------------------- # copy the files needed by makeself installation run mkdir -p "${NETDATA_INSTALL_PATH}/system" @@ -64,6 +52,15 @@ fi # ----------------------------------------------------------------------------- +# remove the links to allow the untaring the archive + +rm "${NETDATA_INSTALL_PATH}/sbin" \ + "${NETDATA_INSTALL_PATH}/usr/bin" \ + "${NETDATA_INSTALL_PATH}/usr/sbin" \ + "${NETDATA_INSTALL_PATH}/usr/local" + + +# ----------------------------------------------------------------------------- # create the makeself archive "${NETDATA_MAKESELF_PATH}/makeself.sh" \ |