pmaports/main/postmarketos-base/postmarketos-base.post-upgrade
Pablo Correa Gómez 04abb5b1a7
main/postmarketos-base: migrate wrong timezone configurations (MR 4308)
So that old installations that run setup-timezone without "-i" do not
need to execute manual steps to get sensible timezone configurations.

See https://gitlab.com/postmarketOS/pmaports/-/issues/2168 for more context

Fixes #2168
[ci:skip-build]: already built successfully in CI
2023-08-07 09:41:53 +02:00

26 lines
1.1 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)
# 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
exit 0