Debian Codegraph @

debian/tests/testsshmail

raw
1 #!/bin/sh
2
3 set -efu
4
5 if [ -z "$AUTOPKGTEST_TMP" ]; then
6 AUTOPKGTEST_TMP=tmp
7 mkdir -p ${AUTOPKGTEST_TMP}
8 fi
9
10 SRCDIR=$(pwd)
11
12 cp -rv ${SRCDIR}/debian/tests ${AUTOPKGTEST_TMP}
13 cd ${AUTOPKGTEST_TMP}/tests
14
15 user_login=""
16
17 ./user.py > user.log
18 while read pass login; do
19 user_login=$login
20 user_pass=$pass
21 sed -e "s/login/$login/" -e "s/passw/$pass/" offlinerc > /home/${user_login}/offlinerc.test
22 done < user.log
23 echo "preauthtunnel = ssh -p 22222 -i /home/${user_login}/testkey ${user_login}@localhost '/usr/lib/dovecot/imap'" >> /home/${user_login}/offlinerc.test
24 usermod -aG dovecot $user_login
25 usermod -aG dovenull $user_login
26 echo "Port 22222" >> /etc/ssh/sshd_config
27 systemctl status ssh.service 2> /tmp/ssh.log
28 in_chroot=`cat /tmp/ssh.log | grep "Running in chroot, ignoring command" | wc -l`
29 if [ $in_chroot -eq 0 ]; then
30 systemctl restart ssh.service
31 systemctl status ssh.service
32 else
33 /etc/init.d/ssh restart
34 /etc/init.d/ssh status
35 fi
36 #start dovecot if its not running
37 if [ ! -f /run/dovecot/master.pid ]; then
38 dovecot
39 fi
40 sleep 5
41 # wait for dovecot to start running
42 for i in `seq 1 5`; do
43 doveadm -f flow instance list | grep -q 'running=yes'
44 if [ $? -eq 0 ]; then
45 break
46 fi
47 sleep 5
48 done
49 echo "this is test mail to test offlineimap" | mail -s "testmail" ${user_login}
50 echo "this is another test mail" | mail -s "second test" ${user_login}
51 sleep 1
52 cd /home/${user_login}
53 su ${user_login} -c "ssh-keygen -f testkey -N \"\""
54 su ${user_login} -c "mkdir -p ~/.ssh"
55 su ${user_login} -c "ssh-keyscan -p 22222 localhost > ~/.ssh/known_hosts"
56 su ${user_login} -c "sshpass -p ${user_pass} ssh-copy-id -p 22222 -i ~/testkey ${user_login}@localhost"
57 su ${user_login} -c "offlineimap --info -c offlinerc.test"
58 su ${user_login} -c "offlineimap -o -c offlinerc.test"
59 for flname in `ls /home/${user_login}/Test/INBOX/new`; do
60 echo ""
61 cat /home/${user_login}/Test/INBOX/new/${flname}
62 done
63 dovecot stop
64 userdel -f ${user_login}