2022-11-05 03:54:06 +00:00
|
|
|
#!/bin/sh
|
2023-06-22 03:36:51 +00:00
|
|
|
# It's very important to set user/group correctly.
|
2022-11-05 03:54:06 +00:00
|
|
|
|
2023-06-22 03:36:51 +00:00
|
|
|
mastodon_dir='/var/lib/mastodon'
|
|
|
|
|
|
|
|
if ! getent group mastodon 1>/dev/null; then
|
|
|
|
echo '* Creating group mastodon' 1>&2
|
|
|
|
|
|
|
|
addgroup -S mastodon
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! id mastodon 2>/dev/null 1>&2; then
|
|
|
|
echo '* Creating user mastodon' 1>&2
|
|
|
|
|
|
|
|
adduser -DHS -G mastodon -h "$mastodon_dir" -s /bin/sh \
|
|
|
|
-g "added by apk for mastodon" mastodon
|
|
|
|
passwd -u mastodon 1>/dev/null # unlock
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! id -Gn mastodon | grep -Fq redis; then
|
|
|
|
echo '* Adding user mastodon to group redis' 1>&2
|
|
|
|
|
|
|
|
addgroup mastodon redis
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$(id -gn mastodon)" != 'mastodon' ]; then
|
|
|
|
cat >&2 <<-EOF
|
|
|
|
!!
|
|
|
|
!! User mastodon has primary group $(id -gn mastodon). We strongly recommend to change
|
|
|
|
!! mastodon's primary group to mastodon.
|
|
|
|
!!
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Add it at least as a supplementary group.
|
|
|
|
adduser mastodon mastodon
|
|
|
|
fi
|
|
|
|
|
|
|
|
user_home="$(getent passwd mastodon | cut -d: -f6)"
|
|
|
|
|
|
|
|
if [ "$user_home" != "$mastodon_dir" ]; then
|
|
|
|
cat >&2 <<-EOF
|
|
|
|
!!
|
|
|
|
!! User mastodon has home directory in $user_home, but this package assumes
|
|
|
|
!! $mastodon_dir. Although it's possible to use a different directory,
|
|
|
|
!! it's really not easy.
|
|
|
|
!!
|
|
|
|
!! Please change mastodon's home directory to $mastodon_dir, or adjust settings
|
|
|
|
!! and move files yourself. Otherwise Mastodon will not work!
|
|
|
|
!!
|
|
|
|
EOF
|
|
|
|
fi
|
2022-11-05 03:54:06 +00:00
|
|
|
|
|
|
|
exit 0
|
|
|
|
|