Alpine setup scripts

Feature descriptions for available Alpine Linux setup scripts ().
These scripts can be installed by using apk to install the alpine-conf package.
If you don't have an Alpine Linux install, you can find and examine the scripts in their git repository.
== setup-alpine ==
This is the main Alpine configuration and installation script.
The script interactively walks the user through executing several auxiliary setup-* scripts, in the order shown below.
The bracketed options represent example configuration choices, formatted as they may be supplied when manually calling the auxiliary setup scripts, or using a setup-alpine "answerfile" (see below).
# setup-keymap [us us]
# setup-hostname [-n alpine-test]
# setup-interfaces [-i < interfaces-file]
# rc-service networking --quiet start &
# if none of the networking interfaces were configured using dhcp, then: setup-dns [-d example.com -n "192.168.0.1 [...]"]
# set the root password
# if not in quick mode, then: setup-timezone [-z UTC | -z America/New_York | -p EST+5]
# enable the new hostname (rc-service hostname --quiet restart)
# add networking and seedrng (also referred to as urandom in versions prior to OpenRC 0.45) to the boot rc level, and acpid and crond to the default rc level, and start the boot and default rc services
# extract the fully-qualified domain name and hostname from and hostname, and update 
# setup-proxy [-q "http://webproxy:8080"], and activate proxy if it was configured
# setup-apkrepos [-r (to select a mirror randomly)]
# setup-user
# if not in quick mode, then: setup-sshd [-c openssh | dropbear | none]
# if not in quick mode, then: setup-ntp [-c chrony | openntpd | busybox | none]
# if not in quick mode, then: DEFAULT_DISK=none setup-disk -q [-m data /dev/sda] (see Installation#Installation_Overview about the disk modes)
# if installation mode selected during setup-disk was "data" instead of "sys", then: setup-lbu []
# if installation mode selected during setup-disk was "data" instead of "sys", then: setup-apkcache [ | none]
setup-alpine itself accepts the following command-line switches:
;-c answerfile
:Create a new answerfile with default choices. You can edit the file and then invoke setup-alpine -f answerfile.
;-f answerfile
:Use an existing answerfile, which may override some or all of the interactive prompts. You can also specify a HTTP(S) or FTP URL for setup-alpine to download an answerfile from. Doing so will spin up a temporary networking config if one is not already active.
== setup-hostname ==
:setup-hostname [-h] [-n hostname]
Options:
-h Show help
-n Specify hostname
This script allows quick and easy setup of the system hostname by writing it to . The script prevents you from writing an invalid hostname (such as one that used invalid characters or starts with a '-' or is too long).
The script can be invoked manually or is called as part of the setup-alpine script.
== setup-interfaces ==
Note that the contents of interfaces-file has to be supplied as stdin, rather than naming the file as an additional argument. The contents should have the format of , such as:
== setup-dns ==
:setup-dns [-h] [-d domain name] [-n name server]
Options:
-h Show help 
-d specify search domain name
-n name server IP 
The setup-dns script is stored in and allows quick and simple setup of DNS servers (and a DNS search domain if required). Simply running setup-dns will allow interactive use of the script, or the options can be specified.
The information fed to this script is written to 
Example usage (with 192.168.0.1 being the local router/dns-forwarder): 
Example :
It can be run manually but is also invoked in the setup-alpine script unless interfaces are configured for DHCP.
== setup-timezone ==
:setup-timezone [-z UTC | -z America/New_York | -p EST+5]
Can pre-select the timezone using either of these switches:
-z subfolder of 
-p POSIX TZ format
To manually change the time-zone, see Setting the timezone.
== setup-proxy ==
:setup-proxy [-hq] [PROXYURL]
Options:
-h Show help 
-q Quiet mode prevents changes from taking effect until after reboot
This script requests the system proxy to use in the form http://<proxyurl>:<port> for example:
http://10.0.0.1:8080
To set no system proxy use none.
This script exports the following environmental variables: 
http_proxy=$proxyurl 
https_proxy=$proxyurl
ftp_proxy=$proxyurl
where $proxyurl is the value input. 
If none was chosen then the value it is set to a blank value (and so no proxy is used).
== setup-apkrepos ==
:setup-apkrepos [-fhr] [REPO...]
Setup apk repositories.
options:
-c Enable the community repo
-f Detect and add fastest mirror
-h Show help
-r Add a random mirror and do not prompt
-1 Add first mirror on the list (normally a CDN)
This is run as part of the setup-alpine script.
== setup-user ==
:setup-user [-h] [-a] [-u] [-f FULLNAME] [-g GROUPS] [-k SSHKEY] [USERNAME]
Options:
-h Show help 
-a Create admin user. Add to wheel group and setup doas.
-u Unlock the user automatically (eg. create the user non-interactively with an ssh key for login)
-f Set the full name for the user
-g Comma or space separated list of groups to add user to
-k ssh key or URL to ssh key (eg. https://gitlab.alpinelinux.org/user.keys) or none for no key
If USERNAME is not specified user will be prompted.
The setup-user script is stored in and allows quick and simple setup of user accounts. 
It can be run manually but is also invoked in the setup-alpine script.
== setup-sshd ==
:setup-sshd [-h] [-c choice of SSH daemon]
Options:
-h Show help 
-c SSH daemon where SSH daemon can be one of the following:
openssh install the daemon
dropbear install the daemon
none Do not install an SSH daemon
Example usage: 
The setup-sshd script is stored in and allows quick and simple setup of either the OpenSSH or Dropbear SSH daemon & client. 
It can be run manually but is also invoked in the setup-alpine script.
== setup-ntp ==
From Wikipedia:
The Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. 
setup-ntp script is stored in and allows quick and simple setup of the NTP client,
It can be run manually but is also invoked in the setup-alpine script.
== setup-disk ==
:DEFAULT_DISK=none setup-disk -q [-m data | sys] [mountpoint directory | ...]
In "sys" mode, it's an installer, it permanently installs Alpine Linux on the disk, in "data" mode, it provides a larger and persistent volume.
This script accepts the following command-line switches:
;-k kernel flavor
;-o apkovl file
:Restore system from apkovl file
;-m data | sys
:Don't prompt for installation mode. With -m data, the supplied devices are formatted to use as a volume.
;-s swap size in MB
:Use 0 to disable swap
The script honors the following environment variables:
=== Environment Variables === 
The following environment variables can be combined and used.
If BOOTLOADER is specified, the specified bootloader will be used.
If no bootloader is specified, the default bootloader is syslinux(extlinux)
except when EFI is detected or explicitly set by USE_EFI which will select grub.
Supported bootloaders are: grub, syslinux
If KERNELOPTS is specified, it will be appended to the kernel boot parameters.
Default is: quiet
If DISKLABEL is specified, the specified partition label will be used.
if no partition label is specified, the default label will be dos
except when EFI is detected or explicitly set by USE_EFI which will select gpt.
Supported partition labels are: dos, gpt
If BOOTFS, ROOTFS, VARFS are specified, then format a partition with specified filesystem. If not specified, the default filesystem is ext4. VARFS is used, only if -m data is specified or interactively selected whereas BOOTFS and ROOTFS are used only if -m sys is specified or interactively selected.
Supported filesystems for
 boot: ext2, ext3, ext4, btrfs, xfs, vfat(EFI)
 root: ext2, ext3, ext4, btrfs, xfs
 var : ext2, ext3, ext4, btrfs, xfs
If BOOT_SIZE is specified, sets the size of the boot partition in MB; defaults to 100. Only used if -m sys is specified or interactively selected.
If SWAP_SIZE is specified, sets the size of the swap volume in MB; set to 0 to disable swap. If not specified, will default to twice RAM, up to 4096, but won't be more than 1/3 the size of the smallest disk, and if less than 64 will just be 0. Only used if -m sys is specified or interactively selected.
If SYSROOT is specified, sets the Mountpoint to use when creating volumes and doing traditional disk install (-m sys). Defaults to .
If MBR is specified, sets the Path of MBR binary code, defaults to .
=== Partitioning ===
If you have complex partitioning needs, that go beyond environment variables for setup-alpine, you can partition, format, and mount your volumes manually, and then just supply the root mountpoint to setup-disk. Doing so implicitly behaves as though -m sys had also been specified.
==== RAID ====
setup-disk will automatically build a RAID array if you supply the -r switch, or if you specify more than one device. The array will always be RAID1 (and --metadata=0.90) for the volumes, but will be RAID5 (and --metadata=1.2 for non-boot volumes when 3 or more devices are supplied.
If you instead want to build your RAID array manually, see Setting up a software RAID array. Then format and mount the disks, and supply the root mountpoint to setup-disk.
==== LVM ====
setup-disk will automatically build and use volumes in a LVM group if you supply the -L switch. The group and volumes created by the script will have the following names:
* volume group: vg0
* swap volume: lv_swap (only created when swap size > 0)
* root volume: lv_root (only created when -m sys is specified or interactively selected)
* var volume: lv_var (only created when -m data is specified or interactively selected)
The lv_var or lv_root volumes are created to occupy all remaining space in the volume group.
If you need to change any of these settings, you can use vgrename, lvrename, lvreduce or lvresize.
If you instead want to build your LVM system manually, see Setting up Logical Volumes with LVM. Then format and mount the disks, and supply the root mountpoint to setup-disk.
== setup-lbu ==
This script will only be invoked for by setup-alpine when installing data installation types (ramdisk)
It configures where lbu commit will store the .apkovl backup. See Alpine local backup for more information.
When started, setup-lbu will prompt where to store your data. The options it will prompt for will be taken from the directories found in /media (except for cdrom). [not sure how these are mounted: are they automatically mounted by setup-lbu? Does the user have to manually mount using another tty?]
== setup-apkcache ==
This script will only be invoked for by setup-alpine when installing data installation types (ramdisk)
It configures where to save the apk package files. The apkcache is where apk stores downloaded packages, such that the system does not need to download them again on each reboot, and doesn't have to depend on the network. See Local APK cache for a detailed explanation.
You should be able to use a partition that you set up in the previous steps.
== setup-devd ==
This is a standalone script; it's not invoked by setup-alpine but must be run manually to setup a Device manager.
Refer setup-devd source. 
== setup-bootable ==
This is a standalone script; it's not invoked by setup-alpine but must be run manually.
It allows to create boot media that boots the system running from RAM memory (diskless) like the installation images, but using a writable (i.e. not iso9660) filesystem. So that it can also serve to store local customizations (e.g. apkovl files and cached packages). 
First, the script copies files from an ISO image (as file on a CD/DVD/USB etc.) onto a USB-Stick/CompactFlash/SDCard etc., or harddisk partition. And then, it installs the syslinux bootloader to make the device bootable.
However, its current syslinux installation seems to fail on non-FAT32 partitions. So in these cases, you may start over with a FAT32 filesystem, or rather with the desired filesystem and using setup-bootable only with the -u option, to skip the syslinux install, and then refer to the manual method to fix the problem, or use one of the other bootloader options, instead.
 
The setup-bootable script accepts the following arguments and command-line switches (you can run setup-bootable -h to see a usage message).
The argument source can be a directory or an ISO (will be mounted to MNT or ) or a URL (will be downloaded with WGET or wget). The argument dest can be a directory mountpoint, or will default to if not supplied.
The script will ensure that source and dest are available; will copy the contents of source to dest, ensuring first that there's enough space; and unless -u was specified, will make dest bootable.
Suppose the target device is , then this partition can be prepared for booting with
For the manual way to set up boot media see Manually_copying_Alpine_files.
== setup-xorg-base ==
This is a standalone script; it's not invoked by setup-alpine but must be run manually.
It configures a graphical environment, installing basic Xorg packages and eudev (replacing mdev), and is also required for Wayland sessions, if Xwayland is used.
The script installs, among other packages, e.g.: xorg-server xf86-input-libinput xinit eudev.
Additional packages to install may be supplied as arguments.
== setup-wayland-base ==
This is a standalone script; it's not invoked by setup-alpine but must be run manually.
usage: setup-wayland-base [-h] [PKG..]
Set up system to use Wayland
options:
 -h Show this help
Installs the packages , and , enables community repository, enables the service for eudev and install the packages PKG if specified.
== setup-desktop ==
This script is used to set up a desktop environment. This is a replacement for the now-removed alpine-desktop package.
== Documentation needed ==
=== setup-xen-dom0 ===
=== setup-mta ===
Uses ssmtp.
This is a standalone script; it's not invoked by setup-alpine but must be run manually.
=== setup-acf ===
:setup-acf [-ahn] [-e email] [-l address] [PACKAGE...]
Options:
-a Which acf-* packages to install 
-h Show help 
-n Don't create 
-e email address (for TLS certificate)
-l hostname for mini_httpd 
 
This is a standalone script; it's not invoked by setup-alpine but must be run manually.
This script was named setup-webconf before Alpine 1.9 beta 4.
See ACF pages for more information.
= See also =
* Installation
* Post Install
Category:Installation