Add help texts to menu. Run configurator automatically if configuration
is missing.
This commit is contained in:
parent
3ab705d2b0
commit
3420fe4a69
|
@ -1,8 +1,25 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
# Script setup
|
# Initialize script environment
|
||||||
|
|
||||||
|
# Find the directory this script is stored in. (from: http://stackoverflow.com/questions/59895)
|
||||||
|
function get_source_dir() {
|
||||||
|
local source="${BASH_SOURCE[0]}"
|
||||||
|
while [[ -h $source ]]
|
||||||
|
do
|
||||||
|
local tmp="$(cd -P "$(dirname "${source}")" && pwd)"
|
||||||
|
source="$(readlink "${source}")"
|
||||||
|
[[ $source != /* ]] && source="${tmp}/${source}"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo -n "$(realpath "$(dirname "${source}")")"
|
||||||
|
}
|
||||||
|
|
||||||
|
GENTOO_INSTALL_REPO_DIR="$(get_source_dir)"
|
||||||
|
cd "$GENTOO_INSTALL_REPO_DIR" || { echo "Could not change into directory '$GENTOO_INSTALL_REPO_DIR'"; exit 1; }
|
||||||
|
|
||||||
# TODO check install dialog
|
# TODO check install dialog
|
||||||
echo "Please install dialog on your system to use the configurator"
|
echo "Please install dialog on your system to use the configurator"
|
||||||
|
@ -11,8 +28,14 @@ echo "Please install dialog on your system to use the configurator"
|
||||||
################################################
|
################################################
|
||||||
# Configuration storage
|
# Configuration storage
|
||||||
|
|
||||||
|
SAVE_AS_FILENAME="${1-"gentoo.conf"}"
|
||||||
|
if [[ -e "$SAVE_AS_FILENAME" ]]; then
|
||||||
|
# Load settings
|
||||||
UNSAVED_CHANGES=false
|
UNSAVED_CHANGES=false
|
||||||
SAVE_AS_FILENAME="gentoo.conf"
|
source "$SAVE_AS_FILENAME"
|
||||||
|
else
|
||||||
|
# Default settings
|
||||||
|
UNSAVED_CHANGES=true
|
||||||
|
|
||||||
HOSTNAME="gentoo"
|
HOSTNAME="gentoo"
|
||||||
# TODO get from current system
|
# TODO get from current system
|
||||||
|
@ -38,6 +61,7 @@ ADDITIONAL_PACKAGES=("app-editors/neovim")
|
||||||
INSTALL_SSHD=true
|
INSTALL_SSHD=true
|
||||||
|
|
||||||
ROOT_SSH_AUTHORIZED_KEYS=""
|
ROOT_SSH_AUTHORIZED_KEYS=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -54,6 +78,7 @@ MENU_ITEMS=(
|
||||||
|
|
||||||
function HOSTNAME_tag() { echo "Hostname"; }
|
function HOSTNAME_tag() { echo "Hostname"; }
|
||||||
function HOSTNAME_label() { echo "($HOSTNAME)"; }
|
function HOSTNAME_label() { echo "($HOSTNAME)"; }
|
||||||
|
function HOSTNAME_help() { echo "Enter the desired system hostname here, be aware that when creating mdadm raid arrays, this value will be recorded in metadata block. If you change it later, you should also update the metadata."; }
|
||||||
function HOSTNAME_menu() {
|
function HOSTNAME_menu() {
|
||||||
local sel
|
local sel
|
||||||
sel="$(dialog --clear \
|
sel="$(dialog --clear \
|
||||||
|
@ -68,10 +93,14 @@ function HOSTNAME_menu() {
|
||||||
|
|
||||||
function TIMEZONE_tag() { echo "Timezone"; }
|
function TIMEZONE_tag() { echo "Timezone"; }
|
||||||
function TIMEZONE_label() { echo "($TIMEZONE)"; }
|
function TIMEZONE_label() { echo "($TIMEZONE)"; }
|
||||||
function TIMEZONE_help() { echo "ajajaejaejgj jagj etjghoajf iajgpiajroianer goinaeirogn oairg arga lnaorignap ojkjaprogj iarrgona og"; }
|
function TIMEZONE_help() { echo "The timezone for the new system."; }
|
||||||
|
function TIMEZONE_menu() {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
function KEYMAP_tag() { echo "Keymap"; }
|
function KEYMAP_tag() { echo "Keymap"; }
|
||||||
function KEYMAP_label() { echo "($KEYMAP)"; }
|
function KEYMAP_label() { echo "($KEYMAP)"; }
|
||||||
|
function KEYMAP_help() { echo "The default vconsole keymap for the system."; }
|
||||||
function KEYMAP_menu() {
|
function KEYMAP_menu() {
|
||||||
local items=()
|
local items=()
|
||||||
local map
|
local map
|
||||||
|
@ -97,12 +126,24 @@ function KEYMAP_menu() {
|
||||||
|
|
||||||
function LOCALE_tag() { echo "Locale"; }
|
function LOCALE_tag() { echo "Locale"; }
|
||||||
function LOCALE_label() { echo "($LOCALE)"; }
|
function LOCALE_label() { echo "($LOCALE)"; }
|
||||||
|
function LOCALE_help() { echo "The locale to set for the new system. Be careful, the available options deviate from the corresponding names in the list of locales which is used by locale-gen. For example the locale 'en_US.utf8' is called 'en_US.UTF-8' in /etc/locale.gen). Use the name as shown in `eselect locale` here."; }
|
||||||
|
function LOCALE_menu() {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
function INIT_SYSTEM_tag() { echo "Init system"; }
|
function INIT_SYSTEM_tag() { echo "Init system"; }
|
||||||
function INIT_SYSTEM_label() { echo "($INIT_SYSTEM)"; }
|
function INIT_SYSTEM_label() { echo "($INIT_SYSTEM)"; }
|
||||||
|
function INIT_SYSTEM_help() { echo ""; }
|
||||||
|
function INIT_SYSTEM_menu() {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
function KEYFILE_tag() { echo "Key file"; }
|
function KEYFILE_tag() { echo "Key file"; }
|
||||||
function KEYFILE_label() { echo "($KEYFILE)"; }
|
function KEYFILE_label() { echo "($KEYFILE)"; }
|
||||||
|
function KEYFILE_help() { echo ""; }
|
||||||
|
function KEYFILE_menu() {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -111,6 +152,58 @@ function KEYFILE_label() { echo "($KEYFILE)"; }
|
||||||
# $1: filename
|
# $1: filename
|
||||||
function save() {
|
function save() {
|
||||||
echo save to "$1"
|
echo save to "$1"
|
||||||
|
cat > "$1" <<EOF
|
||||||
|
# vim: set ft=sh ts=4 sw=4 sts=-1 noet:
|
||||||
|
# This file will be interpreted by /bin/bash.
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Disk configuration
|
||||||
|
|
||||||
|
create_btrfs_raid_layout swap=8GiB luks=true /dev/sdX
|
||||||
|
luks_getkeyfile() {
|
||||||
|
case "\$1" in
|
||||||
|
#'my_luks_partition') echo -n '/path/to/my_luks_partition_keyfile' ;;
|
||||||
|
*) echo -n "/path/to/luks-keyfile" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# System configuration
|
||||||
|
|
||||||
|
HOSTNAME=${HOSTNAME@Q}
|
||||||
|
TIMEZONE=${TIMEZONE@Q}
|
||||||
|
KEYMAP=${KEYMAP@Q}
|
||||||
|
KEYMAP_INITRAMFS=${KEYMAP_INITRAMFS@Q}
|
||||||
|
|
||||||
|
LOCALES=${LOCALES@Q}
|
||||||
|
LOCALE=${LOCALE@Q}
|
||||||
|
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Gentoo configuration
|
||||||
|
|
||||||
|
GENTOO_MIRROR="https://mirror.eu.oneandone.net/linux/distributions/gentoo/gentoo"
|
||||||
|
GENTOO_ARCH="amd64"
|
||||||
|
STAGE3_BASENAME="stage3-$GENTOO_ARCH-systemd"
|
||||||
|
SELECT_MIRRORS=true
|
||||||
|
SELECT_MIRRORS_LARGE_FILE=false
|
||||||
|
SYSTEMD=true
|
||||||
|
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Additional (optional) configuration
|
||||||
|
|
||||||
|
ADDITIONAL_PACKAGES=("app-editors/neovim")
|
||||||
|
INSTALL_SSHD=true
|
||||||
|
ROOT_SSH_AUTHORIZED_KEYS=""
|
||||||
|
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# Prove that you have read the config
|
||||||
|
|
||||||
|
I_HAVE_READ_AND_EDITED_THE_CONFIG_PROPERLY=true
|
||||||
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
function msgbox_help() {
|
function msgbox_help() {
|
||||||
|
@ -184,8 +277,8 @@ function menu() {
|
||||||
--extra-button --extra-label "Exit" \
|
--extra-button --extra-label "Exit" \
|
||||||
--help-button \
|
--help-button \
|
||||||
--ok-label "Select" --cancel-label "Save" \
|
--ok-label "Select" --cancel-label "Save" \
|
||||||
--menu "Main config menu" \
|
--menu "This is the gentoo configuration menu. Read and adjust all options below carefully. Save your desired configuration and run ./install afterwards. Use the help if you want further information for any item." \
|
||||||
16 72 8 "${tag_item_list[@]}" 3>&2 2>&1 1>&3 3>&-)"
|
20 72 12 "${tag_item_list[@]}" 3>&2 2>&1 1>&3 3>&-)"
|
||||||
|
|
||||||
local diag_exit="$?"
|
local diag_exit="$?"
|
||||||
if [[ $diag_exit == 0 ]]; then
|
if [[ $diag_exit == 0 ]]; then
|
||||||
|
@ -204,6 +297,7 @@ function menu() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Begin menu loop. Exit will be called to end this loop where it is appropriate.
|
||||||
while true; do
|
while true; do
|
||||||
menu
|
menu
|
||||||
done
|
done
|
27
install
27
install
|
@ -1,11 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
# Initialize script environment
|
# Initialize script environment
|
||||||
|
|
||||||
# Find the directory this script is stored in. (from: http://stackoverflow.com/questions/59895)
|
# Find the directory this script is stored in. (from: http://stackoverflow.com/questions/59895)
|
||||||
get_source_dir() {
|
function get_source_dir() {
|
||||||
local source="${BASH_SOURCE[0]}"
|
local source="${BASH_SOURCE[0]}"
|
||||||
while [[ -h $source ]]
|
while [[ -h $source ]]
|
||||||
do
|
do
|
||||||
|
@ -44,14 +45,16 @@ while [[ $# -gt 0 ]]; do
|
||||||
""|"help"|"--help"|"-help"|"-h")
|
""|"help"|"--help"|"-help"|"-h")
|
||||||
echo "Usage: $0 [opts]... <action>"
|
echo "Usage: $0 [opts]... <action>"
|
||||||
echo "Performs a minimal gentoo installation. See https://github.com/oddlama/gentoo-install"
|
echo "Performs a minimal gentoo installation. See https://github.com/oddlama/gentoo-install"
|
||||||
echo "for more information."
|
echo "for more information. If the configuration file does not exist, the configurator will"
|
||||||
|
echo "be started instead."
|
||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -c, --config <CONFIG> Use the given configuration file instead of the default"
|
echo " -c, --config <CONFIG> Use the given configuration file instead of the default"
|
||||||
echo " location (gentoo.conf)"
|
echo " location (gentoo.conf). Applies to installation as well"
|
||||||
|
echo " as initial configuration in case it doesn't exist."
|
||||||
echo ""
|
echo ""
|
||||||
echo "Actions:"
|
echo "Actions:"
|
||||||
echo " -i, --install Installs gentoo as configured"
|
echo " -i, --install Installs gentoo as configured. (default if configuration exists)"
|
||||||
echo " -R, --chroot Chroot into an existing system. The root filesystem"
|
echo " -R, --chroot Chroot into an existing system. The root filesystem"
|
||||||
echo " is mounted automatically based on the partition"
|
echo " is mounted automatically based on the partition"
|
||||||
echo " UUIDs (generated when installing for the first time),"
|
echo " UUIDs (generated when installing for the first time),"
|
||||||
|
@ -86,10 +89,24 @@ while [[ $# -gt 0 ]]; do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
# Load config
|
# Check configuration location
|
||||||
[[ -z "${CONFIG%%$GENTOO_INSTALL_REPO_DIR*}" ]] \
|
[[ -z "${CONFIG%%$GENTOO_INSTALL_REPO_DIR*}" ]] \
|
||||||
|| die "Configuration file must be inside the installation directory. This is needed so it is accessible from within the chroot environment."
|
|| die "Configuration file must be inside the installation directory. This is needed so it is accessible from within the chroot environment."
|
||||||
|
|
||||||
|
if [[ -z "$ACTION" ]]; then
|
||||||
|
if [[ -e "$CONFIG" ]]; then
|
||||||
|
# Default if configuration exists: Run installer
|
||||||
|
ACTION="install"
|
||||||
|
else
|
||||||
|
# Default if configuration does not exists: Run configurator, and exit afterwards.
|
||||||
|
exec "$GENTOO_INSTALL_REPO_DIR/configure" "$CONFIG"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Load config
|
||||||
|
[[ -e "$CONFIG" ]] \
|
||||||
|
|| die "Configuration file '$CONFIG' does not exist. To run the configurator, omit '-i' or "
|
||||||
|
|
||||||
source "$CONFIG"
|
source "$CONFIG"
|
||||||
[[ $I_HAVE_READ_AND_EDITED_THE_CONFIG_PROPERLY == "true" ]] \
|
[[ $I_HAVE_READ_AND_EDITED_THE_CONFIG_PROPERLY == "true" ]] \
|
||||||
|| die "You have not properly read the config. Edit the config file and set I_HAVE_READ_AND_EDITED_THE_CONFIG_PROPERLY=true to continue."
|
|| die "You have not properly read the config. Edit the config file and set I_HAVE_READ_AND_EDITED_THE_CONFIG_PROPERLY=true to continue."
|
||||||
|
|
Loading…
Reference in New Issue