nyuuzyou/wikis huggingface dataset:
Chroot/start-chroot

#!/bin/sh -e
if [ 0 -ne `id -u` ]; then
 echo "This script needs root access" >&2
 exit 1
fi
if ! [ -d "$1" ] || [ x-h = x"$*" ] || [ x--help = x"$*" ]; then
 echo "Usage: ${0##*/} <chroot_directory>" >&2
 exit 1
fi
cd "$1"
if ! [ -d ./etc ]; then
 echo "No etc directory inside $1" >&2
 exit 1
fi
shift
MOUNTED=
umount_all() {
 case $MOUNTED in
 shm\ *) if [ -L ./dev/shm ]; then
 umount ./`readlink ./dev/shm`
 else
 umount ./dev/shm
 fi
 MOUNTED=${MOUNTED#shm };;
 esac
 case $MOUNTED in
 run\ *) umount ./run
 MOUNTED=${MOUNTED#run };;
 esac
 case $MOUNTED in
 tmp\ *) umount ./tmp
 MOUNTED=${MOUNTED#tmp };;
 esac
 case $MOUNTED in
 proc\ *) umount ./proc
 MOUNTED=${MOUNTED#proc };;
 esac
 case $MOUNTED in
 sys\ *) umount ./sys
 MOUNTED=${MOUNTED#sys };;
 esac
 case $MOUNTED in
 pts\ *) umount ./dev/pts
 MOUNTED=${MOUNTED#pts };;
 esac
 case $MOUNTED in
 dev\ *) umount ./dev
 MOUNTED=${MOUNTED#dev };;
 esac
}
trap 'umount_all' EXIT
#mkdir -p ./etc ./dev/pts ./sys ./proc ./tmp ./run ./boot ./root
cp -iL /etc/resolv.conf ./etc/ || true # if ^C, will cancel script
mount --bind /dev ./dev
MOUNTED="dev $MOUNTED"
mount -t devpts devpts ./dev/pts -o nosuid,noexec
MOUNTED="pts $MOUNTED"
mount -t sysfs sys ./sys -o nosuid,nodev,noexec,ro
MOUNTED="sys $MOUNTED"
mount -t proc proc ./proc -o nosuid,nodev,noexec
MOUNTED="proc $MOUNTED"
mount -t tmpfs tmp ./tmp -o mode=1777,nosuid,nodev,strictatime
MOUNTED="tmp $MOUNTED"
mount -t tmpfs run ./run -o mode=0755,nosuid,nodev
MOUNTED="run $MOUNTED"
if [ -L ./dev/shm ]; then
 mkdir -p ./`readlink ./dev/shm`
 mount -t tmpfs shm ./`readlink ./dev/shm` -o mode=1777,nosuid,nodev
else
 #mkdir -p ./dev/shm
 mount -t tmpfs shm ./dev/shm -o mode=1777,nosuid,nodev
fi
MOUNTED="shm $MOUNTED"
case $1 in
 -l) shift;;
 -l*) one=${1#-l}; shift; set -- -"$one" "$@";;
esac
chroot . /usr/bin/env -i SHELL=/bin/sh HOME=/root TERM="$TERM" \
 PATH=/usr/sbin:/usr/bin:/sbin:/bin PS1='chroot # ' /bin/sh -l "$@"
# FIXME
# are USER and LOGNAME set automatically?
# perhaps: source /etc/profile && export PS1="chroot $PS1"
Clevis

== What is clevis ==
It is a software that allows to encrypt/decrypt a disk by bounding to tang (network bound encryption/decryption) or a TPM (hardware chip encryption/decryption).
It is in use in redhat fedora systems
== Why use clevis ==
With tang, you may automatically decrypt device block/files for convenience, it is encrypted and built to prevent man-in-the-middle attacks as well, since nobody gets private key, only an always changing advertised timed key.
* It is recommended to use a tang docker with this, you can use this for example: github or gitlab
== Auto Disk decryption using clevis + tang ==
You need to run tang in a separate server, from the one you want to decrypt. I recommend running a tang server on a docker.
=== mkinitfs + kernel-hooks + secureboot-hook ===
Using mkinitfs, it is possible to force tang/clevis in initramfs generation. It is recommended to make a chroot or docker so you don't mess with your system files, and by adding these files:
Edit /sbin/mkinitfs (put "# Copy custom init" before "# copy modloop signature"):
PUT "# Clevis + tang script" AFTER "ebegin "Mounting root""
Then just do:
----
=== dracut ===
== External sources ==
* https://fedoramagazine.org/using-linux-system-roles-to-implement-clevis-and-tang-for-automated-luks-volume-unlocking/
* https://www.admin-magazine.com/Archive/2018/43/Automatic-data-encryption-and-decryption-with-Clevis-and-Tang
* https://wiki.archlinux.org/title/Clevis
* https://man.archlinux.org/man/clevis-encrypt-tang.1.en
* https://github.com/latchset/clevis/blob/master/src/pins/tang/clevis-encrypt-tang.1.adoc
Category:Security Category:Booting
Collectd

= Installation =
= Configuration =
= Controlling Collectd =
== Start collectd ==
After the installation collectd is not running. To start collectd, use start.
You will get a feedback about the status.
 * Starting collectd ... [ ok ]
Alternatively you can also run collectd directly, from /usr/sbin/collectd
== Stop collectd ==
If you want to stop the server use stop.
== Restart collectd ==
After changing the configuration file collectd needs to be restarted.
== Runlevel ==
Normally you want to start the collectd server when the system is launching. This is done by adding collectd to the needed runlevel.
 * service collectd added to runlevel default
= Checking =
= Graphical interface =
* Collectd Graphical Panel
Category:Monitoring Category:Server
Configure Wake-on-LAN

Configuring Wake-on-LAN is a simple process on Alpine Linux. First, check if your network card supports Wake-on-LAN (WOL):
# apk add ethtool
# ethtool eth0 | grep -i wake
 Supports Wake-on: pumbg
 Wake-on: d
Supports Wake-on: pumbg means that WOL is supported, Wake-on: d means that it is currently disabled. To enable it, edit /etc/network/interfaces as follows:
auto eth0
 pre-up /usr/sbin/ethtool -s eth0 wol g
Reboot, and you should now be able to wake your machine from LAN. You can check if it is really enabled like so:
# ethtool eth0 | grep -i wake
 Supports Wake-on: pumbg
 Wake-on: g
Wake-on: g means that it is now enabled.
There are many tools that allow you to wake up the machine now that WOL is supported; https://github.com/sabhiram/go-wol is an excellent one.
Category:Networking
Category:Power Management
Configure action when power-button is pressed

This article explains how to configure what happens when you press the power button. This might be useful to allow for desktop environments to control what happens instead of shutting down.
# Install : 
# Enable and start the acpid daemon: 
== Busybox acpid ==
This can be done via Busybox acpid by creating/modifying the hook in . 
=== Configuring for shutdown === 
In a newly installed system this might be already defined, however you can create the hook as follows:
=== Configuring for sleep === 
# Install : 
# Modify the hook as follows: 
=== Disabling === 
To disable simply comment or remove the hook. This is useful to allow desktop environments to handle the power button.
Category:Power Management
category: Desktop
Connecting To Oracle Database

Connecting to a Oracle database directly does not seem to be possible due to the driver being compiled for GNU libc and it being proprietary. It is possible to connect to one database using Docker however. The image is proprietary as well, so a docker login is required and the "Proceed to Checkout" on https://hub.docker.com/_/oracle-instant-client has to be went through.
== Create the environment ==
First, create the container and mount the current directory:
docker run --name okcli -v ${PWD}:/data -d -e LC_CTYPE=en_US.UTF-8 store/oracle/database-instantclient:12.2.0.1 sh -c "yum update -y && yum install -y python3-pip util-linux vim && pip3 install okcli && tail -f /dev/null"
You may check if the installation has finished by running:
docker logs -f okcli
Now, whenever you need to connect to a database, run the following:
docker restart okcli && docker exec -it okcli sh -c "cd /data && sh"
== Option 1: Connecting with with okcli ==
okcli is a libre CLI to access a Oracle database. You can connect using it by now entering the following command in the prompt from above:
okcli 'myusername/mypassword@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=141.62.75.20)(Port=1521))(CONNECT_DATA=(SID=DB1)))'
You can run a script in the directory you've mounted above like so:
okcli 'myusername/mypassword@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=141.62.75.20)(Port=1521))(CONNECT_DATA=(SID=DB1)))' -@ myscript.sql
== Option 2: Connecting with with SQL Plus ==
SQL Plus is the proprietary CLI to access a Oracle database. You can connect using it by now entering the following command in the prompt from above:
sqlplus 'myusername/mypassword@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=141.62.75.20)(Port=1521))(CONNECT_DATA=(SID=DB1)))'
You can run a script in the directory you've mounted above like so:
sqlplus 'myusername/mypassword@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=141.62.75.20)(Port=1521))(CONNECT_DATA=(SID=DB1)))' @myscript.sql
Category:Database
Create Alpine Linux PV DomU

== Obtain a copy of Alpine Linux ==
To create an Alpine Linux paravirtualized (PV) DomU you'll need an Alpine Linux iso.
Download the latest alpine-virt iso from https://alpinelinux.org/downloads/
In this example we'll use for the download and disk images.
==Mount the ISO image ==
Next, mount the iso so you can read the kernel and initramfs:
Now you have the kernel in and initramfs in .
Alternatively you can use or to extract the content to a temporary area.
== Create the disk image ==
Now you need to create an empty file to be used as the hard drive of the DomU (in this example we are using a 3GB disk):
Alternatively, if an LVM volume group (e.g. vg1) with free space is available on dom0, create a logical volume for Alpine:
== Create a DomU config file that boots the ISO image ==
Next, create a basic DomU configuration file, so you can launch the pv guest iso (save it where you like, although the most common place is ).
If using LVM, replace with in the disk specification. 
== Install the guest ==
Now that you have the necessary files, you can start the DomU to proceed with the install:
Log into the system with user "root" and no password.
After configuring the basic system, you will be asked where would you like to install Alpine. Choose xvda and sys.
That will create three partitions on your disk. xvda1 for , xvda2 for swap and xvda3 for 
Available disks are:
 xvda	(3.1 GB )
Which disk(s) would you like to use? (or '?' for help or 'none') [none] xvda
The following disk is selected:
 xvda	(3.1 GB )
How would you like to use it? ('sys', 'data' or '?' for help) [?] sys
WARNING: The following disk(s) will be erased:
 xvda	(3.1 GB )
WARNING: Erase the above disk(s) and continue? [y/N]: y
Initializing partitions on /dev/xvda...
Creating file systems...
Installing system on /dev/xvda3:
Installation is complete. Please reboot.
#
When you reboot, the pv bootloader pvgrub, will look to for its menu, so create that file first. 
Mount the boot partition and create a file for pvgrub. (Note that grub.cfg is for pvgrub2 which replaced pvgrub1 and its menu.lst beginning in 2013.)
Install a basic text editor like or :
If using nano, enter:
Then add the following to create a basic grub2 configuration file:
Finally, Ctrl-S to save, Ctrl-X to exit nano.
Unmount and power off.
== Adjust the domU config file to boot from fresh install ==
In your Dom0, edit your DomU config file to boot with pvgrub.
Make sure that grub-xenhost is installed.
Remember to unmount the loopback iso image.
The next time you boot, you'll be presented with the grub boot menu, and your VM will boot.
== Using Legacy pvgrub ==
To use Legacy pvgrub you need to use a instead of .
And in you need to change the 'kernel' loader to
== See also ==
* Setting up Alpine Linux 3.7.0 as a domU VM on XenServer 7.2
Category:Virtualization
Create UEFI boot USB

This article explains how to create an UEFI boot USB with parted and gummiboot.
In this example we will use . This will be different depending on your system.
== Create GPT boot partition ==
Install 
Create a single UEFI boot partitions.
== Create fat32 filesystem ==
Create a fat32 system with the name `Alpine`.
== Copy content of ISO image to filesystem ==
It is possible to mount the iso image and copy files with or and it is also possible to use to extract content from the iso. In this example I will use the utility from package.
== Unmount the partition ==
Finally umount the disk
Create UEFI secureboot USB

This article explains how to create an UEFI boot USB with parted and rEFInd. Unfortunately the version of GRUB that ships with Alpine Linux did not work and Gummiboot only worked on one of two machines I tested. I will submit a PR for a rEFInd package and update these instructions to simplify them given time.
In this example we will use and $HOME. This will be different depending on your system. Substitute the paths in the examples below as necessary.
== Create GPT boot partition ==
Install 
Create a single UEFI boot partitions.
== Create fat32 filesystem ==
Create a fat32 system with the name `Alpine`.
== Copy content of ISO image to filesystem ==
It is possible to mount the iso image and copy files with or and it is also possible to use to extract content from the iso. In this example I will use the utility from package.
== Create MOK Key ==
== Download and install rEFInd ==
Download the binary zip file of rEFInd from https://www.rodsbooks.com/refind/getting.html. In this example we will use the current version of rEFInd, refind-bin-0.11.4.zip. There may be a more recent version of rEFInd available when you download.
== Copy signed shim ==
Download Matthew J. Garrett's signed shim from http://www.codon.org.uk/~mjg59/shim-signed/shim-signed-0.2.tgz. In this example we assume it is stored in your users download directory. Substitute the paths in the example below as necessary.
== Install Shim and Certificate ==
== Sign the Bootloader and kernel with your key ==
== Unmount the partition ==
Finally umount the disk
== Install the Keys and Enroll Hash ==
Insert the USB into the target PC and boot. When prompted select to enroll key, navigate to alpine_local.cer and add it. Then select enroll hash navigate to efi/boot/grubx64.efi select it and add the hash. Now reboot and given a bit of luck it should launch alpine. This step is a bit more complex than it needs to be due to the binary distribution of refind already being signed by the authors key. Once rEFInd is packaged it should simplify this step.
Category:Installation Category:UEFI
Create a bootable SDHC from a Mac

== Prepare Partition ==
Newer versions of MacOS does not allow you to set scheme. Creating MBR using fdisk will result in a disk that MacOS cannot mount. This instructions are out of date for newer versions of MacOS.
* Open disk utility
* Select your SD Card
* Click Erase in the menu
* Set Format to MS-DOS (FAT)
* Set Scheme to Master Boot Record
* Click the Erase button
== Unpack files ==
* Open Terminal
* Check your SD Card is mounted (in this case named "ALPINE")
* Unpack files with sudo tar xf ~/Downloads/alpine-rpi-[...]-armhf.rpi.tar.gz -C /Volumes/ALPINE
* Eject disk, it should now be ready to be used in the Raspberry Pi
== After initial setup ==
After this preparation you should boot the Raspberry Pi with a keyboard and a HDMI screen connected, login as root and run setup-alpine and lbu-commit.
Category:Installation
Create an Alpine 1.9 vserver template

= How to create an Alpine 1.9 vserver template =
A vserver template is a simple tar archive of a base install.
Install base packages into a temporary root
Vserver needs at least one process running when it boots up so we manually enable the syslog service in our template.
Create the archive as /tmp/template.tar.gz
Finally remove the temp dir.
Category:Virtualization
Cron

This page documents the working of Cron, a job scheduler on Unix-like operating systems. Cron is most suitable for scheduling repetitive tasks. Scheduling one-time tasks can be accomplished using the associated at utility. 
There are many cron implementations, but Alpine Linux comes inbuilt with the BusyBox version of cron. Some of the other packages available in Alpine Linux are , and .
For systems that do not run continuously, like laptops or regular desktop computers, cron jobs with large time intervals between invocations may not be executed at all if the system is suspended or powered off during the cron job's scheduled time. To work around this, many crond implementations provide special directives like @daily and @monthly which keep track of the last execution time and still execute if the system was down while the job was supposed to run.
Examples of how to achieve this in different crond implementations can be found below.
== Cronie ==
The package comes with anacron</Code> tool, which does this kind of asynchronous job processing. To use it, first install the package and configure it start at boot using OpenRC.
=== Anacron ===
Here are the steps to use anacron</Code> in Alpine Linux:
# Add the line to the crontab of the root user:
#: 
# Once edited, root crontab should appear as follows, when viewed using the command or viewed directly:
#:
# Anacron needs the folder to avoid the error . So create the folder using the command:
#: 
# Edit the configuration file and test the configuration validity by <Code>anacron -T</Code>.
# Reboot the computer to test the working of anacron. The syslog file captures messages from anacron and can be searched by <Code>cat /var/log/messages |grep anacron</Code>.
== dcron ==
Another available crond that fully integrates the features of anacron is , "dillon's lightweight cron daemon". To use it, first install the package:
Finally, start and tell OpenRC to start it at boot:
=== Configuration ===
You can add directives to the crontab with the crontab -e command, also including the @hourly, @daily, @weekly, @monthly and @yearly directives.
The syntax of these special directives slightly differs from anacron. Here is how Alpine's default could be adjusted to use the syntax with the special directives to ensure that they are executed even with systems that are not always running:
As you can see, the name or "ID" of a job is set in the style of a shell variable assignment. For more information about 's options and its crontab format, check out the crontab(1) and crond(8) manpages, which you can install with the package.
== See Also ==
* Archwiki Cron page
* Official cronie website
* Official dcron website
* crontab Generator
Category:System Administration‏‎ 
Category:Desktop
Cross-Compiler targeting Alpine

This page explains how I set up a cross-compiler on ArchLinux (both x86 and x86_64) targeting Alpine. There are only a few situations in which you'd want to do this. I had to do it because I wanted to port GHC to Alpine, and to do that, you need to start with some alreay-compiled GHC binary. So that meant cross-compiling from some system where the binaries were already available.
I used Buildroot to setup my cross-compiler. These instructions target Buildroot 2013.05 and Alpine 2.6.0, both released in May 2013. The specific versions installed by this Buildroot (as I've configured it) are:
* kernel headers v3.9.2
* uClibc v0.9.33.2
* binutils v2.23.2
* gcc v4.7.3
* gmp v5.1.1
* mpc v1.0.1
* mpfr v3.1.2 (Alpine currently using mpfr3-3.1.1)
* m4 v1.4.16
* autoconf v2.68 (Alpine currently using autoconf-2.69)
* automake v1.11.6 (Alpine currently using automake-1.13.1)
* libiconv v1.14 (Alpine currently using 1.12)
* libtool v2.2.10 (Alpine currently using libtool-2.4.2)
* ncurses v5.9
* libffi v3.0.13
Buildroot also installs BusyBox v1.12.0, but I ignore this.
The instructions below also describe how to install a cross-compiling LLVM and Clang v3.2 on top of the Buildroot tools. This might be useful for some purposes.
If you want to use these instructions as a basis for doing the same thing with more recent releases of Buildroot or targeting newer releases of Alpine, be sure to check for patches added to the Alpine ports tree, especially to gcc or uClibc, after 2.6.0.
<OL>
<LI>
I began by Installing ArchLinux inside an Alpine chroot.
<LI>
On the Arch system, install the following packages:
<LI>
On the Arch system, do the following:
<LI>
On the Arch system, prepare the sources and patches to build the cross-compiler.
<LI>
Now, compile buildroot:
<LI>
If the compilation was successful, then:
<LI>
(Optional) Download and compile LLVM and clang. (This needs the patch at , which hasn't yet made it into the aports tree.)
</OL>
Now on the Arch system you can do this:
Or you could use i486-buildroot-linux-uclibc-clang instead.
The resulting binary won't run on the Arch system (or from a shell launched from inside the Arch chroot, if the Arch system is on a chroot inside your Alpine system, as mine is). But it will run on the Alpine system (or from a shell launched from outside the Arch chroot).
Category:Development
Cups

#REDIRECT Printer Setup
 
== Installation ==
Install the CUPS package
== Make it autostart ==
Next time you reboot your Alpine Linux box, you would probably want cupsd to automatically start.
You can check your boot services:
== Configuring the cups server ==
Edit .
Replace Listen localhost:631 with Listen *:631
Allow hosts in your subnet to connect by adding Allow localhost and Allow from subnet/mask in <Location /> section:
# Restrict access to the server...
<Location />
 Order allow,deny
 Allow localhost 
 Allow from 192.168.0.0/24
</Location>
http://[CUPS server]:631/
Category:Server
Custom network interface names

This article shows how to rename/change name of a network interface.
Alpine Linux uses mdev by default to manage devices in . mdev reads and according to mdev documentation one can define a command to be executed per device definition. The command which is going to be used to change network interface name is nameif.
== configuration ==
Here we tell mdev to call nameif for devices found in .
== nameif configuration ==
nameif itself reads by default. Example line for a network interface with following hwaddr
would be
== ramdisk rebuild ==
 is part of ramdisk
thus we need to rebuild ramdisk
== finalization ==
To use renamed network interface without reboot, just call nameif while the network interface is down.
And finally reboot...
Category:Networking
D-Bus

D-Bus is a message bus system that provides a mechanism for inter-process communication.
Some services rely on a D-Bus session instance or expect it by default (including Pipewire). Other processes will only be able to communicate with these services if d-bus is running.
== Installation ==
Install the dbus package:
If you are using x11 you might also want to install the X11 add-ons which provide the dbus-launch command:
If you want dbus to be started at system startup enable the service:
To use the service without restarting you need to start it manually:
== D-Bus session ==
You can start a dbus session like this: dbus-run-session -- sh(replacing sh with your shell or a window manager), or, export $(dbus-launch).
D-Bus passes the environment variable $DBUS_SESSION_BUS_ADDRESS to its children. Running dbus-launch in a terminal means that other running process won't find this D-Bus's socket.
If $DBUS_SESSION_BUS_ADDRESS is undefined, many applications will attempt to use the standard path:
 $XDG_RUNTIME_DIR/bus
Running D-Bus like so should work for many applications:
For applications that dont work without $DBUS_SESSION_BUS_ADDRESS you can prepend your program with the follow workaround script which avoid launching multiple user dbus sessions:
 #!/bin/sh
 if [ ! -e "/tmp/dbus-$USER-env" ]; then
 echo "Creating new dbus session on /tmp/dbus-$USER-env"
 export $(dbus-launch)
 echo "${DBUS_SESSION_BUS_ADDRESS}" > /tmp/dbus-$USER-env
 echo "Dbus session address is: ${DBUS_SESSION_BUS_ADDRESS}"
 else
 echo "Using dbus session address from /tmp/dbus-$USER-env"
 export DBUS_SESSION_BUS_ADDRESS="$(cat /tmp/dbus-$USER-env)"
 echo "Dbus session address is: ${DBUS_SESSION_BUS_ADDRESS}"
 fi
 if [ -n "$1" ]; then
 $@
 fi
== See also ==
* Pipewire and D-Bus
* Archwiki
* Gentoo Wiki
Category:System Administration