From 4fdbb0e296d9ae58de85c43993958c3a52845b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20MOHIER?= Date: Thu, 5 Jan 2017 13:26:10 +0100 Subject: [PATCH] closes #674 - create a post-installation script to set file ownership / permissions --- README.rst | 4 +--- dev/set_permissions.sh | 49 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100755 dev/set_permissions.sh diff --git a/README.rst b/README.rst index d4094a6d6..a3a9915d5 100644 --- a/README.rst +++ b/README.rst @@ -23,7 +23,7 @@ and plugins. It works on any operating system and architecture that supports Python, which includes Windows, GNU/Linux and FreeBSD. Alignak is licensed under the Gnu Affero General Public Licence version 3 (AGPLv3). -Unless specified by another header, this licence apply to all files in this repository +Unless specified by another header, this licence apply to all files in this repository Requirements ============ @@ -37,5 +37,3 @@ Installing Alignak See the `Documentation`_ .. _Documentation: https://alignak-doc.readthedocs.org/en/latest/02_installation/index.html - - diff --git a/dev/set_permissions.sh b/dev/set_permissions.sh new file mode 100755 index 000000000..0bea985c1 --- /dev/null +++ b/dev/set_permissions.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# +# Copyright (C) 2015-2016: Alignak team, see AUTHORS.txt file for contributors +# +# This file is part of Alignak. +# +# Alignak is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Alignak is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Alignak. If not, see . +# + +## Same procedure as the one done in the debian installation +## Create user and group +echo "Checking / creating 'alignak' user and users group" +# Note: if the user exists, it's properties won't be changed (gid, home, shell) +adduser --quiet --system --home /var/lib/alignak --no-create-home --group alignak || true + +## Create nagios group +echo "Checking / creating 'nagios' users group" +addgroup --system nagios || true + +## Add alignak to nagios group +id -Gn alignak |grep -E '(^|[[:blank:]])nagios($|[[:blank:]])' >/dev/null || + echo "Adding user 'alignak' to the nagios users group" + adduser alignak nagios + +## Create directories with proper permissions +for i in /usr/local/etc/alignak /usr/local/var/run/alignak /usr/local/var/log/alignak /usr/local/var/lib/alignak /usr/local/var/libexec/alignak +do + mkdir -p $i + echo "Setting 'alignak' ownership on: $i" + chown -R alignak:alignak $i +done + +echo "Setting file permissions on: /usr/local/etc/alignak" +find /usr/local/etc/alignak -type f -exec chmod 664 {} + +find /usr/local/etc/alignak -type d -exec chmod 775 {} + + +echo "Terminated"