-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·78 lines (66 loc) · 2.07 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env sh
set -e
if [ "$(id -u)" -eq 0 ]; then
echo "Script must not be ran as root"
exit 1
fi
USER="$(whoami)"
if [ -z "${USER}" ]; then
echo "Could not determine current user"
exit 1
fi
mkdir -p "${HOME}/.config/megapixels"
rm -f "${HOME}/.config/megapixels/postprocess.sh"
ln -s "${PWD}/postprocess.sh" "${HOME}/.config/megapixels/postprocess.sh"
chmod +x "${HOME}/.config/megapixels/postprocess.sh"
# Switch to root
sudo -s <<EOF
if [ ! -e /etc/nsswitch.conf ]; then
echo 'hosts: files dns' > /etc/nsswitch.conf
fi
# If /etc/subgid or /etc/subuid do not exist, create them
if [ ! -f /etc/subgid ]; then
touch /etc/subgid
fi
if [ ! -f /etc/subuid ]; then
touch /etc/subuid
fi
if ! command -v "bash" > /dev/null; then
if command -v "pacman" >/dev/null; then
pacman -Sy bash
elif command -v "apk" >/dev/null; then
apk update
apk add bash
elif command -v "apt" >/dev/null; then
apt update
apt install bash
else
echo "Unknown package manager, bash needs to be install via your preferred method"
fi
fi
if ! command -v "podman" >/dev/null; then
if command -v "pacman" >/dev/null; then
pacman -Sy podman fuse-overlayfs --noconfirm
elif command -v "apk" >/dev/null; then
apk update
apk add podman fuse-overlayfs shadow slirp4netns
rc-update add cgroups
rc-service cgroups start
modprobe tun
elif command -v "apt" >/dev/null; then
apt update
apt install podman fuse-overlayfs slirp4netns
else
echo "Unknown package manager, podman needs to be install via your preferred method"
fi
fi
# If $USER is not in /etc/subgid or /etc/subuid
if ! grep -q "^${USER}:100000" /etc/subgid || ! grep -q "^${USER}:100000" /etc/subuid; then
chmod u+s /usr/bin/newuidmap
chmod u+s /usr/bin/newgidmap
echo "Adding ${USER} to /etc/subgid and /etc/subuid"
usermod --add-subuids 100000-165535 --add-subgids 100000-165535 "${USER}"
echo "User permisisons adjusted, reboot machine afterwards"
fi
podman system migrate
EOF