pmaports/main/postmarketos-base/postmarketos-base.post-upgrade
Pablo Correa Gómez 1229616e21
main/postmarketos-base: add service to mount /tmp as tmpfs (MR 4588)
And enable it by default, since it's a sensible thing to do.

This makes the bootmisc config file unnecessary, since it was only
used before to make sure that /tmp was wiped on every boot.

Mounting /tmp as a tmpfs will be skipped if:
* The user or maintainer configured deviceinfo_tmp_as_tmpfs_size=0
* If they didn't but the device has less than 2GB of RAM
* And in any case, if it is already mounted, to respect users that
  might have it in /etc/fstab

The options for mounting /tmp has been copied from my local debian
tmp.mount service. The only real difference is that we are mounting it
after /etc/fstab, and they do so before.

Fixes #2233
2023-12-21 17:38:45 +01:00

51 lines
2.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)
# 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
# To disable mounting /tmp as tmpfs deviceinfo_tmp_as_tmpfs_size="0"
rc-update -q add tmpfs default
exit 0