summaryrefslogtreecommitdiff
path: root/alpine
diff options
context:
space:
mode:
Diffstat (limited to 'alpine')
-rwxr-xr-xalpine/boot.sh12
-rwxr-xr-xalpine/bootstrap.sh26
-rwxr-xr-xalpine/cifs.sh17
-rwxr-xr-xalpine/dnscrypt.sh18
-rwxr-xr-xalpine/fstab.sh16
-rwxr-xr-xalpine/locale.sh12
-rwxr-xr-xalpine/nano.sh13
-rwxr-xr-xalpine/networking.sh49
-rwxr-xr-xalpine/post.sh13
-rwxr-xr-xalpine/rc-zram-init.sh54
-rwxr-xr-xalpine/rc.sh25
-rwxr-xr-xalpine/setup.sh19
-rwxr-xr-xalpine/ssh.sh15
-rwxr-xr-xalpine/timezone.sh10
-rwxr-xr-xalpine/world.sh39
15 files changed, 338 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}