Skip to content

Instantly share code, notes, and snippets.

@mezcel
Last active September 24, 2023 19:29
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mezcel/ff833a444f2671879b22e76aa4ed61c5 to your computer and use it in GitHub Desktop.
Save mezcel/ff833a444f2671879b22e76aa4ed61c5 to your computer and use it in GitHub Desktop.
Alpine Linux Notes
## win10 line endins
*.bat eol=crlf
*.ps1 eol=crlf
## Linux/Posix line endins
*.go eol=lf
*.sh eol=lf
*.source eol=lf
Makefile eol=lf
## ignore vscode settings
.vscode
## ignore builds
*.exe
*.out
main

Alpine Linux Notes

alpinelinux-logo.svg

BusyBox: The Swiss Army Knife of Embedded Linux

  • busybox.net
    • BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete environment for any small or embedded system.
    • BusyBox has been written with size-optimization and limited resources in mind. It is also extremely modular so you can easily include or exclude commands (or features) at compile time. This makes it easy to customize your embedded systems. To create a working system, just add some device nodes in /dev, a few configuration files in /etc, and a Linux kernel.

APK

APK Repos

  • repos /etc/apk/repositories
## Modify repos

setup-apkrepos

APK search

## seach for video packages

apk search xf86-video

Wiki Help

  • What does required by: world $pkgnamemean?
  • How to Mount USB drive in Alpine Linux
    ## Follow this steps in order to mount an USB Drive on an alpine linux system:
    
    ## Check the device corresponding to your USB Drive on the system (for example sdb1)
    cat /proc/partitions
    
    ## Edit your fstab file
    nano /etc/fstab
    ## Add the following line (replace “sdb1” with your device name):
    /dev/sdb1 /media/usb vfat noauto 0 0
    ## Mount the drive
    mount /media/usb
    
    ## cd into your mount
    cd /media/usb
