Add configure-locale implementation

install-scripts
trivernis 2 years ago
parent 5f6ece5f42
commit 5548e05319
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,5 +1,47 @@
let RUN_IN_CHROOT = true;
def set_keymap [keymap: string] {
debug $"Setting keymap to ($keymap)"
touch /etc/vconsole.conf
$"\nKEYMAP=($keymap)" | save -a /etc/vconsole.conf
}
def set_timezone [timezone: string] {
debug $"Setting timezone to ($timezone)"
run ln -sf $"/usr/share/zoneinfo/($timezone)" /etc/localtime
run hwclock --systohc
}
def set_locales [locales] {
debug $"Setting locales to ($locales)"
mut new_locales = $locales
if ($new_locales | length) == 0 {
warn "No locale configured. Defaulting to en_US.UTF_8"
# set a default locale
$new_locales = ["en_US.UTF-8 UTF-8"]
"LANG=en_US.UTF-8" | save -f /etc/locale.conf
} else {
# save the first locale as the leading one
let first_locale = ($new_locales.0 | split row " " | get 0)
$"LANG=($first_locale)" | save -f /etc/locale.conf
}
$new_locales | each {|$locale|
let locale_parts = ($locale | split row " ")
let locale_name = $locale_parts.0
let encoding = $locale_parts.1
$"($locale_name) ($encoding)\n" | save -a /etc/locale.gen
}
run locale-gen
}
# Applies all system changes of `configure-locale`
def main [cfg] {
echo "Executing up task `configure-locale` with config" $cfg
debug $"Configuring locale with config ($cfg)"
set_keymap $cfg.keymap
set_timezone $cfg.timezone
set_locales $cfg.locale
info "Locale configured"
}

@ -43,7 +43,7 @@ impl Command for TodoCommand {
String::from("TODO"),
format!("This is a TODO: {}", args.join(" ")),
Some(call.span()),
Some(String::from("Implement this functionality")),
Some(args.join(" ")),
vec![],
))
}

Loading…
Cancel
Save