summaryrefslogtreecommitdiff
path: root/pkg/utils/test_bootstrap
blob: f072d1065af91a0c53840dd575aa36df8da1f3a6 (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
#!/bin/bash
##############################################################################
#
# test_bootstrap
# --------------
# Test that the bootstrap script works correctly by making a temporary new
# user.
#
# @author Isis Agora Lovecruft, 0x2cdb8b35
# @date 18 February 2013
# @version 0.0.1
##############################################################################

set -ex -

HERE=$(pwd)
TEST_USER=bootstraptester

echo "Creating new user: "'"'"${TEST_USER}"'"'""
sudo adduser --home /home/${TEST_USER} --shell /bin/bash ${TEST_USER} && \
    echo -e "notsecure\nnotsecure\n" | sudo passwd ${TEST_USER}

echo 'Copying boostrap script to new user home directory...'
sudo cp ${HERE}/bootstrap /home/${TEST_USER}/bootstrap && \
    sudo chown ${TEST_USER}:${TEST_USER} /home/${TEST_USER}/bootstrap

echo 'Logging in as new user and executing bootstrap script...'
echo 'Executing test of bootstrap script...'
## -S pulls password from stdin
echo -e "notsecure\n" | sudo -S -H -u ${TEST_USER} -i /home/${TEST_USER}/bootstrap

if [[ "$?" != 0 ]] ; then
    echo 'Error while testing bootstrap...'
else
    echo 'Test of bootstrap successful.'
fi

echo "Deleting user: "'"'"${TEST_USER}"'"'""
sudo deluser --remove-home ${TEST_USER}