imip-agent

tools/fix.sh

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