blob: 15e15682b5eb73b953180bc165d460f508e54803 (
plain)
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
|
#!/bin/sh
SCRIPT_DIR=$(dirname $(readlink -f "$0"))
# check user
USERNAME=`whoami`
I_AM_ROOT=n
if [ "${USERNAME}" = "root" ]; then
I_AM_ROOT=y
fi
# check if polkit files need to be copied
DEST_FILE="/usr/share/polkit-1/actions/org.tqt.policykit.examples.policy"
FILE_EXISTS='n'
if [ -f "${DEST_FILE}" ]; then
FILE_EXISTS='y'
fi
if [ "${I_AM_ROOT}" = "y" ]; then
if [ "${FILE_EXISTS}" = "n" ]; then
cp "${SCRIPT_DIR}/../examples/org.tqt.policykit.examples.policy" "${DEST_FILE}"
fi
useradd testuser
sudo -u testuser $1
retval=$?
userdel testuser
if [ "${FILE_EXISTS}" = "n" ]; then
rm "${DEST_FILE}"
fi
else
if [ "${FILE_EXISTS}" = "y" ]; then
# Required file already exist, can do the test
$1
retval=$?
else
echo "This test requires file ${DEST_FILE} to exists. Skipping test."
retval=0
fi
fi
if [ ${retval} = 0 ]; then
echo "Test passed."
else
echo "Test failed."
fi
exit $retval
|