https://mirrors.alpinelinux.org/
https://wiki.alpinelinux.org/wiki/Category:Installation
https://wiki.alpinelinux.org/wiki/Alpine_Linux_in_a_chroot
1. Download and extract static apk
https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases
download latest one for your arch
or goto
https://dl-cdn.alpinelinux.org/alpine/latest-stable/main/x86_64/apk-tools-static-X.X-X.apk
https://pkgs.alpinelinux.org/package/edge/main/x86/apk-tools-static
tar -xzf apk-tools-static-*.apk
or
chmod +x apk.static #allow execute permission
./apk.static #to execute it
2.format rootfs and mount to /mnt
https://battlepenguin.com/tech/alpine-linux-with-full-disk-encryption/
https://wejn.org/2021/01/alpinelinux-secure-boot-with-full-encryption/
https://wiki.alpinelinux.org/wiki/Root_on_ZFS_with_native_encryption
apk add fdisk
fdisk -l
doas cfdisk sda or nvme0n1
create new partition let it be sdax
mkfs.ext4 /dev/sdax
mount /dev/sdax /mnt
3.install
find {mirror} from http://nl.alpinelinux.org/alpine/MIRRORS.txt
./apk.static -X ${mirror}/latest-stable/main -U --allow-untrusted -p ${chroot_dir} --initdb add alpine-base
example
./apk.static -X http://dl-cdn.alpinelinux.org/alpine/latest-stable/main -U --allow-untrusted -p /mnt --initdb add alpine-base
./apk.static -X http://dl-cdn.alpinelinux.org/alpine/latest-stable/main -U --allow-untrusted -p /mnt --initdb add e2fsprogs dosfstools acct cfdisk
my add linux-firmware-none linux-firmware-i915 linux-firmware-ath10k udev(wifi not working with default evdev) iwd resolvconf
cat chroot.sh
#!/bin/sh
mount --rbind /dev /mnt/dev && mount --make-rslave /mnt/dev
mount --rbind /dev/pts /mnt/dev/pts && mount --make-rslave /mnt/dev/pts
mount --rbind /proc /mnt/proc && mount --make-rslave /mnt/proc
mount --rbind /sys /mnt/sys && mount --make-rslave /mnt/sys
chroot /mnt /bin/sh
sudo bash chroot.sh
mount -o bind /dev /mnt/dev
cp -L /etc/resolv.conf /mnt/etc/
or opendns
echo -e 'nameserver 8.8.8.8\nnameserver 2620:0:ccc::2' > /mnt/etc/resolv.conf
chroot /mnt /bin/ash -l
setup-udev
setup-alpine
passwd
xxxxxxx
cat /etc/apk/world
alpine-base alsa-utils brightnessctl btrfs-progs bubblewrap busybox-mdev-openrc cfdisk doas file firefox font-awesome font-cantarell font-noto-emoji foot grim gsettings-desktop-schemas htop i3blocks intel-media-driver iwd jq librsvg libudev zero libudev-zero-helper libva-utils linux-firmware-non linux-lts mesa-dri gallium mingetty mpv nano ncdu nnn ntfs-3g openresolv parted partx seatd sfdisk slurp swappy sway testdisk ttf-dejavu wireless-regdb wl-clipboard wlsunset wofi wtype zathura zathura-pdf-mupdf zstd
cat .bin/fm
#!/bin/sh
export NNN_FIFO=/tmp/nnn.fifo
export NNN_PLUG='e:-!doas nano "$nnn"*;x:-!doas rm -r "$nnn"*;p:preview-tui;d:dragdrop;'
export NNN_OPTS="d"
export NNN_OPENER=~/.bin/nuke
export EDITOR=nano
export VISUAL=nano
cat nuke
#!/bin/sh
GUI="${GUI:-1}"
BIN="${BIN:-0}"
set -euf -o noclobber -o noglob -o nounset
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n
PATH=$PATH:"${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins"
IMAGE_CACHE_PATH="$(dirname "$1")"/.thumbs
FPATH="$1"
FNAME=$(basename "$1")
EDITOR="nano"
PAGER="${PAGER:-less -R}"
ext="${FNAME##*.}"
if [ -n "$ext" ]; then
ext="$(printf "%s" "${ext}" | tr '[:upper:]' '[:lower:]')"
fi
is_mac() {
uname | grep -q "Darwin"
}
handle_pdf() {
if type zathura >/dev/null 2>&1; then
nohup zathura "${FPATH}" >/dev/null 2>&1 &
else
return
fi
exit 0
}
handle_audio() {
if type mpv >/dev/null 2>&1; then
mpv --player-operation-mode=pseudo-gui "${FPATH}" >/dev/null 2>&1 &
else
return
fi
exit 0
}
handle_video() {
if type mpv >/dev/null 2>&1; then
nohup mpv "${FPATH}" >/dev/null 2>&1 &
else
return
fi
exit 0
}
# handle this extension and exit
handle_extension() {
case "${ext}" in
## Archive
a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
if type atool >/dev/null 2>&1; then
atool --list -- "${FPATH}" | eval "$PAGER"
exit 0
elif type bsdtar >/dev/null 2>&1; then
bsdtar --list --file "${FPATH}" | eval "$PAGER"
exit 0
fi
exit 1;;
rar)
if type unrar >/dev/null 2>&1; then
## Avoid password prompt by providing empty password
unrar lt -p- -- "${FPATH}" | eval "$PAGER"
fi
exit 1;;
7z)
if type 7z >/dev/null 2>&1; then
## Avoid password prompt by providing empty password
7z l -p -- "${FPATH}" | eval "$PAGER"
exit 0
fi
exit 1;;
## PDF
pdf)
handle_pdf
exit 1;;
## Audio
aac|flac|m4a|mid|midi|mpa|mp2|mp3|ogg|wav|wma)
handle_audio
exit 1;;
## Video
avi|mkv|mp4|ts)
handle_video
exit 1;;
## Log files
log)
"$EDITOR" "${FPATH}"
exit 0;;
## BitTorrent
torrent)
if type rtorrent >/dev/null 2>&1; then
rtorrent "${FPATH}"
exit 0
elif type transmission-show >/dev/null 2>&1; then
transmission-show -- "${FPATH}"
exit 0
fi
exit 1;;
## Markdown
md)
if type glow >/dev/null 2>&1; then
glow -sdark "${FPATH}" | eval "$PAGER"
exit 0
elif type lowdown >/dev/null 2>&1; then
lowdown -Tterm "${FPATH}" | eval "$PAGER"
exit 0
fi
;;
## HTML
htm|html|xhtml)
## Preview as text conversion
if type w3m >/dev/null 2>&1; then
w3m -dump "${FPATH}" | eval "$PAGER"
exit 0
elif type lynx >/dev/null 2>&1; then
lynx -dump -- "${FPATH}" | eval "$PAGER"
exit 0
elif type elinks >/dev/null 2>&1; then
elinks -dump "${FPATH}" | eval "$PAGER"
exit 0
fi
;;
## JSON
json)
if type jq >/dev/null 2>&1; then
jq --color-output . "${FPATH}" | eval "$PAGER"
exit 0
elif type python >/dev/null 2>&1; then
python -m json.tool -- "${FPATH}" | eval "$PAGER"
exit 0
fi
;;
esac
}
# sets the variable abs_target, this should be faster than calling printf
abspath() {
case "$1" in
/*) abs_target="$1";;
*) abs_target="$PWD/$1";;
esac
}
# storing the result to a tmp file is faster than calling listimages twice
listimages() {
find -L "///${1%/*}" -maxdepth 1 -type f -print0 |
grep -izZE '\.(jpe?g|png|gif|webp|tiff|bmp|ico|svg)$' |
sort -z | tee "$tmp"
}
load_dir() {
abspath "$2"
tmp="${TMPDIR:-/tmp}/nuke_$$"
trap 'rm -f $tmp' EXIT
count="$(listimages "$abs_target" | grep -a -m 1 -ZznF "$abs_target" | cut -d: -f1)"
if [ -n "$count" ]; then
if [ "$GUI" -ne 0 ]; then
xargs -0 nohup "$1" -n "$count" -- < "$tmp"
else
xargs -0 "$1" -n "$count" -- < "$tmp"
fi
else
shift
"$1" -- "$@" # fallback
fi
}
handle_multimedia() {
## Size of the preview if there are multiple options or it has to be
## rendered from vector graphics. If the conversion program allows
## specifying only one dimension while keeping the aspect ratio, the width
## will be used.
# local DEFAULT_SIZE="1920x1080"
mimetype="${1}"
case "${mimetype}" in
## Image
image/*)
if [ "$GUI" -ne 0 ]; then
if type mvi >/dev/null 2>&1; then
mvi "${FPATH}" >/dev/null 2>&1 &
exit 0
fi
fi
exit 7;;
## PDF
application/pdf)
handle_pdf
exit 1;;
## Audio
audio/*)
handle_audio
exit 1;;
## Video
video/*)
handle_video
exit 1;;
esac
}
handle_mime() {
mimetype="${1}"
case "${mimetype}" in
## Manpages
text/troff)
man -l "${FPATH}"
exit 0;;
## Text
text/* | */xml)
"$EDITOR" "${FPATH}"
exit 0;;
## DjVu
image/vnd.djvu)
if type djvutxt >/dev/null 2>&1; then
## Preview as text conversion (requires djvulibre)
djvutxt "${FPATH}" | eval "$PAGER"
exit 0
elif type exiftool >/dev/null 2>&1; then
exiftool "${FPATH}" | eval "$PAGER"
exit 0
fi
exit 1;;
esac
}
handle_fallback() {
if [ "$GUI" -ne 0 ]; then
if type xdg-open >/dev/null 2>&1; then
nohup xdg-open "${FPATH}" >/dev/null 2>&1 &
exit 0
fi
fi
echo '----- File details -----' && file --dereference --brief -- "${FPATH}"
exit 1
}
handle_blocked() {
case "${MIMETYPE}" in
application/x-sharedlib)
exit 0;;
application/x-shared-library-la)
exit 0;;
application/x-executable)
exit 0;;
application/x-shellscript)
exit 0;;
application/octet-stream)
exit 0;;
esac
}
handle_bin() {
case "${MIMETYPE}" in
application/x-executable|application/x-shellscript)
clear
echo '-------- Executable File --------' && file --dereference --brief -- "${FPATH}"
printf "Run executable (y/N/'a'rgs)? "
read -r answer
case "$answer" in
[Yy]* ) exec "${FPATH}";;
[Aa]* )
printf "args: "
read -r args
exec "${FPATH}" "$args";;
[Nn]* ) exit;;
esac
esac
}
MIMETYPE="$( file -bL --mime-type -- "${FPATH}" )"
handle_extension
handle_multimedia "${MIMETYPE}"
handle_mime "${MIMETYPE}"
[ "$BIN" -ne 0 ] && [ -x "${FPATH}" ] && handle_bin
handle_blocked "${MIMETYPE}"
handle_fallback
exit 1
https://github.com/jarun/nnn/blob/master/plugins/nuke
Comments
Post a Comment