alien-everywhere/automation/scripts/aliendalvik-config

63 lines
2.0 KiB
Plaintext
Raw Permalink Normal View History

2023-12-20 10:44:46 +00:00
#!/bin/sh
set -e
active_wayland_user=
active_wayland_uid=
while true; do
for session in $(loginctl list-sessions --no-legend | awk '{ print $1 }'); do
if [ "$(loginctl show-session --value -p Type ${session})" != "wayland" ]; then
continue
fi
if [ "$(loginctl show-session --value -p Class ${session})" != "user" ]; then
continue
fi
if [ "$(loginctl show-session --value -p Remote ${session})" != "no" ]; then
continue
fi
if [ "$(loginctl show-session --value -p State ${session})" != "active" ]; then
continue
fi
active_wayland_user="$(loginctl show-session --value -p Name ${session})"
active_wayland_uid="$(loginctl show-session --value -p User ${session})"
break
done
if [ "${active_wayland_user}" == "" ]; then
echo "No active wayland session found, waiting for one"
sleep 5
continue
fi
if [ ! -S "/run/user/${active_wayland_uid}/wayland-0" ]; then
echo "No wayland socket for user ${active_wayland_user} found, waiting a bit longer"
sleep 2
continue
fi
break
done
chown ${active_wayland_user}:aliendalvik-wayland /run/user/${active_wayland_uid}/wayland-0
2023-12-20 10:44:46 +00:00
chmod 775 /run/user/${active_wayland_uid}/wayland-0
rm -f /tmp/aliendalvik/config/*
mkdir -p /tmp/aliendalvik/config/
cp -r /opt/alien/lxc-config/* /tmp/aliendalvik/config/
2023-12-20 10:44:46 +00:00
sed -i "s/__UID__/${active_wayland_uid}/g" /tmp/aliendalvik/config/10-bsp_config
sed -i "s/__UID__/${active_wayland_uid}/g" /tmp/aliendalvik/config/20-privilege_config
2023-12-20 10:44:46 +00:00
mkdir -p /home/${active_wayland_user}/.local/share/aliendalvik/data/
chown ${active_wayland_user}:${active_wayland_user} /home/${active_wayland_user}/.local/share/aliendalvik/
2023-12-20 10:44:46 +00:00
data_dir="/home/${active_wayland_user}/.local/share/aliendalvik/data/"
chown aliendalvik-root:aliendalvik-root ${data_dir}
2023-12-20 10:44:46 +00:00
sed -i "s|__DATA_DIR__|${data_dir}|g" /tmp/aliendalvik/config/10-bsp_config