2020-03-04 12:35:06 +03:00
#!/usr/bin/env bash
2021-04-09 20:39:41 +03:00
set -eux
2019-07-07 18:30:15 +03:00
set -o pipefail
# Check if homectl is installed, and if it isn't bail out early instead of failing
if ! test -x /usr/bin/homectl ; then
2021-04-08 01:09:55 +03:00
echo OK >/testok
2019-07-07 18:30:15 +03:00
exit 0
fi
inspect( ) {
2021-04-08 11:34:53 +03:00
# As updating disk-size-related attributes can take some time on some
# filesystems, let's drop these fields before comparing the outputs to
# avoid unexpected fails. To see the full outputs of both homectl &
# userdbctl (for debugging purposes) drop the fields just before the
# comparison.
2021-04-09 20:49:32 +03:00
local USERNAME = " ${ 1 : ?missing argument } "
homectl inspect " $USERNAME " | tee /tmp/a
userdbctl user " $USERNAME " | tee /tmp/b
2021-04-08 11:34:53 +03:00
diff -I '/^\s*Disk (Size|Free|Floor|Ceiling):/' /tmp/{ a,b}
rm /tmp/{ a,b}
2019-07-07 18:30:15 +03:00
}
systemd-analyze log-level debug
systemd-analyze log-target console
NEWPASSWORD = xEhErW0ndafV4s homectl create test-user --disk-size= 20M
inspect test-user
PASSWORD = xEhErW0ndafV4s homectl authenticate test-user
PASSWORD = xEhErW0ndafV4s homectl activate test-user
inspect test-user
PASSWORD = xEhErW0ndafV4s homectl update test-user --real-name= "Inline test"
inspect test-user
homectl deactivate test-user
inspect test-user
PASSWORD = xEhErW0ndafV4s NEWPASSWORD = yPN4N0fYNKUkOq homectl passwd test-user
inspect test-user
PASSWORD = yPN4N0fYNKUkOq homectl activate test-user
inspect test-user
SYSTEMD_LOG_LEVEL = debug PASSWORD = yPN4N0fYNKUkOq NEWPASSWORD = xEhErW0ndafV4s homectl passwd test-user
inspect test-user
homectl deactivate test-user
inspect test-user
PASSWORD = xEhErW0ndafV4s homectl activate test-user
inspect test-user
PASSWORD = xEhErW0ndafV4s homectl deactivate test-user
inspect test-user
PASSWORD = xEhErW0ndafV4s homectl update test-user --real-name= "Offline test"
inspect test-user
PASSWORD = xEhErW0ndafV4s homectl activate test-user
inspect test-user
PASSWORD = xEhErW0ndafV4s homectl deactivate test-user
inspect test-user
2021-04-08 11:34:28 +03:00
PASSWORD = xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz
PASSWORD = xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz \
&& { echo 'unexpected success' ; exit 1; }
2019-07-07 18:30:15 +03:00
PASSWORD = xEhErW0ndafV4s homectl with test-user -- touch /home/test-user/xyz
PASSWORD = xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz
PASSWORD = xEhErW0ndafV4s homectl with test-user -- rm /home/test-user/xyz
2021-04-08 11:34:28 +03:00
PASSWORD = xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz
PASSWORD = xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz \
&& { echo 'unexpected success' ; exit 1; }
2019-07-07 18:30:15 +03:00
homectl remove test-user
systemd-analyze log-level info
2021-04-08 01:09:55 +03:00
echo OK >/testok
2019-07-07 18:30:15 +03:00
exit 0