-
Notifications
You must be signed in to change notification settings - Fork 2
/
arch-setup
87 lines (77 loc) · 3.21 KB
/
arch-setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/sh
#
# Arch Linux in WSL basic configuration and installation of the basic tools.
#
# Written for WSL import of bootstrap archive as of 2021.04.01.
# To be executed immediately after a clean install, but can also be run later
# and repeated without creating trouble.
#
# Script must be run by root user, since it is installing sudo and cannot
# execute commands with regular sudo prompt, and also because it creates/edits
# global config (including the sudoers config) which must be done as root.
#
# Based on separate "sub-scripts" for each main action performed (documented below),
# which can also be executed separately.
#
# Main actions:
# - Minimize filesystem, reducing size with about 100 MiB by removing
# unused locales, character sets, documentation etc, and configuring
# pacman to not later install them.
# - Configure pacman. Creates a new mirrorlist file (in /etc/pacman.d)
# with a hard coded repository url, to be sure that it can continue installing
# packages with pacman, a backup of the original mirrorlist file will be left behind.
# - Ensure complete timezone database, because by default there are a lot missing
# zonedefinitions from the tzdata package, and then WSL's automatic mapping from
# Windows timezone may not work.
# - Perform full package database update and package upgrade.
# - Install some basic utilities, such as sudo, sed, grep, wget, nano, etc.
# - Configure system locale (en_us.UTF-8).
# - Configure sudo, setting the built-in administrators group 'wheel' as allowed sudoer.
# - Configure shell environment. When running in WSL, update prompt and terminal title
# for all users, including root, to use the WSL distro name in place of hostname.
# Also modifies the prompt to use more coloring, and adds alias for auto color on ls
# and grep (ls is default, not grep). Writes user-specific .bashrc in profile
# directories, does not modify global configuration.
#
# Contains hard coded configuration (spread accross the different sub-scripts):
# - Generates and activates system locale en_US.UTF-8, removes everything else
# except for en_GB and nb_NO internationalization sources.
# - Sets time zone Europe/Stockholm, which is part of the "Central European Time" (CET),
# with UTC offset +1.
# - Enables the single package repository mirror mirror.terrahost.no.
#
# Passes any script arguments to the pacman install commands, so can execute script
# with --noconfirm for instance to run non-interactively proceeding without prompting
# user.
#
# Verify running as root (not relying on sudo which may not be installed yet).
if [ ${EUID:-$(id -u)} -ne 0 ]; then
echo 'Please run this script as root'
exit 1
fi
restart_required=0
echo "Minimizing filesystem..."
. "${0}-minimize"
echo
echo "Configuring pacman..."
. "${0}-pacman"
echo
echo "Configuring packages..."
. "${0}-packages"
echo
echo "Configuring locale..."
. "${0}-locale"
echo
echo "Configuring sudo..."
. "${0}-sudo"
echo
echo "Configuring bash shell environment"
. "$(dirname ${0})/bash-setup"
echo
echo Done
if [ "$restart_required" -ne 0 ]; then
echo "NOTICE: Restarting is required for some of the changes to be applied!"
if [ -n "$WSL_DISTRO_NAME" ]; then
echo " From WSL host, execute: wsl --shutdown"
fi
fi