pmaports/main/postmarketos-base/postmarketos-base.post-upgrade
Caleb Connolly 7efcec020d
postmarketos-base: disable openrc syslog service (MR 4617)
Ensure that we don't have two logging daemons running!

Signed-off-by: Caleb Connolly <caleb@connolly.tech>
2023-12-15 23:15:55 +00:00

49 lines
2 KiB
Bash

#!/bin/sh
# WARNING: do not symlink this file to postmarketos-base.post-install!
# Otherwise it will enable services, as listed in that file. And we don't want
# this to happen during upgrade, especially not automatically enabling the sshd
# service! (build.postmarketos.org#85)
# The old version of the package is passed in as the second argument
OLD_VER="$2"
NEW_VER="$1"
old_ver_less() {
[ "$OLD_VER" != "$1" -a "$(echo -e "$1\n$OLD_VER" | sort -V | head -n1)" = "$OLD_VER" ]
}
# postmarketos-base version 30 moved us to logbookd but we forgot to disable
# syslog... The easiest way to solve this is to just do the upgrade again, sorry
# to anyone who manually disabled logbookd again...
if old_ver_less "31-r1"; then
echo "## postmarketos-base migrating to logbookd ##"
echo "## The initial upgrade didn't disable syslog, we're doing that now ##"
echo "## If you want to keep using syslog, undo the following changes ##"
set -x
rc-update add logbookd boot
rc-update del syslog boot
set +x
fi
# Fixup old pmOS installations that run setup-timezone without "-i" option
# and those later installations that run with it, but have missing
# https://gitlab.alpinelinux.org/alpine/alpine-conf/-/merge_requests/157
# See https://gitlab.com/postmarketOS/pmaports/-/issues/2168 for context
# This is probably safe to remove after a couple of releases of the alpine-conf
# fix having been merged
[ -L /etc/localtime ] || exit 0
localtime="$(readlink /etc/localtime)"
restart="yes"
case "$localtime" in
//usr/share/zoneinfo/*) localtime=${localtime#/*} ;;
//etc/zoneinfo*) localtime="/usr/share/zoneinfo/${localtime#//etc/zoneinfo/*}" ;;
/etc/zoneinfo/*) localtime="/usr/share/zoneinfo/${localtime#/etc/zoneinfo/*}" ;;
*) restart="no" ;;
esac
ln -sf "$localtime" /etc/localtime
rm -rf /etc/zoneinfo
[ "$restart" = "yes" ] && service -qq openrc-settingsd restart
# To turn zram-init into a no-op, set: deviceinfo_zram_swap_pct="0"
rc-update -q add zram-init default
exit 0