Path: blob/master/pkg/cidata/cidata.TEMPLATE.d/boot/10-alpine-prep.sh
2658 views
#!/bin/sh12# SPDX-FileCopyrightText: Copyright The Lima Authors3# SPDX-License-Identifier: Apache-2.045set -eux67# This script prepares Alpine for lima; there is nothing in here for other distros8test -f /etc/alpine-release || exit 0910# Configure apk repos11BRANCH=edge12VERSION_ID=$(awk -F= '$1=="VERSION_ID" {print $2}' /etc/os-release)13case ${VERSION_ID} in14*_alpha* | *_beta*) BRANCH=edge ;;15*.*.*) BRANCH=v${VERSION_ID%.*} ;;16esac1718for REPO in main community; do19URL="https://dl-cdn.alpinelinux.org/alpine/${BRANCH}/${REPO}"20if ! grep -q "^${URL}$" /etc/apk/repositories; then21echo "${URL}" >>/etc/apk/repositories22fi23done2425# Alpine comes with doas instead of sudo26if ! command -v sudo >/dev/null 2>&1; then27apk add sudo28fi2930# Alpine doesn't use PAM so we need to explicitly allow public key auth31usermod -p '*' "${LIMA_CIDATA_USER}"3233# Alpine disables TCP forwarding, which is needed by the lima-guestagent34sed -i 's/AllowTcpForwarding no/AllowTcpForwarding yes/g' /etc/ssh/sshd_config35# Enable PAM so as to load /etc/environment via pam_env36sed -i 's/#UsePAM no/UsePAM yes/g' /etc/ssh/sshd_config37rc-service --ifstarted sshd reload3839# mount /sys/fs/cgroup40rc-service cgroups start4142# `limactl stop` tells acpid to powerdown43rc-update add acpid44rc-service acpid start454647