mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
Imported scripts, configuration files and examples from a private repository
This commit is contained in:
49
examples/archlinux/enable-hibernation-from-swapfile.sh
Normal file
49
examples/archlinux/enable-hibernation-from-swapfile.sh
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
|
||||
# enable hibernation from a swapfile on btrfs
|
||||
|
||||
# source:
|
||||
# - https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate
|
||||
|
||||
sudo mkdir /swap
|
||||
|
||||
# disable copy-on-write and compression on the directory
|
||||
sudo chattr -R +C /swap
|
||||
sudo btrfs property set /swap compression none
|
||||
|
||||
# create the swapfile
|
||||
sudo fallocate -l 32GiB /swap/swapfile
|
||||
sudo chmod -R 600 /swap
|
||||
sudo mkswap --label swap /swap/swapfile
|
||||
sudo swapon /swap/swapfile
|
||||
|
||||
# configure swappiness
|
||||
sudo nano /etc/sysctl.d/swappiness
|
||||
sudo sysctl --load=/etc/sysctl.d/swappiness
|
||||
|
||||
# identify the swap device
|
||||
# value is to be used for the resume=UUID= kernel parameter
|
||||
sudo findmnt -no UUID -T /swap/swapfile
|
||||
|
||||
# identify the file offset
|
||||
# value is to be used for the resume_offset= kernel parameter
|
||||
curl --location --output /tmp/btrfs_map_physical.c https://raw.githubusercontent.com/osandov/osandov-linux/master/scripts/btrfs_map_physical.c
|
||||
gcc -O2 -o /tmp/btrfs_map_physical /tmp/btrfs_map_physical.c
|
||||
chmod a+x /tmp/btrfs_map_physical
|
||||
physical_offset=$(sudo /tmp/btrfs_map_physical /swap/swapfile | awk '$1==0 {print $NF}') # last column of the line starting with 0
|
||||
resume_offset=$(( ${physical_offset} / $(getconf PAGESIZE) ))
|
||||
|
||||
# configure the bootloader
|
||||
# GRUB_CMDLINE_LINUX_DEFAULT="quiet cryptdevice=UUID=... resume=UUID=bac7930a-924d-4e9d-83eb-ad6ce5a8100a resume_offset=1865170"
|
||||
sudo nano /etc/default/grub
|
||||
sudo grub-mkconfig -o /boot/grub/grub.cfg
|
||||
|
||||
# configure the mkinitcpio
|
||||
# not needed if using the systemd hook
|
||||
# add resume after filesystems: HOOKS=(base ... filesystems resume fsck)
|
||||
sudo nano /etc/mkinitcpio.conf
|
||||
mkinitcpio -p linux
|
||||
|
||||
# reboot
|
||||
|
||||
# check with `systemctl hibernate`
|
||||
173
examples/gentoo/install.virtualbox.sh
Executable file
173
examples/gentoo/install.virtualbox.sh
Executable file
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# sources
|
||||
# - https://wiki.gentoo.org/wiki/Handbook:AMD64
|
||||
# - https://wiki.gentoo.org/wiki/Localization/Guide
|
||||
|
||||
# start with gentoo live, with UEFI
|
||||
|
||||
# /etc/init.d/sshd start
|
||||
# passwd $complicated_password
|
||||
|
||||
sgdisk --zap-all /dev/sda
|
||||
sgdisk --clear /dev/sda
|
||||
|
||||
sgdisk --new 1:2048:+128M /dev/sda
|
||||
sgdisk --typecode 1:ef00 /dev/sda
|
||||
sgdisk --change-name 1:EFI /dev/sda
|
||||
mkfs.vfat -F 32 -n EFI /dev/sda1
|
||||
|
||||
sgdisk --new 2:+0M: /dev/sda
|
||||
sgdisk --change-name 2:ROOT /dev/sda
|
||||
mkfs.ext4 -F -L System /dev/sda2
|
||||
|
||||
mkdir -p /mnt/gentoo
|
||||
mount /dev/sda2 /mnt/gentoo
|
||||
mkdir -p /mnt/gentoo/boot
|
||||
chattr +i /mnt/gentoo/boot
|
||||
mount /dev/sda1 /mnt/gentoo/boot
|
||||
|
||||
hwclock --systohc
|
||||
ntpd -q -g
|
||||
|
||||
cd /mnt/gentoo
|
||||
|
||||
wget https://ftp.snt.utwente.nl/pub/os/linux/gentoo/releases/amd64/autobuilds/current-stage3-amd64-hardened/stage3-amd64-hardened-20210623T214504Z.tar.xz
|
||||
tar -xpf stage3-amd64-*.tar.xz
|
||||
rm -f stage3-amd64-*.tar.xz
|
||||
|
||||
wget https://ftp.snt.utwente.nl/pub/os/linux/gentoo/snapshots/portage-latest.tar.xz
|
||||
tar -xf portage-latest.tar.xz -C /mnt/gentoo/usr
|
||||
rm -f portage-latest.tar.xz
|
||||
|
||||
mount --types proc /proc /mnt/gentoo/proc
|
||||
mount --rbind /sys /mnt/gentoo/sys
|
||||
mount --make-rslave /mnt/gentoo/sys
|
||||
mount --rbind /dev /mnt/gentoo/dev
|
||||
mount --make-rslave /mnt/gentoo/dev
|
||||
|
||||
cp /etc/resolv.conf /mnt/gentoo/etc
|
||||
chroot /mnt/gentoo /bin/bash
|
||||
source /etc/profile
|
||||
export PS1="(chroot) ${PS1}"
|
||||
ping -c 3 google.com
|
||||
|
||||
fallocate -l 1G /swapfile # or sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
|
||||
chmod 600 /swapfile
|
||||
mkswap /swapfile
|
||||
swapon /swapfile
|
||||
|
||||
mkdir -p /etc/portage/package.{accept_keywords,license,use}
|
||||
|
||||
JOBS="$(nproc)"
|
||||
LOAD_AVERAGE="$(python -c "print($(nproc)*0.9)")"
|
||||
cat >> /etc/portage/make.conf <<EOF
|
||||
|
||||
AUTOCLEAN="yes"
|
||||
FEATURES="candy compress-build-logs parallel-install"
|
||||
GRUB_PLATFORMS="efi-64"
|
||||
L10N="en-US"
|
||||
LINGUAS="en_US"
|
||||
USE="hardened"
|
||||
|
||||
# use all the cpu threads but keep load average to 90%
|
||||
# see https://wiki.gentoo.org/wiki/EMERGE_DEFAULT_OPTS
|
||||
EMERGE_DEFAULT_OPTS="--jobs $JOBS --load-average $LOAD_AVERAGE"
|
||||
MAKEOPTS="--jobs $JOBS --load-average $LOAD_AVERAGE"
|
||||
EOF
|
||||
|
||||
emerge --sync
|
||||
|
||||
echo "Europe/Amsterdam" > /etc/timezone
|
||||
emerge --config sys-libs/timezone-data
|
||||
|
||||
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
|
||||
locale-gen
|
||||
eselect locale set "en_US.utf8"
|
||||
env-update && source /etc/profile && export PS1="(chroot) ${PS1}"
|
||||
|
||||
cat > /etc/fstab <<EOF
|
||||
# The root filesystem should have a pass number of either 0 or 1.
|
||||
# All other filesystems should have a pass number of 0 or greater than 1.
|
||||
#
|
||||
# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
|
||||
#
|
||||
# See the manpage fstab(5) for more information.
|
||||
#
|
||||
# <fs> <mountpoint> <type> <opts> <dump/pass>
|
||||
|
||||
LABEL=EFI /boot vfat noauto,noatime 1 2
|
||||
LABEL=System / ext4 discard,noatime 0 1
|
||||
|
||||
/swapfile swap swap defaults 0 0
|
||||
#tmpfs /run tmpfs rw,nodev,nosuid 0 0
|
||||
EOF
|
||||
|
||||
echo 'hostname="gentoo"' > /etc/conf.d/hostname
|
||||
|
||||
echo "sys-kernel/linux-firmware linux-fw-redistributable no-source-code" > /etc/portage/package.license/kernel
|
||||
emerge \
|
||||
--quiet --verbose \
|
||||
sys-kernel/gentoo-sources sys-kernel/genkernel
|
||||
eselect kernel set 1
|
||||
genkernel all
|
||||
|
||||
emerge \
|
||||
--quiet --verbose \
|
||||
--noreplace \
|
||||
net-misc/netifrc
|
||||
echo 'config_enp0s3="dhcp"' > /etc/conf.d/net
|
||||
sed -i.bak \
|
||||
-e 's/^127.0.0.1.*/127.0.0.1\tlocalhost gentoo/' \
|
||||
-e 's/^::1.*/::1\t\tlocalhost gentoo/' \
|
||||
/etc/hosts
|
||||
cd /etc/init.d
|
||||
ln -s net.lo net.enp0s3
|
||||
rc-update add net.enp0s3 default
|
||||
cd -
|
||||
|
||||
sed -i.bak 's/^enforce=everyone$/enforce=none/' /etc/security/passwdqc.conf
|
||||
emerge \
|
||||
--quiet --verbose \
|
||||
app-admin/sudo
|
||||
echo '%wheel ALL=(ALL) ALL' | tee /etc/sudoers.d/wheel
|
||||
useradd -m -G users,wheel,audio -s /bin/bash mek
|
||||
passwd mek
|
||||
passwd -l root
|
||||
|
||||
emerge \
|
||||
--quiet --verbose \
|
||||
app-admin/sysklogd
|
||||
rc-update add sysklogd default
|
||||
|
||||
emerge \
|
||||
--quiet --verbose \
|
||||
sys-process/cronie
|
||||
rc-update add cronie default
|
||||
|
||||
emerge \
|
||||
--quiet --verbose \
|
||||
net-misc/dhcpcd
|
||||
rc-update add dhcpcd default
|
||||
|
||||
rc-update add sshd default
|
||||
|
||||
echo 'sys-process/bpytop ~amd64' | tee /etc/portage/package.accept_keywords/bpytop
|
||||
emerge \
|
||||
--quiet --verbose \
|
||||
bpytop \
|
||||
nfs-utils \
|
||||
samba \
|
||||
tmux
|
||||
|
||||
emerge \
|
||||
--quiet --verbose \
|
||||
sys-boot/grub:2
|
||||
grub-install --target=x86_64-efi --efi-directory=/boot
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
|
||||
exit
|
||||
|
||||
cd
|
||||
umount -lR /mnt/gentoo
|
||||
reboot
|
||||
48
examples/gentoo/post-install.virtualbox.sh
Executable file
48
examples/gentoo/post-install.virtualbox.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
eselect profile set "default/linux/amd64/17.1/desktop/plasma"
|
||||
emerge --sync
|
||||
emerge \
|
||||
--quiet --verbose \
|
||||
--update --deep --with-bdeps=y \
|
||||
--changed-use --newuse \
|
||||
@world
|
||||
|
||||
|
||||
cat | tee /etc/portage/package.use/kde <<EOF
|
||||
kde-plasma/powerdevil brightness-control
|
||||
|
||||
# include gtk support
|
||||
# exclude vault
|
||||
# discover not working for some reason to be checked
|
||||
# qrcode not working for some reason to be checked
|
||||
kde-plasma/plasma-meta grub gtk -crypt
|
||||
EOF
|
||||
emerge \
|
||||
--quiet --verbose \
|
||||
app-cdr/dolphin-plugins-mountiso \
|
||||
kde-apps/ark \
|
||||
kde-apps/dolphin-plugins-git \
|
||||
kde-apps/kdecore-meta \
|
||||
kde-plasma/plasma-meta
|
||||
rc-update add dbus default
|
||||
rc-update add elogind default
|
||||
cat > /home/mek/.xinitrc <<EOF
|
||||
#!/bin/sh
|
||||
exec dbus-launch --exit-with-session startplasma-wayland
|
||||
EOF
|
||||
|
||||
cp /etc/pam.d/sddm-greeter /etc/pam.d/sddm-greeter.backup
|
||||
echo "session optional pam_elogind.so" >> /etc/pam.d/sddm-greeter
|
||||
sed -i.backup 's/^DISPLAYMANAGER=.*$/DISPLAYMANAGER="sddm"/' /etc/conf.d/display-manager
|
||||
rc-update add display-manager default
|
||||
|
||||
echo | tee /etc/portage/package.use/firefox-bin <<EOF
|
||||
# required by media-sound/pulseaudio-13.0-r1::gentoo[alsa-plugin,alsa]
|
||||
# required by www-client/firefox-bin-89.0.2::gentoo[pulseaudio]
|
||||
# required by www-client/firefox-bin (argument)
|
||||
media-plugins/alsa-plugins pulseaudio
|
||||
EOF
|
||||
emerge \
|
||||
--quiet --verbose \
|
||||
www-client/firefox-bin
|
||||
Reference in New Issue
Block a user