Skip to content

Commit

Permalink
Fix permissions on mastodon.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
dhelonious committed Sep 16, 2024
1 parent 09e39df commit 805a228
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion snap/hooks/configure
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if [ "$BACKUP_DIR" != "$CURRENT_BACKUP_DIR" ]; then
update_backup_dir_file
fi

if $(mastodon_config_exists); then
if mastodon_config_exists; then
# TODO: remove later, required for upgrade to Mastodon 4.3+
if [ -z "$ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY" ] \
|| [ -z "$ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY" ] \
Expand Down
6 changes: 4 additions & 2 deletions snap/hooks/post-refresh
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ copy_config_as_daemon_user redis redis.conf
# NOTE: This is a fix for older versions and may be removed in the future
echo Set permissions on mastodon files and dirs
fix_daemon_user "$SNAP_DATA/mastodon"
fix_daemon_user "$SNAP_COMMON/mastodon.conf"
fix_daemon_user "$MEDIA_DIR"
fix_daemon_user "$LOG_DIR/backend.log"
fix_daemon_user "$LOG_DIR/streaming.log"
fix_daemon_user "$LOG_DIR/sidekiq.log"
if mastodon_config_exists; then
chmod 664 "$SNAP_COMMON/mastodon.conf"
fi

if [ "$SNAP_VERSION" != "$CURRENT_SNAP_VERSION" ]; then
echo Update mastodon
update_mastodon_files

if $(mastodon_config_exists); then
if mastodon_config_exists; then
echo Update mastodon config
link_mastodon_config
upgrade_mastodon_config
Expand Down
2 changes: 1 addition & 1 deletion src/mastodon/bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

check_root

if $(mastodon_config_exists); then
if mastodon_config_exists; then
echo_error "Mastodon is already set up"
exit 0
fi
Expand Down
6 changes: 3 additions & 3 deletions src/mastodon/mastodon.env
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ mastodon_config_exists() {
}

mastodon_get_var() {
if $(mastodon_config_exists); then
if mastodon_config_exists; then
sed -rn "s,^.*$1=([^ ]*|'[^']*'|"'"[^"]*"'").*$,\1,p" "$SNAP_COMMON/mastodon.conf"
fi
}

mastodon_set_var() {
if $(mastodon_config_exists); then
if mastodon_config_exists; then
if grep -qF "$1=" "$SNAP_COMMON/mastodon.conf"; then
$SNAP/bin/sed_inline "s,$1=([^ ]*|'[^']*'|"'"[^"]*"'"),$1=$2," "$SNAP_COMMON/mastodon.conf"
else
Expand Down Expand Up @@ -104,7 +104,7 @@ mastodon_tootctl() {
}

check_setup() {
if ! $(mastodon_config_exists); then
if ! mastodon_config_exists; then
echo "Mastodon is not yet set up"
exit 0
fi
Expand Down

0 comments on commit 805a228

Please sign in to comment.