Skip to content

Commit

Permalink
closes #674 - create a post-installation script to set file ownership…
Browse files Browse the repository at this point in the history
… / permissions
  • Loading branch information
mohierf committed Jan 15, 2017
1 parent e18487a commit 4fdbb0e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
4 changes: 1 addition & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
============
Expand All @@ -37,5 +37,3 @@ Installing Alignak
See the `Documentation`_

.. _Documentation: https://alignak-doc.readthedocs.org/en/latest/02_installation/index.html


49 changes: 49 additions & 0 deletions dev/set_permissions.sh
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
#

## 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"

0 comments on commit 4fdbb0e

Please sign in to comment.