2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4 TEST_DESCRIPTION="cryptsetup systemd setup"
6 . $TEST_BASE_DIR/test-functions
10 mkdir -p $TESTDIR/root
11 mount ${LOOPDEV}p1 $TESTDIR/root
12 [[ -e $TESTDIR/root/testok ]] && ret=0
13 [[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
14 cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
15 mount /dev/mapper/varcrypt $TESTDIR/root/var
16 [[ -f $TESTDIR/root/var/log/journal ]] && cp -a $TESTDIR/root/var/log/journal $TESTDIR
17 umount $TESTDIR/root/var
19 cryptsetup luksClose /dev/mapper/varcrypt
20 [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
21 ls -l $TESTDIR/journal/*/*.journal
22 test -s $TESTDIR/failed && ret=$(($ret+1))
29 check_result_qemu || return 1
31 dwarn "can't run QEMU, skipping"
38 echo -n test >$TESTDIR/keyfile
39 cryptsetup -q luksFormat ${LOOPDEV}p2 $TESTDIR/keyfile
40 cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
41 mkfs.ext3 -L var /dev/mapper/varcrypt
42 mkdir -p $TESTDIR/root
43 mount ${LOOPDEV}p1 $TESTDIR/root
44 mkdir -p $TESTDIR/root/var
45 mount /dev/mapper/varcrypt $TESTDIR/root/var
47 # Create what will eventually be our root filesystem onto an overlay
50 eval $(udevadm info --export --query=env --name=/dev/mapper/varcrypt)
51 eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
53 setup_basic_environment
55 # setup the testsuite service
56 cat >$initdir/etc/systemd/system/testsuite.service <<EOF
58 Description=Testsuite service
59 After=multi-user.target
62 ExecStart=/bin/bash -c 'set -x; systemctl --failed --no-legend --no-pager > /failed ; echo OK > /testok; while : ;do systemd-cat echo "testsuite service waiting for /var/log/journal" ; echo "testsuite service waiting for journal to move to /var/log/journal" > /dev/console ; for i in /var/log/journal/*;do [ -d "\$i" ] && echo "\$i" && break 2; done; sleep 1; done; sleep 1; exit 0;'
69 generate_module_dependencies
70 cat >$initdir/etc/crypttab <<EOF
71 $DM_NAME UUID=$ID_FS_UUID /etc/varkey
73 echo -n test > $initdir/etc/varkey
74 cat $initdir/etc/crypttab | ddebug
76 cat >>$initdir/etc/fstab <<EOF
77 /dev/mapper/varcrypt /var ext3 defaults 0 1
82 ddebug "umount $TESTDIR/root/var"
83 umount $TESTDIR/root/var
84 cryptsetup luksClose /dev/mapper/varcrypt
85 ddebug "umount $TESTDIR/root"
90 umount $TESTDIR/root/var 2>/dev/null
91 [[ -b /dev/mapper/varcrypt ]] && cryptsetup luksClose /dev/mapper/varcrypt
92 umount $TESTDIR/root 2>/dev/null
93 [[ $LOOPDEV ]] && losetup -d $LOOPDEV