dev/1.RockyLinux.md

3.8 KiB

Extra Repos

dnf update
dnf install -y epel-release
dnf install -y elrepo-release
dnf install -y rpmfusion-free-release

System tools

dnf groupinstall "Development tools"
dnf install -y vim git zip htop iftop btop hdparm stress python3-pip
yum install -y https://rpm.nodesource.com/pub_20.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm
yum install -y nodejs --setopt=nodesource-nodejs.module_hotfixes=1 --nogpgcheck

System test

btop
stress -c 4 -i 2 -d 1

Oh My Posh

curl -s https://ohmyposh.dev/install.sh | bash -
mkdir -p .config/oh-my-posh/themes
wget -P .config/oh-my-posh/themes https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/capr4n.omp.json
wget -P .config/oh-my-posh/themes https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/aliens.omp.json
wget -P .config/oh-my-posh/themes https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/capr4n.omp.json
echo 'eval "$(oh-my-posh init bash --config ~/.config/oh-my-posh/themes/capr4n.omp.json)"' >> ~/.bashrc
exec bash

FZF

dnf -y install fzf fd-find bat
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
# Ctrl-t  find files / directories
# Ctrl-r  find in history
# Alt-c    change directory
# kill -9 **TAB   autocomplete option

Encrypted Partition

# Create encrypted partition
dnf install cryptsetup
cryptsetup -y -v --type luks2 luksFormat /dev/nvme0n1p6
lsblk -f

# Mount luks
cryptsetup luksOpen /dev/nvme0n1p6 data
ls -l /dev/mapper/data
cryptsetup -v status data
cryptsetup luksDump /dev/nvme0n1p6

# Format ext4
dd if=/dev/zero of=/dev/mapper/data status=progress
mkfs.ext4 /dev/mapper/data

# Mount ext4
mkdir /data
mount /dev/mapper/data /data
df -h
ls -l /data

# Umount all
umount /data
cryptsetup luksClose data

Change docker data Directory

docker info -f '{{ .DockerRootDir }}' # /var/lib/docker
systemctl stop docker.socket
systemctl stop docker
echo '{"data-root": "/data/docker"}' >  /etc/docker/daemon.json
systemctl start docker
systemctl start docker.socket
docker info -f '{{ .DockerRootDir }}' # /data/docker
mv /var/lib/docker /var/lib/docker.old

Enable rc.local

/etc/rc.local

#!/bin/bash
# Add terminal commands here without sude

# Make sure the script will "exit 0" on success
# or any other value on error.
exit 0

/etc/systemd/system/rc-local.service

[Unit]
 Description=/etc/rc.local Compatibility
 ConditionPathExists=/etc/rc.local

[Service]
 Type=forking
 ExecStart=/etc/rc.local start
 TimeoutSec=0
 StandardOutput=tty
 RemainAfterExit=yes
 SysVStartPriority=99

[Install]
 WantedBy=multi-user.target
chmod +x /etc/rc.local
systemctl enable rc-local
systemctl start rc-local.service
systemctl status rc-local.service

Get password service

/opt/password.py

#! /usr/bin/python3
from aiohttp import web
async def sendpass(request):
    data = {"password": "12345678"}
    return web.json_response(data)
app = web.Application()
app.add_routes([web.get('/andthepasswordis', sendpass)])
web.run_app(app, port=9999)

python3 -m pip install aiohttp

/lib/systemd/system/password.service

[Unit]
Description=Custom Python Service
After=multi-user.target
Conflicts=getty@tty1.service
 
[Service]
Type=simple
ExecStart=/usr/bin/python3 /opt/password.py
StandardInput=tty-force
 
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable password
systemctl start password.service
systemctl status password.service

/etc/systemd/system/docker-stop.service

[Unit]
Description=Stop docker and umount luks data partition before shutting down
[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=/opt/docker-stop.sh
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable docker-stop
systemctl status docker-stop