Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor adoptions to fit with today's Archlinux plus an explanation of all available parameters written in Markdown. #2

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitingnore → .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
local.txt
prime.txt
users.csv

#
# IntelliJ Idea
#
/.idea/
77 changes: 62 additions & 15 deletions arch-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ fi
BASE_GROUPS="adm,audio,disk,lp,optical,storage,video,games,power,scanner,uucp"
DSK=""
NFS_CACHE=""
PKG_CACHE="/var/cache/pacman/pkg"
FQDN="arch.example.org"
TIMEZONE="Europe/London"
KEYMAP="uk"
DEFAULT_KEYMAP="uk"
LANG="en_GB.UTF-8"
LOCALE=`echo ${LANG} | cut -d'.' -f1`
LC_COLLATE="C"
Expand Down Expand Up @@ -48,9 +49,9 @@ function usage() {
echo
echo "Usage"
if [ "${MODE}" == "install" ]; then
echo " ${0} -d sda -p brh -w P@ssw0rd -b ${PARTITION_TYPE} -f ${FS} -k ${KEYMAP} -l ${LANG} -n ${FQDN} -t ${TIMEZONE}"
echo " ${0} -d sda -p brh -w P@ssw0rd -b ${PARTITION_TYPE} -f ${FS} -k ${DEFAULT_KEYMAP} -l ${LANG} -n ${FQDN} -t ${TIMEZONE}"
else
echo " ${0} -w P@ssw0rd -k ${KEYMAP} -l ${LANG} -n ${FQDN} -t ${TIMEZONE}"
echo " ${0} -w P@ssw0rd -k ${DEFAULT_KEYMAP} -l ${LANG} -n ${FQDN} -t ${TIMEZONE}"
fi
echo
echo "Required parameters"
Expand All @@ -72,7 +73,7 @@ function usage() {
fi
echo " -c : The NFS export to mount and use as the pacman cache."
echo " -e : The desktop environment to install. Defaults to '${DE}'. Can be 'none', 'cinnamon', 'gnome', 'kde', 'lxde', 'mate' or 'xfce'"
echo " -k : The keyboard mapping to use. Defaults to '${KEYMAP}'. See '/usr/share/kbd/keymaps/' for options."
echo " -k : The keyboard mapping to use. Defaults to '${DEFAULT_KEYMAP}'. See '/usr/share/kbd/keymaps/' for options."
echo " -l : The language to use. Defaults to '${LANG}'. See '/etc/locale.gen' for options."
echo " -n : The hostname to use. Defaults to '${FQDN}'"
echo " -r : The computer role. Defaults to '${INSTALL_TYPE}'. Can be 'desktop' or 'server'."
Expand Down Expand Up @@ -176,20 +177,20 @@ function test_nfs_cache() {
echo
echo "Testing NFS cache : ${NFS_CACHE}"
systemctl start rpc-statd.service >/dev/null
mount -t nfs ${NFS_CACHE} /var/cache/pacman/pkg >/dev/null
mount -t nfs ${NFS_CACHE} ${PKG_CACHE} >/dev/null
if [ $? -ne 0 ]; then
echo "ERROR! Unable to mount ${NFS_CACHE}"
echo " - See `basename ${0}` -h"
exit 1
fi

# Make sure the cache is writeable
touch /var/cache/pacman/pkg/cache.test 2>/dev/null
touch ${PKG_CACHE}/cache.test 2>/dev/null
if [ $? -ne 0 ]; then
echo "ERROR! The NFS cache, ${NFS_CACHE}, is read-only."
exit 1
else
rm /var/cache/pacman/pkg/cache.test 2>/dev/null
rm ${PKG_CACHE}/cache.test 2>/dev/null
fi
fi
}
Expand Down Expand Up @@ -318,9 +319,31 @@ function mount_disks() {
fi
}

function bind_pacman_cache() {
echo "==> Bind mounting pacman cache"
mkdir -p ${TARGET_PREFIX}${PKG_CACHE}
mount --bind ${TARGET_PREFIX}${PKG_CACHE} ${PKG_CACHE}
}

function chain_package_lists() {
# Chain package lists
for f in $*; do
if [ -r $f ]; then
files+="$f "
else
echo "ERROR! file $f not readable."
fi
done

if [ -n "${files}" ]; then
# Remove lines starting with #, replace trailing comments introduced by #, remove empty lines
cat ${files} | sed '/^#.*$/d' | sed 's/[[:space:]]*#.*$//' | sed '/^[[:space:]]*$/d'
fi
}

function build_packages() {
# Chain packages
cat packages/base/packages-extra.txt > /tmp/packages.txt
chain_package_lists packages/base/packages-extra.txt > /tmp/packages.txt
if [ "${DE}" != "none" ] && [ "${INSTALL_TYPE}" == "desktop" ]; then
if [ "${DE}" == "kde" ]; then
if [ "${LOCALE}" == "pt_BR" ] || [ "${LOCALE}" == "en_GB" ] || [ "${LOCALE}" == "zh_CN" ]; then
Expand All @@ -342,18 +365,18 @@ function build_packages() {
fi

# Chain the DE packages.
cat packages/desktop/packages-xorg.txt packages/desktop/packages-${DE}.txt packages/desktop/packages-gst.txt packages/desktop/packages-cups.txt packages/desktop/packages-ttf.txt >> /tmp/packages.txt
chain_package_lists packages/desktop/packages-xorg.txt packages/desktop/packages-${DE}.txt packages/desktop/packages-gst.txt packages/desktop/packages-cups.txt packages/desktop/packages-ttf.txt >> /tmp/packages.txt
fi
}

function install_packages() {
# Install packages
if [ "${MODE}" == "install" ]; then
pacstrap -c ${TARGET_PREFIX} $(cat packages/base/packages-base.txt /tmp/packages.txt)
pacstrap -c ${TARGET_PREFIX} $(chain_package_lists packages/base/packages-base.txt /tmp/packages.txt)
if [ $? -ne 0 ]; then
echo "ERROR! 'pacstrap' failed. Cleaning up and exitting."
if [ -n "${NFS_CACHE}" ]; then
umount -fv /var/cache/pacman/pkg
umount -fv ${PKG_CACHE}
fi
if [ "${PARTITION_LAYOUT}" == "brh" ]; then
umount -fv ${TARGET_PREFIX}/home
Expand All @@ -363,7 +386,7 @@ function install_packages() {
fi
else
pacman -Rs --noconfirm heirloom-mailx
pacman -S --noconfirm --needed $(cat packages/base/packages-base.txt)
pacman -S --noconfirm --needed $(chain_package_lists packages/base/packages-base.txt)
if [ "${BASE_ARCH}" == "x86" ]; then
pacman -S --noconfirm --needed $(cat /tmp/packages.txt)
else
Expand Down Expand Up @@ -393,6 +416,9 @@ function build_configuration() {
# Start building the configuration script
start_config

# Start building the configuration script
start_postinstall

# Configure the hostname.
add_config "echo ${FQDN} > /etc/hostname"
add_config "hostnamectl set-hostname --static ${FQDN}"
Expand All @@ -404,7 +430,9 @@ function build_configuration() {
# Font and font map
FONT="ter-116b"

add_config "echo KEYMAP=${KEYMAP} > /etc/vconsole.conf"
add_postinstall "# Set keymap to none first, to make sure localectl sets keymap for vconsole and X11."
add_postinstall "localectl set-keymap none"
add_postinstall "localectl set-keymap ${KEYMAP}"
add_config "echo FONT=${FONT} >> /etc/vconsole.conf"
add_config "echo FONT_MAP=${FONT_MAP} >> /etc/vconsole.conf"
add_config "sed -i \"s/#${LANG}/${LANG}/\" /etc/locale.gen"
Expand Down Expand Up @@ -623,6 +651,15 @@ function build_configuration() {
fi
done
fi

if [ "${MODE}" == "install" ]; then
proxies="$(set | grep -i -E "^[a-z]*_proxy")"
for proxy in $proxies; do
add_config "echo export ${proxy} >> /etc/profile.d/proxy.sh"
done
fi

add_postinstall "systemctl disable arch-postinstall"
}

function apply_configuration() {
Expand All @@ -638,9 +675,9 @@ function apply_configuration() {
function cleanup() {
sync
if [ -n "${NFS_CACHE}" ]; then
addlinetofile "${NFS_CACHE} /var/cache/pacman/pkg nfs defaults,relatime,noauto,x-systemd.automount,x-systemd.device-timeout=5s 0 0" ${TARGET_PREFIX}/etc/fstab
addlinetofile "${NFS_CACHE} ${PKG_CACHE} nfs defaults,relatime,noauto,x-systemd.automount,x-systemd.device-timeout=5s 0 0" ${TARGET_PREFIX}/etc/fstab
if [ "${MODE}" == "install" ]; then
umount -fv /var/cache/pacman/pkg
umount -fv ${PKG_CACHE}
fi
fi

Expand Down Expand Up @@ -715,6 +752,13 @@ if [ $? -ne 0 ]; then
exit 1
fi

if [ -z "${KEYMAP}" ]; then
echo "==> Keyboard mapping not defined, try to determine from install environment"
KEYMAP="$(cat ~/.zsh_history | awk -F";" '{print $NF}' | grep "^loadkeys " | tail -1 | awk '{print $2}')"
if [ -z "${KEYMAP}" ]; then
KEYMAP="${DEFAULT_KEYMAP}"
fi
fi
KEYMAP_TEST=`ls -1 /usr/share/kbd/keymaps/*/*/*${KEYMAP}*`
if [ $? -ne 0 ]; then
echo "ERROR! The keyboard mapping you specified, '${KEYMAP}', is not recognised."
Expand All @@ -737,6 +781,9 @@ final_warning
if [ "${MODE}" == "install" ]; then
format_disks
mount_disks
if [ -z "${NFS_CACHE}" ]; then
bind_pacman_cache
fi
fi

build_packages
Expand Down
22 changes: 22 additions & 0 deletions common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,28 @@ add_config() {
echo "${1}" >> ${TARGET_PREFIX}/usr/local/bin/arch-config.sh
}

start_postinstall() {
cat <<- 'EOF' > ${TARGET_PREFIX}/etc/systemd/system/arch-postinstall.service
[Unit]
Description=Post Install Script

[Service]
ExecStart=/usr/local/bin/arch-postinstall.sh

[Install]
WantedBy=local-fs.target
EOF

add_config "systemctl enable arch-postinstall"

echo "#!/usr/bin/env bash" > ${TARGET_PREFIX}/usr/local/bin/arch-postinstall.sh
chmod +x ${TARGET_PREFIX}/usr/local/bin/arch-postinstall.sh
}

add_postinstall() {
echo "${1}" >> ${TARGET_PREFIX}/usr/local/bin/arch-postinstall.sh
}

detect_laptop() {
# Are we a mac?
if test -d /proc/pmu; then
Expand Down
62 changes: 62 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
The power of ArchInstaller a little more in detail. Enjoy!

# Parameters

The script arch-install.sh supports several parameters to customize the
Archlinux installation. Some of the parameters are required but most of
them are optional.

## Required parameters

| Parameter | Explanation | Options | Example |
|--- |--- |--- |--- |
| -d | Target device. | - | sda |
| -p | Partition layout. | brh / br | brh: /boot, /root, /home
| | | | br: /boot, /root
| -w | Root password, unencrypted. | - | brh: /boot, /root, /home


#. -d sda -p brh -w test-124 -b msdos -f xfs -e xfce -k de-latin1 -l en_US.UTF-8 -n arch001 -r desktop -t Europe/Berlin

## Optional parameters

| Parameter | Explanation | Options | Example |
|--- |--- |--- |--- |
| -b | Partition type. Default: msdos | msdos / gpt | msdos |
| -f | Filesystems to format the partitions. Default: ext4 | bfs / btrfs / ext2 / ext3 / ext4 / f2fs / jfs / nilfs / ntfs / reiserfs / xfs | xfs
| -c | NFS export to mount and used as pacman cache. | - | nas.local:/srv/pacman/cache
| -e | Desktop environment to install. Default: none | none / cinnamon / gnome / kde / lxde / mate / xfce | xfce
| -k | Keyboard mapping. Default: uk | See '/usr/share/kbd/keymaps/' for options. | de-latin1
| -l | System language. Default: en_GB.UTF-8 | See '/etc/locale.gen' for options. | en_US.UTF-8
| -n | Hostname, fully qualified. Default: arch.example.org | - | arch001.local
| -r | Computer role. Default: desktop | desktop / server | desktop
| -t | Timezone. Default: Europe/London | See '/usr/share/zoneinfo/' for options. | Europe/Berlin


## Example

The following command installs Archlinux with these attributes:

- Desktop system leveraging XFCE as desktop environment
- English as system language
- German keyboard layout
- German timezone
- Erase disk /dev/sda and format with a classical partitioning.
- Create three filesystems: /boot, /root and /home, the latter two
formated with XFS, /boot is always ext2
- Simple root password, don't use it in your installation
- Set hostname to arch001.local

`./arch-install.sh -d sda -p brh -w test-123! -b msdos -f xfs -e xfce -k
de-latin1 -l en_US.UTF-8 -n arch001.local -r desktop -t Europe/Berlin`

# User provisioning

To provision users create a file in the following format to define user
accounts.

`
"username,password,comment,extra_groups"
`


3 changes: 1 addition & 2 deletions packages/base/packages-extra.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
alsa-firmware
avahi
b43-fwcutter
bluez-firmware
#bluez-firmware
btrfs-progs
ca-certificates
cpupower
Expand Down Expand Up @@ -35,4 +35,3 @@ wireless-regdb
wireless_tools
wpa_supplicant
xfsprogs
zd1211-firmware
2 changes: 1 addition & 1 deletion packages/desktop/packages-cinnamon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ gnome-screenshot
gnome-system-log
gnome-system-monitor
gksu
lightdm-gtk3-greeter
lightdm-gtk-greeter
nemo
networkmanager-openvpn
networkmanager-pptp
Expand Down
1 change: 0 additions & 1 deletion packages/desktop/packages-cups.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ cups-filters
foomatic-db
foomatic-db-engine
foomatic-db-nonfree
foomatic-filters
ghostscript
gsfonts
gutenprint
2 changes: 1 addition & 1 deletion packages/desktop/packages-mate.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
lightdm-gtk-greeter
accountsservice
cups-pk-helper
lightdm-gtk2-greeter
mate
mate-extras
network-manager-applet
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/packages-xfce.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lightdm-gtk2-greeter
lightdm-gtk-greeter
xfce4
xfce4-goodies
network-manager-applet
Expand Down