#!/bin/bash
function DlMPlayer {
## https://pkgs.alpinelinux.org/package/edge/community/x86_64/mplayer
## https://git.alpinelinux.org/aports/tree/community/mplayer/APKBUILD
sudo apk add libxxf86dga-dev libxv-dev libmad-dev lame-dev libao-dev
sudo apk add libtheora-dev xvidcore-dev zlib-dev sdl-dev freetype-dev
sudo apk add x264-dev faac-dev ttf-dejavu libxvmc-dev alsa-lib-dev live-media-dev
sudo apk add mesa-dev yasm libpng-dev libvdpau-dev libvpx-dev libcdio-paranoia-dev
## http://mplayerhq.hu/design7/dload.html#binary_codecs
#sudo apk add mplayer ## x64 only
wget -P ~/Downloads/ http://mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
## cd ~/Downloads/
## tar -xf essential-20071007.tar.bz2
wget -P ~/Downloads/ http://www.mplayerhq.hu/MPlayer/releases/MPlayer-1.4.tar.xz
## cd ~/Downloads/
## tar -xf MPlayer-1.4.tar.xz
}
DlMPlayer
#!/bin/bash
## install_audio.sh
##
## Alpine repos: https://pkgs.alpinelinux.org/packages
## Wiki: https://wiki.alpinelinux.org/wiki/Sound_Setup
## https://wiki.alpinelinux.org/wiki/PulseAudio
function InstallAlsa {
## First you will need to install Alsa packages, the Linux sound driver and volume adjuster.
sudo apk add alsa-utils alsa-utils-doc alsa-lib alsaconf
## Then you will need to add all your users (including root) to the audio group
sudo addgroup $USER audio
sudo addgroup root audio
## Alsa service is not started on install, you need to start it and to add it on rc
sudo rc-service alsa start
sudo rc-update add alsa
}
function InstallPulse {
sudo apk add pulseaudio pulseaudio-alsa
sudo apk add alsa-plugins-pulse
}
function InstallVLC {
sudo apk add curl-dev flac-dev libvorbis-dev libao-dev speex-dev
sudo apk add vorbis-tools
sudo apk add libxxf86dga-dev libxv-dev libmad-dev lame-dev libao-dev
sudo apk add libtheora-dev xvidcore-dev zlib-dev sdl-dev freetype-dev
sudo apk add x264-dev faac-dev ttf-dejavu libxvmc-dev alsa-lib-dev live-media-dev
sudo apk add mesa-dev yasm libpng-dev libvdpau-dev libvpx-dev libcdio-paranoia-dev
sudo apk add vlc
}
InstallAlsa
InstallPulse
InstallVLC
echo -e "\nDone."
#!/bin/bash
## install_dwm.sh
##
## Alpine repos: https://pkgs.alpinelinux.org/packages
## Wiki: https://wiki.alpinelinux.org/wiki/Dwm
function XorgDependencies {
sudo apk add git make gcc g++ libx11-dev libxft-dev
sudo apk add libxinerama-dev ncurses dbus-x11
sudo setup-xorg-base
sudo apk add xinit
sudo apk add xorg-server xf86-video-vesa xf86-input-evdev xf86-input-mouse xf86-input-keyboard udev
## find appropriate video
## sudo apk search xf86-video
sudo apk add xf86-video-amdgpu
sudo apk add xf86-video-ati
}
function SucklessApps {
mkdir -p ~/suckless/
git clone https://git.suckless.org/dwm ~/suckless/dwm && if [ -d ~/suckless/dwm ]; then
cd ~/suckless/dwm
sudo make clean install
## add dwm to startx
echo "exec dwm" > ~/.xinitrc
fi
git clone https://git.suckless.org/dmenu ~/suckless/dmenu && if [ -d ~/suckless/dmenu ]; then
cd ~/suckless/dmenu
sudo make clean install
fi
git clone https://git.suckless.org/st ~/suckless/st && if [ -d ~/suckless/st ]; then
cd ~/suckless/st
sudo make clean install
fi
}
function Beautification {
sudo apk add ranger feh pcmanfm zathura
sudo apk add udisks2-dev udisks-dev lvm2 cfdisk
sudo apk add xarchiver gvfs tumbler ffmpegthumbnailer libfm-dev libusbmuxd-dev libusb
sudo apk add geany-dev geany-plugins
sudo apk add geany-plugins-spellcheck geany-plugins-addons geany-plugins-treebrowser geany-plugins-geanyvc geany-plugins-addons geany-plugins-lang geany-plugins-utils
sudo apk add ttf-font-awesome ttf-hack ttf-inconsolata font-inconsolata-nerd
sudo apk add ttf-ubuntu-font-family
sudo apk add adwaita-gtk2-theme adwaita-icon-theme gnome-icon-theme
}
XorgDependencies
SucklessApps
Beautification
echo -e "\nDone."
#!/bin/bash
## Alpine repos: https://pkgs.alpinelinux.org/packages
function InstallVim {
## vim cache
mkdir -p ~/.backup
mkdir -p ~/.swp
mkdir -p ~/.undo
sudo apk add vim
}
function GnuApps {
sudo apk update
sudo apk add build-base linux-headers
sudo apk add git make gcc g++ libx11-dev libxft-dev libxinerama-dev ncurses dbus-x11
sudo apk add autoconf glib automake libtool intltool perl-xml-parser
sudo apk add tmux gdb ranger
sudo apk add bc aspell aspell-en hunspell
sudo apk add wget elinks
sudo apk add zip
}
function GitUser {
echo -e "\n\nPreparing Git got Github:\n\n"
read -p "Enter your github user name: " githubusername
echo ""
read -p "Enter github user email: " githubuseremail
git config --global user.name $githubusername
git config --global user.email $githubuseremail
echo ""
}
function HomeDir {
## vim cache
mkdir -p ~/.backup
mkdir -p ~/.swp
mkdir -p ~/.undo
mkdir -p ~/Downloads
## customize Almquist ash
echo 'PS1="\u@\h:\w\a$ "' > ~/.profile
}
GnuApps
InstallVim
HomeDir
GitUser
echo -e "\nDone."
#!/bin/bash
echo -e "\nAdd a new user:\n"
read -p 'new username: ' username
apk add sudo
adduser $username
echo ""
echo -e "## add the following to /etc/sudoers.tmp"
echo -e "\t$username ALL=(ALL) ALL"
read "Press enter to continue ..." pauseVar
visudo
## echo -e "myname ALL=(ALL) ALL" >> /etc/sudoers.tmp
#!/bin/bash
## install_video.sh
##
## Alpine repos: https://pkgs.alpinelinux.org/packages
## Wiki: https://wiki.alpinelinux.org/wiki/Dwm
function XorgDependencies {
sudo apk add git make gcc g++ libx11-dev libxft-dev
sudo apk add libxinerama-dev ncurses dbus-x11
sudo setup-xorg-base
sudo apk add xinit
sudo apk add xorg-server xf86-video-vesa xf86-input-evdev xf86-input-mouse xf86-input-keyboard udev
## find appropriate video
## sudo apk search xf86-video
sudo apk add xf86-video-amdgpu
sudo apk add xf86-video-ati
}
XorgDependencies
echo -e "\nDone."
#!/bin/bash
function startWifiDaemon {
## Wifi
## https://wiki.alpinelinux.org/wiki/Connecting_to_a_wireless_access_point
wifiInterface=wlan0
sudo ip link set $wifiInterface up
#wpa_supplicant -B -i $wifiInterface -c /etc/wpa_supplicant/wpa_supplicant.conf
sudo /etc/init.d/wpa_supplicant start
}
startWifiDaemon
#!/bin/bash
## Alpine repos: https://pkgs.alpinelinux.org/packages
function ApkDwm {
## DWM
## https://wiki.alpinelinux.org/wiki/Dwm
sudo setup-xorg-base
sudo apk add xinit
sudo apk add xorg-server xf86-video-vesa xf86-input-evdev xf86-input-mouse xf86-input-keyboard udev
sudo apk add xf86-video-amdgpu
sudo apk add xf86-video-ati
sudo apk add adwaita-gtk2-theme adwaita-icon-theme ttf-dejavu
# sudo vi /etc/apk/repositories
# sudo apk update
sudo apk add git make gcc g++ libx11-dev libxft-dev libxinerama-dev ncurses dbus-x11
mkdir -p ~/suckless/
git clone https://git.suckless.org/dwm ~/suckless/dwm && if [ -d ~/suckless/dwm ]; then
cd ~/suckless/dwm
sudo make clean install
fi
git clone https://git.suckless.org/dmenu ~/suckless/dmenu && if [ -d ~/suckless/dmenu ]; then
cd ~/suckless/dmenu
sudo make clean install
fi
git clone https://git.suckless.org/st ~/suckless/st && if [ -d ~/suckless/st ]; then
cd ~/suckless/st
sudo make clean install
fi
echo "exec dwm" > ~/.xinitrc
}
function ApkSu {
## Do this as root
read -p 'new username: ' username
apk add sudo
adduser $username
visudo
## echo -e "myname ALL=(ALL) ALL" >> /etc/sudoers.tmp
}
function ApkAudio {
## https://wiki.alpinelinux.org/wiki/Sound_Setup
## First you will need to install Alsa packages, the Linux sound driver and volume adjuster.
sudo apk add alsa-utils alsa-utils-doc alsa-lib alsaconf
## Then you will need to add all your users (including root) to the audio group
sudo addgroup $USER audio
sudo addgroup root audio
## Find the default sound card.
##alsamixer
## Once you've found the sound card name that gives you volume controls, set the unique number that showed up in the F6 context menu as your default soundcard.
## vim /usr/share/alsa/alsa.conf
## Scroll down until you find the lines that start with defaults.ctl.card and defaults.pcm.card and put the number (you found in the F6 context menu of the alsamixer command for the soundcard you want as your default) at the end of those lines separated by a space for each. For example, if the default sound card you want is "1".
## defaults.ctl.card 1
## defaults.pcm.card 1
## Alsa service is not started on install, you need to start it and to add it on rc
sudo rc-service alsa start
sudo rc-update add alsa
## https://wiki.alpinelinux.org/wiki/PulseAudio
sudo apk add pulseaudio pulseaudio-alsa
sudo apk add alsa-plugins-pulse
## Audio Players
sudo apk add curl-dev flac-dev libvorbis-dev libao-dev speex-dev
sudo apk add vorbis-tools
sudo apk add libxxf86dga-dev libxv-dev libmad-dev lame-dev libao-dev
sudo apk add libtheora-dev xvidcore-dev zlib-dev sdl-dev freetype-dev
sudo apk add x264-dev faac-dev ttf-dejavu libxvmc-dev alsa-lib-dev live-media-dev
sudo apk add mesa-dev yasm libpng-dev libvdpau-dev libvpx-dev libcdio-paranoia-dev
sudo apk add vlc
}
function ApkCore {
# setup-apkrepos
sudo apk update
sudo apk add build-base linux-headers
sudo apk add git make gcc g++ libx11-dev libxft-dev libxinerama-dev ncurses dbus-x11
sudo apk add autoconf glib automake libtool intltool perl-xml-parser
sudo apk add vim git tmux gdb
sudo apk add python2-dev python3-dev curl-dev
sudo setup-xorg-base
sudo apk add gtk+2.0-dev gtk+3.0-dev
sudo apk add bc aspell aspell-en hunspell
sudo apk add wget elinks
sudo apk add zip
## open the rest of the APK repos
## main
## and community
## or testing
sudo apk add ranger feh pcmanfm zathura
sudo apk add udisks2-dev udisks-dev lvm2 cfdisk
sudo apk add xarchiver gvfs tumbler ffmpegthumbnailer libfm-dev libusbmuxd-dev libusb
sudo apk add geany-dev geany-plugins
sudo apk add geany-plugins-spellcheck geany-plugins-addons geany-plugins-treebrowser geany-plugins-geanyvc geany-plugins-addons geany-plugins-lang geany-plugins-utils
sudo apk add ttf-font-awesome ttf-hack ttf-inconsolata font-inconsolata-nerd
sudo apk add ttf-ubuntu-font-family
sudo apk add adwaita-gtk2-theme adwaita-icon-theme gnome-icon-theme
## vim cache
mkdir -p ~/.backup
mkdir -p ~/.swp
mkdir -p ~/.undo
mkdir -p ~/Downloads
## customize Almquist ash
echo 'PS1="\u@\h:\w\a$ "' > ~/.profile
}
function GithubRepos {
## geany themes
git clone https://github.com/codebrainz/geany-themes.git ~/github/codebrainz/geany-themes.git
}
function ZipRepos {
## https://pkgs.alpinelinux.org/package/edge/community/x86/pcmanfm
sudo apk add gtk+3.0-dev libfm-dev intltool
sudo apk add wget
#wget -O ~/Downloads https://downloads.sourceforge.net/pcmanfm/$pkgname-$pkgver.tar.xz
## unzip <package>
## tar -xzvf <package>
## http://tarot.freeshell.org/leafpad/
sudo apk add gtk+2.0-dev
wget -P ~/Downloads/ http://savannah.nongnu.org/download/leafpad/leafpad-0.8.17.tar.gz
## unzip leafpad-0.8.17.tar.gz
## tar -xf leafpad-0.8.17.tar
## http://mplayerhq.hu/design7/dload.html#binary_codecs
#sudo apk add mplayer
wget -P ~/Downloads/ http://mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
## tar -xf essential-20071007.tar.bz2
wget -P ~/Downloads/ http://www.mplayerhq.hu/MPlayer/releases/MPlayer-1.4.tar.xz
## tar -xf MPlayer-1.4.tar.xz
}
#ApkSu
ApkCore
ApkAudio
#ApkDwm
#GithubRepos
#ZipRepos
echo -e "\nDone."
#!/bin/bash
## Must be root
function setupWifi {
## Wifi
## https://wiki.alpinelinux.org/wiki/Connecting_to_a_wireless_access_point
confPath=/etc/wpa_supplicant/wpa_supplicant.conf
wifiInterface=wlan0
echo -e "\n---\n"
ip link set $wifiInterface up
iwlist $wifiInterface scanning
echo -e "\n---\n Select the SSID to connect to:"
read -p 'SSID Name: ' myssd
read -sp 'SSID password: ' mypw
iwconfig $wifiInterface essid $myssd
iwconfig $wifiInterface
wpa_passphrase $myssd $mypw > $confPath
ip addr show $wifiInterface
# /etc/init.d/wpa_supplicant start
# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
wpa_supplicant -B -i $wifiInterface -c $confPath
}
setupWifi
echo -e "\nDone.\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment