Skip to content

Commit

Permalink
Don't change permissions in the init script (only /var/run since it c…
Browse files Browse the repository at this point in the history
…ould

be in ramdisk).
  • Loading branch information
graziano committed Aug 27, 2009
1 parent 2b83e24 commit bccfa7d
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 37 deletions.
40 changes: 22 additions & 18 deletions extras/nagios.sh
Expand Up @@ -12,6 +12,7 @@ CC_HOSTS=""
SC_HOSTS=""
PRINT_HOSTS=""
PRINT_MEMBERS=""
WGET="`which wget > /dev/null`"
TOUT=30

usage () {
Expand Down Expand Up @@ -94,6 +95,20 @@ define hostgroup {
EOF
}

get_status() {
local address="$1"
local name="$2"
local ret="false"

ret="`$WGET -O - -o /dev/null --timeout=$TOUT http://${address}:8773/services/Heartbeat|grep \"${name}\" |sed 's/.*enabled=\([[:alnum:]]*\)[[:blank:]].*/\1/'`"

if [ "$ret" = "true" ]; then
return 0
fi

return 1
}

# let's parse the command line
while [ $# -gt 0 ]; do
if [ "$1" = "-h" -o "$1" = "-help" -o "$1" = "?" -o "$1" = "--help" ]; then
Expand Down Expand Up @@ -301,6 +316,10 @@ if [ -n "$NAGIOS_PIPE" ]; then
echo "$NAGIOS_PIPE is not a pipe or is not writable!"
exit 1
fi
if [ -z "$WGET" ]; then
echo "wget is missing!"
exit 1
fi

# let's check the NCs
if [ -n "$NODES" ]; then
Expand Down Expand Up @@ -338,7 +357,7 @@ if [ -n "$NAGIOS_PIPE" ]; then
if [ -n "$CLOUD" ]; then
for x in "$CLOUD" ; do
# get the status
if wget -O - -o /dev/null --timeout=$TOUT http://$x:8773/services/ |grep Eucalyptus > /dev/null; then
if get_status $x eucalyptus ; then
STATUS="0"
else
STATUS="2"
Expand All @@ -354,22 +373,7 @@ if [ -n "$NAGIOS_PIPE" ]; then
if [ -n "$WALRUS" ]; then
for x in "$WALRUS" ; do
# get the status
if wget -O - -o /dev/null --timeout=$TOUT http://$x:8773/services/ |grep Eucalyptus > /dev/null; then
STATUS="0"
else
STATUS="2"
fi
DESCRIPTION="Eucalyptus Walrus status"

# let's tell nagios
echo "[`date +%s`] PROCESS_SERVICE_CHECK_RESULT;$x;eucalyptus-walrus;$STATUS;$DESCRIPTION" > $NAGIOS_PIPE
done
fi
# let's check the walrus
if [ -n "$WALRUS" ]; then
for x in "$WALRUS" ; do
# get the status
if wget -O - -o /dev/null --timeout=$TOUT http://$x:8773/services/ |grep Eucalyptus > /dev/null; then
if get_status $x walrus ; then
STATUS="0"
else
STATUS="2"
Expand All @@ -385,7 +389,7 @@ if [ -n "$NAGIOS_PIPE" ]; then
if [ -n "$SC" ]; then
for x in "$SC" ; do
# get the status
if wget -O - -o /dev/null --timeout=$TOUT http://$x:8774/axis2/services |grep EucalyptusCC > /dev/null; then
if get_status $x storage ; then
STATUS="0"
else
STATUS="2"
Expand Down
56 changes: 39 additions & 17 deletions tools/euca_conf.in
Expand Up @@ -614,11 +614,15 @@ if [ -n "$SETUP" ]; then
fi
EUCA_GROUP="`$ID -ng $EUCA_USER 2>/dev/null`"
if [ -z "$EUCA_GROUP" ]; then
echo "Cannot detect $EUCA_USER group: using $EUCA_USER"
echo "Cannot detect $EUCA_USER group"
exit 1
fi
if ! chown root:$EUCA_GROUP $ROOTWRAP ; then
exit 1
fi
if ! chmod 4750 $ROOTWRAP ; then
exit 1
fi
chown root:$EUCA_GROUP $ROOTWRAP
chmod 4750 $ROOTWRAP
fi

# let's create the instance path
Expand All @@ -627,23 +631,39 @@ if [ -n "$SETUP" ]; then
echo "Failed to create instance path!"
exit 1
fi
chown $EUCA_USER:$EUCA_GROUP $INSTANCE_PATH
if ! chown $EUCA_USER:$EUCA_GROUP $INSTANCE_PATH ; then
exit 1
fi
fi

chown -R $EUCA_USER:$EUCA_GROUP $EUCALYPTUS/var/lib/eucalyptus
ret=$?
chown -R $EUCA_USER:$EUCA_GROUP $EUCALYPTUS/var/log/eucalyptus
let $((ret += $?))
chown -R $EUCA_USER:$EUCA_GROUP $EUCALYPTUS/var/run/eucalyptus
let $((ret += $?))

# let's create more needed directory with the right permissions
mkdir -p $EUCALYPTUS/var/lib/eucalyptus/db
chown $EUCA_USER $EUCALYPTUS/var/lib/eucalyptus/db
let $((ret += $?))
chown $EUCA_USER:$EUCA_GROUP $EUCALYPTUS/var/lib/eucalyptus/db
let $((ret += $?))
chmod 700 $EUCALYPTUS/var/lib/eucalyptus/db
let $((ret += $?))
mkdir -p $EUCALYPTUS/var/lib/eucalyptus/keys
chown $EUCA_USER $EUCALYPTUS/var/lib/eucalyptus/keys
let $((ret += $?))
chown $EUCA_USER:$EUCA_GROUP $EUCALYPTUS/var/lib/eucalyptus/keys
let $((ret += $?))
chmod 700 $EUCALYPTUS/var/lib/eucalyptus/keys
let $((ret += $?))
mkdir -p $EUCALYPTUS/var/lib/eucalyptus/CC
chown $EUCA_USER $EUCALYPTUS/var/lib/eucalyptus/CC
let $((ret += $?))
chown $EUCA_USER:$EUCA_GROUP $EUCALYPTUS/var/lib/eucalyptus/CC
let $((ret += $?))
chmod 700 $EUCALYPTUS/var/lib/eucalyptus/CC
let $((ret += $?))

return $ret
fi

# pre-flight checks
Expand Down Expand Up @@ -710,17 +730,19 @@ if [ -n "$CHECK" ]; then

# let's set up directories which could disappears if /var/run is
# in memory
mkdir -p $EUCALYPTUS/var/run/eucalyptus
mkdir -p $EUCALYPTUS/var/log/eucalyptus

# set up eucalyptus var locations to be owned by EUCA_USER
for y in $EUCALYPTUS/var/lib/eucalyptus/ $EUCALYPTUS/var/run/eucalyptus/ $EUCALYPTUS/var/log/eucalyptus/ $INSTANCE_PATH; do
if [ $y != "/" -a -d $y ]; then
if ! chown -R $EUCA_USER:$EUCA_GROUP $y ; then
echo "Problem setting permissions for $y"
fi
if [ ! -d $EUCALYPTUS/var/run/eucalyptus ]; then
if ! mkdir -p $EUCALYPTUS/var/run/eucalyptus ; then
# error should come from mkdir
exit 1
fi
done
if ! chown $EUCA_USER:$EUCA_GROUP $EUCALYPTUS/var/run/eucalyptus ; then
# error should come from chown
exit 1
fi
fi

# good to go
exit 0
fi

createCloudURL () {
Expand Down
2 changes: 1 addition & 1 deletion tools/eucalyptus-cc.in
Expand Up @@ -138,7 +138,7 @@ do_start() {
exit 1
fi

if ! $EUCALYPTUS/usr/sbin/euca_conf -check cc ; then
if ! $EUCALYPTUS/usr/sbin/euca_conf --check cc ; then
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion tools/eucalyptus-nc.in
Expand Up @@ -140,7 +140,7 @@ do_start() {
exit 1
fi

if ! $EUCALYPTUS/usr/sbin/euca_conf -check nc ; then
if ! $EUCALYPTUS/usr/sbin/euca_conf --check nc ; then
exit 1
fi

Expand Down

0 comments on commit bccfa7d

Please sign in to comment.