diff options
| author | Maria Lisina <sekoohaka.sarisan@gmail.com> | 2026-08-20 21:01:58 +0500 |
|---|---|---|
| committer | Maria Lisina <sekoohaka.sarisan@gmail.com> | 2026-08-20 21:01:58 +0500 |
| commit | 396b18a36a8ee72d347de9af5383f2a8a91c8e67 (patch) | |
| tree | 8c29d6d2e758b08528143543ac12a027b0ba6ef7 | |
| parent | 8a1b3be58997c81ac808fbe672f222791aae8ece (diff) | |
Add old scripts
Signed-off-by: Maria Lisina <sekoohaka.sarisan@gmail.com>
| -rwxr-xr-x | alpine/boot.sh | 12 | ||||
| -rwxr-xr-x | alpine/bootstrap.sh | 26 | ||||
| -rwxr-xr-x | alpine/cifs.sh | 17 | ||||
| -rwxr-xr-x | alpine/dnscrypt.sh | 18 | ||||
| -rwxr-xr-x | alpine/fstab.sh | 16 | ||||
| -rwxr-xr-x | alpine/locale.sh | 12 | ||||
| -rwxr-xr-x | alpine/nano.sh | 13 | ||||
| -rwxr-xr-x | alpine/networking.sh | 49 | ||||
| -rwxr-xr-x | alpine/post.sh | 13 | ||||
| -rwxr-xr-x | alpine/rc-zram-init.sh | 54 | ||||
| -rwxr-xr-x | alpine/rc.sh | 25 | ||||
| -rwxr-xr-x | alpine/setup.sh | 19 | ||||
| -rwxr-xr-x | alpine/ssh.sh | 15 | ||||
| -rwxr-xr-x | alpine/timezone.sh | 10 | ||||
| -rwxr-xr-x | alpine/world.sh | 39 | ||||
| -rwxr-xr-x | nft/accept-filter.sh | 31 | ||||
| -rwxr-xr-x | nft/asn-filter.sh | 53 | ||||
| -rwxr-xr-x | wsl2/build.sh | 22 | ||||
| -rwxr-xr-x | wsl2/config.sh | 165 |
19 files changed, 609 insertions, 0 deletions
diff --git a/alpine/boot.sh b/alpine/boot.sh new file mode 100755 index 0000000..84f4ee1 --- /dev/null +++ b/alpine/boot.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# boot configuration + +set -e + +__root="$(blkid -o value -s UUID /dev/${1}2)" + +efibootmgr --create --disk /dev/${1} --loader "\vmlinuz-virt" --label "Alpine Linux" --unicode "initrd=\initramfs-virt quiet root=UUID=${__root} rootfstype=ext4 rw" diff --git a/alpine/bootstrap.sh b/alpine/bootstrap.sh new file mode 100755 index 0000000..c1bf1da --- /dev/null +++ b/alpine/bootstrap.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# Alpine Linux bootstrap script + +set -e + +parted --script /dev/${1} \ + mklabel gpt \ + mkpart '"EFI system partition"' fat32 1MiB 101MiB \ + set 1 esp on \ + mkpart '"Linux filesystem partition"' ext4 101MiB 100% + +mkfs.fat -F 32 -n "EFI" /dev/${1}1 +mkfs.ext4 -L "Alpine Linux" /dev/${1}2 +mount -m /dev/${1}2 /mnt/bootstrap +mount -m /dev/${1}1 /mnt/bootstrap/boot + +apk -p /mnt/bootstrap -U -X https://dl-cdn.alpinelinux.org/alpine/v3.23/main --allow-untrusted --arch x86_64 --initdb add alpine-base + +for __dev in dev proc run sys tmp +do + mount --rbind --make-rslave /${__dev} /mnt/bootstrap/${__dev} +done diff --git a/alpine/cifs.sh b/alpine/cifs.sh new file mode 100755 index 0000000..ad880c1 --- /dev/null +++ b/alpine/cifs.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# cifs configuration + +set -e + +cat << EOF >> /etc/fstab +//172.16.0.1/Users/${1} /media/cifs/Windows cifs _netdev,defaults,vers=3.1.1,credentials=/root/.cifs +EOF + +cat << EOF > /root/.cifs +username=${1} +password=${2} +EOF diff --git a/alpine/dnscrypt.sh b/alpine/dnscrypt.sh new file mode 100755 index 0000000..fee4f44 --- /dev/null +++ b/alpine/dnscrypt.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# dnscrypt-proxy setup script + +sed -i \ + -e "s/^# server_names =.*$/server_names = ['google', 'google-ipv6']/" \ + -e "s/^listen_addresses =.*$/listen_addresses = ['127.0.0.1:53', '[::1]:53']/" \ + -e 's/^ipv6_servers =.*$/ipv6_servers = true/' \ + -e 's/^cache =.*$/cache = false/' \ + /etc/dnscrypt-proxy/dnscrypt-proxy.toml + +cat << EOF > /etc/resolv.conf +nameserver 127.0.0.1 +nameserver ::1 +EOF diff --git a/alpine/fstab.sh b/alpine/fstab.sh new file mode 100755 index 0000000..2085999 --- /dev/null +++ b/alpine/fstab.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# fstab configuration + +set -e + +__boot="$(blkid -o value -s UUID /dev/${1}1)" +__root="$(blkid -o value -s UUID /dev/${1}2)" + +cat << EOF > /etc/fstab +UUID=${__root} / ext4 defaults 0 1 +UUID=${__boot} /boot vfat defaults 0 2 +EOF diff --git a/alpine/locale.sh b/alpine/locale.sh new file mode 100755 index 0000000..a771093 --- /dev/null +++ b/alpine/locale.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# locale configuration + +set -e + +cat << EOF > /etc/profile.d/10locale.sh +export LANG=en_US.UTF-8 +EOF diff --git a/alpine/nano.sh b/alpine/nano.sh new file mode 100755 index 0000000..d928d0e --- /dev/null +++ b/alpine/nano.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# nano configuration + +set -e + +sed -i \ + -e 's/^# set historylog$/set historylog/' \ + -e 's|^# include /usr/share/nano/\*.nanorc$|include /usr/share/nano/\*.nanorc|' \ + /etc/nanorc diff --git a/alpine/networking.sh b/alpine/networking.sh new file mode 100755 index 0000000..8c5eff0 --- /dev/null +++ b/alpine/networking.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# networking configuration + +set -e + +if [ -n "${1}" ] +then + __hostname="${1}" + shift +else + __hostname="localhost" +fi + +echo ${__hostname} > /etc/hostname + +cat << EOF > /etc/network/interfaces +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet dhcp + +auto eth1 +iface eth1 inet static + address 172.16.0.1 + netmask 255.240.0.0 +iface eth1 inet6 auto +EOF + +cat << EOF > /etc/resolv.conf +nameserver 8.8.8.8 +nameserver 8.8.4.4 +nameserver 2001:4860:4860::8888 +nameserver 2001:4860:4860::8844 +EOF + +cat << EOF > /etc/hosts +127.0.0.1 localhost ${__hostname} +::1 localhost ipv6-localhost ipv6-loopback ${__hostname} +fe00::0 ipv6-localnet +ff00::0 ipv6-mcastprefix +ff02::1 ipv6-allnodes +ff02::2 ipv6-allrouters +ff02::3 ipv6-allhosts +EOF diff --git a/alpine/post.sh b/alpine/post.sh new file mode 100755 index 0000000..ae2e06f --- /dev/null +++ b/alpine/post.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# Alpine Linux post setup script, supposed to be ran in working system + +set -e + +__dir="${0%/*}" + +${__dir}/boot.sh ${1} +${__dir}/cifs.sh ${2} ${3} diff --git a/alpine/rc-zram-init.sh b/alpine/rc-zram-init.sh new file mode 100755 index 0000000..a66c766 --- /dev/null +++ b/alpine/rc-zram-init.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# OpenRC zram-init configuration + +set -e + +if [ -n "${1}" ] +then + __num_devices=${1} + + if ! test ${__num_devices} -gt 0 > /dev/null 2>&1 + then + echo "Invalid devices number" + exit 1 + fi + + shift +fi + +if [ -n "${1}" ] +then + __size=${1} + + if ! test ${__size} -gt 0 > /dev/null 2>&1 + then + echo "Invalid block size" + exit 1 + fi + + shift +fi + +cat << EOF > /etc/modprobe.d/zram.conf +options zram num_devices=${__num_devices} +EOF + +cat << EOF > /etc/conf.d/zram-init +load_on_start=yes +unload_on_stop=yes +num_devices=${__num_devices} +EOF + +for __device in $(seq 0 $((__num_devices - 1))) +do + printf "\ntype%u=%s\nsize%u=%u\nmaxs%u=%u\nalgo%u=%s\nlabl%u=%s\n" \ + ${__device} "swap" \ + ${__device} ${__size} \ + ${__device} 1 \ + ${__device} "zstd" \ + ${__device} "zram" >> /etc/conf.d/zram-init +done diff --git a/alpine/rc.sh b/alpine/rc.sh new file mode 100755 index 0000000..0253f3b --- /dev/null +++ b/alpine/rc.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# Alpine Linux OpenRC setup script, supposed to be ran in chroot + +rc-update add acpid default +rc-update add bootmisc boot +rc-update add crond default +rc-update add devfs sysinit +rc-update add dmesg sysinit +rc-update add hostname boot +rc-update add hwclock boot +rc-update add hwdrivers sysinit +rc-update add killprocs shutdown +rc-update add mdev sysinit +rc-update add modules boot +rc-update add mount-ro shutdown +rc-update add networking boot +rc-update add savecache shutdown +rc-update add seedrng boot +rc-update add swap boot + +rc-update add sshd diff --git a/alpine/setup.sh b/alpine/setup.sh new file mode 100755 index 0000000..83e1d5c --- /dev/null +++ b/alpine/setup.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# Alpine Linux setup script, supposed to be ran in chroot + +set -e + +__dir="${0%/*}" + +${__dir}/networking.sh ${1} +${__dir}/world.sh +${__dir}/fstab.sh ${2} +${__dir}/locale.sh +${__dir}/timezone.sh ${3} +${__dir}/nano.sh +${__dir}/ssh.sh +${__dir}/rc.sh diff --git a/alpine/ssh.sh b/alpine/ssh.sh new file mode 100755 index 0000000..875ef8a --- /dev/null +++ b/alpine/ssh.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# SSH configuration + +set -e + +cat << EOF > /etc/ssh/sshd_config.d/root.conf +PermitRootLogin yes +PubkeyAuthentication yes +PasswordAuthentication no +KbdInteractiveAuthentication no +EOF diff --git a/alpine/timezone.sh b/alpine/timezone.sh new file mode 100755 index 0000000..551b23a --- /dev/null +++ b/alpine/timezone.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# timezone configuration + +set -e + +ln -fs /usr/share/zoneinfo/${1} /etc/localtime diff --git a/alpine/world.sh b/alpine/world.sh new file mode 100755 index 0000000..b942ca0 --- /dev/null +++ b/alpine/world.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# APK world setup script + +set -e + +__world=" + alpine-sdk + curl + dosfstools + e2fsprogs + efibootmgr + fastfetch + git + jq + lang + linux-virt + nano + nano-syntax + openssh + recode + telegram-bot-api + tzdata + util-linux + zsh + zsh-completions +" + +cat << EOF > /etc/apk/repositories +https://dl-cdn.alpinelinux.org/alpine/v3.23/main +https://dl-cdn.alpinelinux.org/alpine/v3.23/community +https://dl-cdn.alpinelinux.org/alpine/edge/testing +EOF + +apk update +apk add ${__world} diff --git a/nft/accept-filter.sh b/nft/accept-filter.sh new file mode 100755 index 0000000..5dfe5dc --- /dev/null +++ b/nft/accept-filter.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# nftables accept filter + +set -e + +cat << EOF > /etc/nftables.nft +#!/usr/sbin/nft -f + +flush ruleset + +table inet filter { + chain input { + type filter hook input priority 0; policy accept; + } + + chain forward { + type filter hook forward priority 0; policy accept; + } + + chain output { + type filter hook output priority 0; policy accept; + } +} + +include "/var/lib/nftables/*.nft" +include "/etc/nftables.d/*.nft" +EOF diff --git a/nft/asn-filter.sh b/nft/asn-filter.sh new file mode 100755 index 0000000..2880d30 --- /dev/null +++ b/nft/asn-filter.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# nftables ASN filter + +set -e + +if [ ${#} -eq 0 ] +then + echo "No ASNs specified!" + exit 1 +fi + +__blocked_asns="${@}" +shift ${#} + +for __asn in ${__blocked_asns} +do + __asn_ips="$(curl --get --silent "https://2ip.io/as/${__asn}.json" | jq -r '.prefixes[].ipv4Prefix')" + set -- ${@} ${__asn_ips} +done + +while [ ${#} -gt 0 ] +do + _asn_ips="$(printf "%s%s" "${_asn_ips}" "${1}")" + + if [ ${#} -gt 1 ] + then + _asn_ips="$(printf "%s%c" "${_asn_ips}" ",")" + fi + + shift +done + +cat << EOF > /etc/nftables.d/asn_filter.nft +#!/usr/sbin/nft -f + +table inet asn_filter { + set blocked_addresses { + typeof ip saddr + flags interval + auto-merge + elements = { ${_asn_ips} } + } + + chain input { + type filter hook input priority 0; + ip saddr @blocked_addresses drop + } +} +EOF diff --git a/wsl2/build.sh b/wsl2/build.sh new file mode 100755 index 0000000..6e07e0a --- /dev/null +++ b/wsl2/build.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env dash +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# Sekoohaka Kernel build script + +set -e + +for __arch in arm64 x86_64 +do + if [ ${__arch} = arm64 ] + then + _arch=aarch64 + else + _arch=x86_64 + fi + + rm -fr ../out-${__arch} + make -j 16 O=../out-${__arch} ARCH=${__arch} CROSS_COMPILE=${_arch}-linux-gnu- wsl2_defconfig + make -j 16 O=../out-${__arch} ARCH=${__arch} CROSS_COMPILE=${_arch}-linux-gnu- +done diff --git a/wsl2/config.sh b/wsl2/config.sh new file mode 100755 index 0000000..bfcf8cc --- /dev/null +++ b/wsl2/config.sh @@ -0,0 +1,165 @@ +#!/usr/bin/env dash +# +# Copyright (C) 2025-2026 Maria Lisina +# SPDX-License-Identifier: Apache-2.0 +# +# Sekoohaka Kernel defconfig based on Azure Linux 6.6 + +set -e + +__wsl2_required_configs=" + CONFIG_BINFMT_MISC + CONFIG_NET_IP_TUNNEL + CONFIG_NET_UDP_TUNNEL + CONFIG_INET_DIAG + CONFIG_INET_TCP_DIAG + CONFIG_INET_UDP_DIAG + CONFIG_NETFILTER_NETLINK + CONFIG_NETFILTER_NETLINK_LOG + CONFIG_NF_CONNTRACK + CONFIG_NF_NAT + CONFIG_NF_TABLES + CONFIG_NFT_MASQ + CONFIG_NFT_NAT + CONFIG_NF_DEFRAG_IPV4 + CONFIG_NF_DEFRAG_IPV6 + CONFIG_VSOCKETS + CONFIG_VSOCKETS_DIAG + CONFIG_HYPERV_VSOCKETS + CONFIG_NETLINK_DIAG + CONFIG_NET_9P + CONFIG_NET_9P_FD + CONFIG_NET_9P_VIRTIO + CONFIG_PCI_HYPERV + CONFIG_PCI_HYPERV_INTERFACE + CONFIG_SCSI_FC_ATTRS + CONFIG_HYPERV_STORAGE + CONFIG_VXLAN + CONFIG_HYPERV_NET + CONFIG_HYPERV_KEYBOARD + CONFIG_VIRTIO_CONSOLE + CONFIG_HYPERV + CONFIG_HYPERV_TIMER + CONFIG_HYPERV_UTILS + CONFIG_HYPERV_BALLOON + CONFIG_DXGKRNL + CONFIG_FUSE_FS + CONFIG_VIRTIO_FS + CONFIG_OVERLAY_FS + CONFIG_NETFS_SUPPORT + CONFIG_FSCACHE + CONFIG_9P_FS + CONFIG_9P_FSCACHE + + CONFIG_NETFILTER_XTABLES + CONFIG_NETFILTER_XT_TARGET_RATEEST + CONFIG_NETFILTER_XT_TARGET_TCPMSS + CONFIG_NETFILTER_XT_MATCH_DSCP + CONFIG_NETFILTER_XT_MATCH_HL + CONFIG_NETFILTER_XT_MATCH_RATEEST + CONFIG_NETFILTER_XT_MATCH_TCPMSS +" + +__wsl2_sekoohaka_configs=" + CONFIG_KERNEL_ZSTD + + CONFIG_ZRAM + CONFIG_ZRAM_BACKEND_ZSTD + CONFIG_ZRAM_WRITEBACK + CONFIG_ZRAM_MEMORY_TRACKING + CONFIG_ZRAM_MULTI_COMP + CONFIG_CRYPTO_ZSTD + + CONFIG_DM_CRYPT + + CONFIG_HIDRAW + CONFIG_HID_BPF + CONFIG_USB_HIDDEV + CONFIG_USB + CONFIG_USB_STORAGE + CONFIG_USB_UAS + CONFIG_USBIP_CORE + CONFIG_USBIP_VHCI_HCD + CONFIG_USB_SERIAL + + CONFIG_USB_SERIAL_CH341 + CONFIG_USB_SERIAL_CP210X + CONFIG_USB_SERIAL_FTDI_SIO + CONFIG_USB_SERIAL_PL2303 + + CONFIG_EROFS_FS + + CONFIG_INIT_STACK_ALL_ZERO + + CONFIG_ANDROID_BINDER_IPC + CONFIG_ANDROID_BINDERFS + + CONFIG_POSIX_MQUEUE + CONFIG_CGROUPS + CONFIG_MEMCG + CONFIG_CGROUP_SCHED + CONFIG_CGROUP_FREEZER + CONFIG_CPUSETS + CONFIG_CGROUP_DEVICE + CONFIG_CGROUP_CPUACCT + CONFIG_CGROUP_BPF + CONFIG_NAMESPACES + CONFIG_UTS_NS + CONFIG_IPC_NS + CONFIG_PID_NS + CONFIG_NET_NS + CONFIG_BRIDGE_NETFILTER + CONFIG_NF_NAT + CONFIG_NETFILTER_XT_MARK + CONFIG_NETFILTER_XT_NAT + CONFIG_NETFILTER_XT_TARGET_MASQUERADE + CONFIG_NETFILTER_XT_MATCH_ADDRTYPE + CONFIG_NETFILTER_XT_MATCH_CONNTRACK + CONFIG_NETFILTER_XT_MATCH_IPVS + CONFIG_IP_VS + CONFIG_BRIDGE + CONFIG_VETH + CONFIG_KEYS +" + +for __arch in arm64 x86_64 +do + if [ ${__arch} = arm64 ] + then + _arch=aarch64 + else + _arch=x86_64 + fi + + rm -fr ../out-${__arch} + mkdir ../out-${__arch} + cp ../azure-${__arch} ../out-${__arch}/.config + make -j 16 O=../out-${__arch} ARCH=${__arch} CROSS_COMPILE=${_arch}-linux-gnu- olddefconfig + sed -i 's/^CONFIG_LOCALVERSION=.*$/CONFIG_LOCALVERSION="-microsoft-sekoohaka-WSL2"/' ../out-${__arch}/.config + sed -i 's/^CONFIG_SYSTEM_TRUSTED_KEYS=.*$//' ../out-${__arch}/.config + + for __config in ${__wsl2_required_configs} + do + echo "${__config}=y" >> ../out-${__arch}/.config + done + + make -j 16 O=../out-${__arch} ARCH=${__arch} CROSS_COMPILE=${_arch}-linux-gnu- olddefconfig + + echo "# CONFIG_BPF_SYSCALL is not set" >> ../out-${__arch}/.config + echo "# CONFIG_MODULES is not set" >> ../out-${__arch}/.config + + for __module in $(grep '=m$' ../out-${__arch}/.config) + do + sed -i "s/${__module}/# ${__module%=*} is not set/" ../out-${__arch}/.config + done + + make -j 16 O=../out-${__arch} ARCH=${__arch} CROSS_COMPILE=${_arch}-linux-gnu- olddefconfig + + for __config in ${__wsl2_sekoohaka_configs} + do + echo "${__config}=y" >> ../out-${__arch}/.config + done + + make -j 16 O=../out-${__arch} ARCH=${__arch} CROSS_COMPILE=${_arch}-linux-gnu- olddefconfig + make -j 16 O=../out-${__arch} ARCH=${__arch} CROSS_COMPILE=${_arch}-linux-gnu- savedefconfig +done |
