paul@634 | 1 | #!/bin/sh |
paul@634 | 2 | |
paul@1201 | 3 | # This tool fixes permissions on data stores and published data, making sure |
paul@1201 | 4 | # that the imip-agent can update the directories involved and that the |
paul@1201 | 5 | # permissions persist. |
paul@1201 | 6 | # |
paul@1201 | 7 | # Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk> |
paul@1201 | 8 | # |
paul@1201 | 9 | # This program is free software; you can redistribute it and/or modify it under |
paul@1201 | 10 | # the terms of the GNU General Public License as published by the Free Software |
paul@1201 | 11 | # Foundation; either version 3 of the License, or (at your option) any later |
paul@1201 | 12 | # version. |
paul@1201 | 13 | # |
paul@1201 | 14 | # This program is distributed in the hope that it will be useful, but WITHOUT |
paul@1201 | 15 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@1201 | 16 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@1201 | 17 | # details. |
paul@1201 | 18 | # |
paul@1201 | 19 | # You should have received a copy of the GNU General Public License along with |
paul@1201 | 20 | # this program. If not, see <http://www.gnu.org/licenses/>. |
paul@1201 | 21 | |
paul@1108 | 22 | DIRNAME=`dirname "$0"` |
paul@891 | 23 | |
paul@891 | 24 | if [ -e "$DIRNAME/config.sh" ]; then |
paul@1089 | 25 | CONFIG="$DIRNAME/config.sh" |
paul@1089 | 26 | . "$CONFIG" |
paul@891 | 27 | else |
paul@1089 | 28 | CONFIG=/etc/imip-agent/config.sh |
paul@1089 | 29 | . "$CONFIG" |
paul@891 | 30 | fi |
paul@891 | 31 | |
paul@1108 | 32 | PROGNAME=`basename "$0"` |
paul@731 | 33 | |
paul@731 | 34 | if [ "$1" = "--help" ]; then |
paul@731 | 35 | cat 1>&2 <<EOF |
paul@1096 | 36 | Usage: $PROGNAME |
paul@1096 | 37 | |
paul@1096 | 38 | Fix permissions for the stored and published data directories, operating on... |
paul@731 | 39 | |
paul@1096 | 40 | * $INSTALL_DIR |
paul@1096 | 41 | * $WEB_INSTALL_DIR |
paul@891 | 42 | |
paul@1096 | 43 | ...respectively. |
paul@1096 | 44 | |
paul@1096 | 45 | Set ownership and membership to the user and group respectively given as |
paul@1096 | 46 | $IMIP_AGENT_USER and $IMIP_AGENT_GROUP. |
paul@731 | 47 | EOF |
paul@731 | 48 | exit 1 |
paul@731 | 49 | fi |
paul@731 | 50 | |
paul@1096 | 51 | chown -R "$IMIP_AGENT_USER" "$INSTALL_DIR" |
paul@1096 | 52 | chgrp -R "$IMIP_AGENT_GROUP" "$INSTALL_DIR" |
paul@634 | 53 | |
paul@1089 | 54 | for DIR in "$INSTALL_DIR"/preferences "$WEB_INSTALL_DIR"/static ; do |
paul@1096 | 55 | chown -R "$IMIP_AGENT_USER" "$DIR" |
paul@1096 | 56 | chgrp -R "$IMIP_AGENT_GROUP" "$DIR" |
paul@634 | 57 | chmod -R g+w "$DIR" |
paul@634 | 58 | done |
paul@1089 | 59 | |
paul@1089 | 60 | if [ "$STORE_TYPE" = "file" ]; then |
paul@1089 | 61 | for DIR in "$INSTALL_DIR"/store "$INSTALL_DIR"/journal ; do |
paul@1096 | 62 | chown -R "$IMIP_AGENT_USER" "$DIR" |
paul@1096 | 63 | chgrp -R "$IMIP_AGENT_GROUP" "$DIR" |
paul@1089 | 64 | chmod -R g+w "$DIR" |
paul@1089 | 65 | done |
paul@1089 | 66 | fi |