Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lima-vm
GitHub Repository: lima-vm/lima
Path: blob/master/pkg/cidata/cidata.TEMPLATE.d/boot/10-alpine-prep.sh
2658 views
1
#!/bin/sh
2
3
# SPDX-FileCopyrightText: Copyright The Lima Authors
4
# SPDX-License-Identifier: Apache-2.0
5
6
set -eux
7
8
# This script prepares Alpine for lima; there is nothing in here for other distros
9
test -f /etc/alpine-release || exit 0
10
11
# Configure apk repos
12
BRANCH=edge
13
VERSION_ID=$(awk -F= '$1=="VERSION_ID" {print $2}' /etc/os-release)
14
case ${VERSION_ID} in
15
*_alpha* | *_beta*) BRANCH=edge ;;
16
*.*.*) BRANCH=v${VERSION_ID%.*} ;;
17
esac
18
19
for REPO in main community; do
20
URL="https://dl-cdn.alpinelinux.org/alpine/${BRANCH}/${REPO}"
21
if ! grep -q "^${URL}$" /etc/apk/repositories; then
22
echo "${URL}" >>/etc/apk/repositories
23
fi
24
done
25
26
# Alpine comes with doas instead of sudo
27
if ! command -v sudo >/dev/null 2>&1; then
28
apk add sudo
29
fi
30
31
# Alpine doesn't use PAM so we need to explicitly allow public key auth
32
usermod -p '*' "${LIMA_CIDATA_USER}"
33
34
# Alpine disables TCP forwarding, which is needed by the lima-guestagent
35
sed -i 's/AllowTcpForwarding no/AllowTcpForwarding yes/g' /etc/ssh/sshd_config
36
# Enable PAM so as to load /etc/environment via pam_env
37
sed -i 's/#UsePAM no/UsePAM yes/g' /etc/ssh/sshd_config
38
rc-service --ifstarted sshd reload
39
40
# mount /sys/fs/cgroup
41
rc-service cgroups start
42
43
# `limactl stop` tells acpid to powerdown
44
rc-update add acpid
45
rc-service acpid start
46
47