This repository has been archived by the owner on Jul 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup-phase-1-2.sh
executable file
·175 lines (157 loc) · 7.63 KB
/
setup-phase-1-2.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash
source ./env.sh
source ./helper-functions.sh
source ./setup-env.sh
function phase1_lilipod_distrobox_install() {
echor "Phase 1"
cd "$prefix" || {
echor "Couldn't go into installation folder on phase 1, aborting."
exit 1
}
if [ ! -s "/etc/subgid" ] || [ ! -s "/etc/subuid" ]; then # only manjaro had those files missing so far
echor "You seem to be missing subgid or subuid which is required for rootless containers to work"
echog "I can create those for you, next sudo prompt will ask for permissions from you to do so."
echog "Confirm if you're okay with proceesing (y/N)"
read -r confirm
if [[ $confirm != "y" ]] && [[ $confirm != "Y" ]]; then
echor "User has not confirmed creation of gid/uid, can't complete installation, exiting."
exit 1
fi
echo "$USER:100000:65536" | sudo tee /etc/subuid
echo "$USER:100000:65536" | sudo tee /etc/subgid
fi
echog "Using shipped getsubids"
cp "../getsubids" "$prefix/bin/"
if [[ "$(which getsubids)" != "$prefix/bin/getsubids" ]]; then
echor "Failed to install getsubids properly"
exit 1
fi
echog "Installing lilipod"
wget -O lilipod "https://github.com/89luca89/lilipod/releases/download/$lilipod_version/lilipod-linux-amd64" || exit 1
chmod +x lilipod
mkdir -p "$prefix/bin" || exit 1
mv lilipod "$prefix/bin" || exit 1
echog "Installing distrobox"
curl -OL "https://github.com/89luca89/distrobox/archive/$distrobox_version.zip" || exit 1
unzip "$distrobox_version.zip" || (
echor "Please install unzip on your system."
exit 1
) || exit 1
{
cd distrobox-$distrobox_version* || exit 1
./install --prefix "$prefix" || exit 1
cd ..
}
# distrobox-enter has bug with unshare_groups and lilipod (lilipod probably doesnt support them) https://github.com/89luca89/distrobox/pull/1261
sed -i 's/unshare_groups={{ index .Config.Labels "distrobox.unshare_groups" }};//g' "$prefix/bin/distrobox-enter"
cd ..
}
function phase2_distrobox_container_creation() {
echor "Phase 2"
GPU=$(detect_gpu)
AUDIO_SYSTEM=$(detect_audio)
# Sanity checks after phase 1
if [[ "$(which lilipod)" != "$prefix/bin/lilipod" ]]; then
echor "Failed to install lilipod properly"
exit 1
fi
if [[ "$(which distrobox)" != "$prefix/bin/distrobox" ]]; then
echor "Failed to install distrobox properly"
exit 1
fi
write_json gpu "$GPU" "$prefix/specs.json"
if [[ "$GPU" == "amd" ]] || [[ "$GPU" == "intel" ]]; then
distrobox create --pull --image docker.io/archlinux/archlinux:latest \
--name "$container_name" \
--home "$prefix/$container_name" \
--pre-init-hooks "pacman -Syy reflector --noconfirm && reflector --country 'Canada,United States,France,Germany,Australia' --latest 5 --sort rate --save /etc/pacman.d/mirrorlist"
elif [[ "$GPU" == nvidia* ]]; then
CUDA_LIBS="$(find /usr/lib* -iname "libcuda*.so*")"
if [[ -z "$CUDA_LIBS" ]]; then
echor "Couldn't find CUDA on host, please install it, reboot and try again, as it's required for NVENC encoder support."
exit 1
fi
distrobox create --pull --image docker.io/archlinux/archlinux:latest \
--name "$container_name" \
--home "$prefix/$container_name" \
--nvidia \
--pre-init-hooks "pacman -Syy reflector --noconfirm && reflector --country 'Canada,United States,France,Germany,Australia' --latest 5 --sort rate --save /etc/pacman.d/mirrorlist"
else
echor "Unsupported gpu found, can't proceed. Please report setup.log to https://github.com/alvr-org/ALVR-Distrobox-Linux-Guide/issues."
exit 1
fi
if [ $? -ne 0 ]; then
echor "Couldn't create distrobox container, please report setup.log to https://github.com/alvr-org/ALVR-Distrobox-Linux-Guide/issues."
echor "GPU: $GPU; AUDIO SYSTEM: $AUDIO_SYSTEM"
exit 1
fi
write_json audio "$AUDIO_SYSTEM" "$prefix/specs.json"
if [[ "$AUDIO_SYSTEM" == "pulse" ]]; then
echor "Do note that pulseaudio won't work with automatic microphone routing as it requires pipewire."
elif [[ "$AUDIO_SYSTEM" != "pipewire" ]]; then
echor "Unsupported audio system ($AUDIO_SYSTEM). please report setup.log to https://github.com/alvr-org/ALVR-Distrobox-Linux-Guide/issues."
exit 1
fi
distrobox enter --name "$container_name" --additional-flags "--env XDG_CURRENT_DESKTOP=X-Generic --env LANG=en_US.UTF-8 --env LC_ALL=en_US.UTF-8" -- ./setup-phase-3.sh
if [ $? -ne 0 ]; then
echor "Couldn't install distrobox container first time at phase 3, please report setup.log to https://github.com/alvr-org/ALVR-Distrobox-Linux-Guide/issues."
# envs are required! otherwise first time install won't have those env vars, despite them being even in bashrc, locale conf, profiles, etc
exit 1
fi
distrobox stop "$container_name" --yes
distrobox enter --name "$container_name" --additional-flags "--env PATH=$prefix/$container_name/alvr_streamer_linux/usr/bin:$PATH --env XDG_CURRENT_DESKTOP=X-Generic --env LANG=en_US.UTF-8 --env LC_ALL=en_US.UTF-8" -- ./setup-phase-4.sh
if [ $? -ne 0 ]; then
echor "Couldn't install distrobox container first time at phase 4, please report setup.log to https://github.com/alvr-org/ALVR-Distrobox-Linux-Guide/issues."
# envs are required! otherwise first time install won't have those env vars, despite them being even in bashrc, locale conf, profiles, etc
exit 1
fi
}
function sanity_checks() {
if [ "$EUID" -eq 0 ]; then
echo "Please don't run this script as root (no sudo)."
exit 1
fi
if [[ -e "$prefix/$container_name" ]]; then
echor "You're trying to overwrite previous installation with new installation, please use uninstall.sh first"
exit 1
fi
if [[ "$prefix" =~ \ ]]; then
echor "File path to container can't contains spaces as SteamVR will fail to launch if path to it contains spaces."
echor "Please clone or unpack repository into another directory that doesn't contain spaces."
exit 1
fi
if [ "$(detect_gpu_count)" -ne 1 ]; then
echog "Multi-gpu systems might not work with this installation, but script will still continue and attempt to work."
echog "For this to work on INTEL + NVIDIA setup you must use 'prime-run %command%' (without quotes) on each game commandline parameters in Steam."
echor "Please confirm that you have read line above and know what to do (y/N)"
read -r CONFIRM
if [[ $CONFIRM != "y" ]] && [[ $CONFIRM != "Y" ]]; then
echor "User has not acknowledged notice, exiting."
exit 1
fi
write_json multi_gpu 1 "$prefix/specs.json"
else
write_json multi_gpu 0 "$prefix/specs.json"
fi
disk_space=$(df -Pk . | sed 1d | grep -v used | awk '{ print $4 "\t" }')
disk_space=$((10#${disk_space} / 1024 / 1024))
write_json disk_space "$disk_space" "$prefix/specs.json"
if ((disk_space < 15)); then
echor "Installation might require up to least 15 gb during installation (steamvr + alvr build)."
echor "You have less than 15 gb of free space available, please free up space for installation."
exit 1
fi
}
function install_jq() {
# Install jq to local PATH for script
mkdir -p "$prefix/bin"
wget -q --show-progress -O "$prefix/bin/jq" https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64
chmod +x "$prefix/bin/jq"
}
install_jq
sanity_checks
# Prevent host steam to be used during install, forcefully kill it (on steamos produces output like it tries to kill host processes and fails, fixme?...)
pkill -f steam
log_system
phase1_lilipod_distrobox_install
phase2_distrobox_container_creation