1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#!/bin/sh
# PCP QA Test No. 1478
# Workout for pcp-reboot-init - $PCP_VAR_DIR fixup part
#
# Copyright (c) 2024 Ken McDonell. All Rights Reserved.
#
if [ $# -eq 0 ]
then
seq=`basename $0`
echo "QA output created by $seq"
else
# use $seq from caller, unless not set
[ -n "$seq" ] || seq=`basename $0`
echo "QA output created by `basename $0` $*"
fi
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
_cleanup()
{
cd $here
$sudo rm -rf $tmp $tmp.*
}
status=0 # success is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_filter()
{
sed \
-e "s@$tmp@TMP@g" \
-e "s@$PCP_BINADM_DIR@PCP_BINADM_DIR@g" \
# end
}
mkdir $tmp
# setup a "correct" NOTICES to avoid babble from trying to
# fix this ... note this test is using pcpqa for $PCP_USER and
# $PCP_GROUP
# Note: this is $tmp/log/NOTICES, not the real NOTICES file.
#
mkdir $tmp/log
$sudo chown pcpqa:pcpqa $tmp/log
PCP_LOG_DIR=$tmp/log; export PCP_LOG_DIR
$sudo touch "$PCP_LOG_DIR"/NOTICES
$sudo chown pcpqa:pcpqa "$PCP_LOG_DIR"/NOTICES
PCP_DIR=$tmp; export PCP_DIR
unset PCP_ENV_DONE
unset PCP_RUN_DIR
unset PCP_USER
unset PCP_GROUP
# real QA test starts here
echo "=== \$PCP_DIR borked"
$PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
mkdir $tmp/etc
cp /etc/pcp.env $tmp/etc/pcp.env
$PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
echo
echo "=== missing vars from pcp.conf"
touch $tmp/etc/pcp.conf
echo "PCP_FOO=bar" >>$tmp/etc/pcp.conf
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
echo "PCP_USER=pcpqa" >>$tmp/etc/pcp.conf
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
echo "PCP_GROUP=pcpqa" >>$tmp/etc/pcp.conf
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
echo "PCP_RUN_DIR=$tmp/run" >>$tmp/etc/pcp.conf
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
echo
echo "=== \$PCP_RUN_DIR missing"
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
ls -ld $tmp/run | _filter_ls -s | _filter
echo
echo "=== \$PCP_RUN_DIR exists and OK, so do nothing"
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
ls -ld $tmp/run | _filter_ls -s | _filter
echo
echo "=== \$PCP_RUN_DIR exists but various problems ..."
echo "--- wrong user"
iam=`id -u`
$sudo chown $iam:pcpqa $tmp/run
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
ls -ld $tmp/run | _filter_ls -s | _filter
echo "--- wrong group"
iam=`id -g`
$sudo chown pcpqa:$iam $tmp/run
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
ls -ld $tmp/run | _filter_ls -s | _filter
echo "--- wrong mode"
$sudo chmod 755 $tmp/run
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
ls -ld $tmp/run | _filter_ls -s | _filter
# success, all done
exit
|