Skip to content

Instantly share code, notes, and snippets.

@icedream
Last active March 7, 2022 17:45
Show Gist options
  • Save icedream/40d134cd7b19fd470a76b26f517c860a to your computer and use it in GitHub Desktop.
Save icedream/40d134cd7b19fd470a76b26f517c860a to your computer and use it in GitHub Desktop.
SteamOS SSH preparation
#!/bin/bash
set -e
set -u
# following stuff kinda copied from /usr/bin/steamos-chroot
[ -e /usr/lib/steamos/steamos-partitions-lib ] && \
. /usr/lib/steamos/steamos-partitions-lib || \
{ echo "Failed to source '/usr/lib/steamos/steamos-partitions-lib'"; exit 1; }
DISK=/dev/nvme0n1
ROOTFS_DEVICE=
prepare_chroot_at() {
local dir=$1
mount -o rw "$ROOTFS_DEVICE" $dir
mount --bind /dev $dir/dev
mount --bind /proc $dir/proc
mount --bind /run $dir/run
mount --bind /sys $dir/sys
mount --bind /sys/firmware/efi/efivars $dir/sys/firmware/efi/efivars
mount -t tmpfs -o size=128M tmpfs $dir/tmp
#mount "$EFI_DEVICE" $dir/efi
#mount "$ESP_DEVICE" $dir/esp
#mount "$VAR_DEVICE" $dir/var
if [ -d $dir/var/boot ]; then
mount --bind $dir/var/boot $dir/boot
fi
}
for partset in A B
do
ROOTFS_DEVICE=$(get_device_by_partlabel $DISK rootfs-$partset)
mkdir /mnt/steamos -p
# just in case we failed to unmount in a previous iteration of this script
sudo umount -R /mnt/steamos || true
echo "Mounting partset $partset…" >&2
prepare_chroot_at /mnt/steamos
# enable SSH and set a password for deck user to log in with
echo "> Enabling SSH" >&2
chroot /mnt/steamos systemctl enable sshd
echo "> Setting deck user password to \"deck\"" >&2
echo "deck:deck" | chroot /mnt/steamos chpasswd
# force desktop session on bootup
echo "> Setting SteamOS session to plasma-persistent" >&2
chroot /mnt/steamos steamos-session-select plasma-persistent
echo "> Unmounting" >&2
sudo umount -R /mnt/steamos
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment