- Use at your own risk
- This script assumes that
grep,sedis available, anddoasorsudoif not running as root
Last active
July 10, 2025 14:32
-
-
Save Glucy-2/81550fa5b899446eb22e5a2a2346e5aa to your computer and use it in GitHub Desktop.
Alpine init
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Check if the script is run as root or with doas/sudo | |
| if [ "$(id -u)" -ne 0 ]; then | |
| if [ -x "$(command -v doas)" ]; then | |
| SUDO="doas" | |
| elif [ -x "$(command -v sudo)" ]; then | |
| SUDO="sudo" | |
| else | |
| echo "This script must be run as root or with doas/sudo." | |
| exit 1 | |
| fi | |
| else | |
| SUDO="" | |
| fi | |
| # Install packages | |
| $SUDO apk add util-linux-misc lsblk lscpu pciutils nmap nmap-nping \ | |
| traceroute mtr fastfetch vim bash bash-completion btop htop iotop iftop \ | |
| lsof libcap curl wget qemu-guest-agent vnstat iperf3 wireguard-tools dhcpcd \ | |
| nftables slirp4netns kitty-terminfo podman podman-compose starship | |
| # Enable and start vnstatd, qemu-guest-agent | |
| SERVICES="vnstatd qemu-guest-agent" | |
| for service in $SERVICES; do | |
| $SUDO rc-update add $service | |
| $SUDO rc-service $service start | |
| done | |
| # Setup NTP | |
| echo -e "\n" | $SUDO setup-ntp | |
| # Setup starship and bash | |
| echo '[[ -f ~/.bashrc ]] && . ~/.bashrc' > ~/.bash_profile | |
| echo 'eval "$(starship init bash)"' > ~/.bashrc | |
| mkdir -p ~/.config | |
| starship preset plain-text-symbols -o ~/.config/starship.toml | |
| # Setup rootless podman | |
| $SUDO adduser -h /home/podman -s /sbin/nologin -D -u 121 podman | |
| $SUDO rc-update add cgroups | |
| $SUDO rc-service cgroups start | |
| $SUDO modprobe tun | |
| echo tun | $SUDO tee -a /etc/modules > /dev/null | |
| echo podman:100000:65536 | $SUDO tee /etc/subuid | $SUDO tee /etc/subgid > /dev/null | |
| echo 'If you see a warning running podman:' | |
| echo ' WARN[0000] "/" is not a shared mount, this could cause issues or missing mounts with rootless containers' | |
| echo 'You might want to fix this:' | |
| echo ' https://wiki.alpinelinux.org/wiki/Podman#Shared_mount' | |
| # Change shell to /bin/bash | |
| $SUDO sed -i.bak "s|^\($(id -un):[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\).*|\1/bin/bash|" /etc/passwd | |
| echo "Change your shell to /bin/bash:" | |
| echo " $(grep $(id -un) /etc/passwd)" | |
| # Enable OpenRC logger | |
| $SUDO sed -i.bak -E 's/^[[:space:]]*#[[:space:]]*(rc_logger[[:space:]]*=.*)$/\1/; s/^(rc_logger[[:space:]]*=).*$/\1"YES"/' /etc/rc.conf | |
| echo "Enabled OpenRC logger:" | |
| echo " $(grep rc_logger /etc/rc.conf)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment