mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-19 19:40:37 +02:00
code cleanup, created basic-common.sh, renamed TITLES to Basic Setup
This commit is contained in:
parent
c462ef306e
commit
74f6413ebc
8 changed files with 72 additions and 180 deletions
|
@ -18,6 +18,7 @@ Environment Changes:
|
|||
- renamed km to vconsole
|
||||
- renamed tz to clock
|
||||
- renamed archboot-locale script to localize
|
||||
- load archboot.com and wiki.archlinux.org on firefox startup
|
||||
localize:
|
||||
- fixed abort dialog
|
||||
update:
|
||||
|
|
|
@ -1,30 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# written by Tobias Powalowski <tpowa@archlinux.org>
|
||||
LANG=C
|
||||
_ANSWER="/tmp/.clock"
|
||||
_RUNNING_ARCH="$(uname -m)"
|
||||
_TITLE="Archboot ${_RUNNING_ARCH} | Arch Linux Setup | Clock Configuration"
|
||||
# _dialog()
|
||||
# an el-cheapo dialog wrapper
|
||||
#
|
||||
# parameters: see dialog(1)
|
||||
# returns: whatever dialog did
|
||||
_dialog() {
|
||||
dialog --backtitle "${_TITLE}" --aspect 15 "$@"
|
||||
return $?
|
||||
}
|
||||
|
||||
_abort() {
|
||||
if _dialog --yesno "Abort Arch Linux Clock Configuration?" 5 45; then
|
||||
[[ -e /tmp/.clock-running ]] && rm /tmp/.clock-running
|
||||
[[ -e /tmp/.clock ]] && rm /tmp/.clock
|
||||
clear
|
||||
exit 1
|
||||
else
|
||||
_CONTINUE=""
|
||||
fi
|
||||
}
|
||||
_TITLE="Archboot ${_RUNNING_ARCH} | Basic Setup | Clock Configuration"
|
||||
. /usr/lib/archboot/basic-common.sh
|
||||
|
||||
_hwclock() {
|
||||
_DATE_PROGRAM=timedatectl
|
||||
|
@ -106,23 +84,11 @@ _timeset() {
|
|||
fi
|
||||
}
|
||||
|
||||
if [[ -e /tmp/.clock-running ]]; then
|
||||
echo "clock already runs on a different console!"
|
||||
echo "Please remove /tmp/.clock-running first to launch clock!"
|
||||
exit 1
|
||||
fi
|
||||
: >/tmp/.clock-running
|
||||
_check
|
||||
_SET_TIME=""
|
||||
if [[ -n "${1}" ]]; then
|
||||
_LABEL="Back"
|
||||
else
|
||||
_LABEL="Exit"
|
||||
fi
|
||||
while [[ -z "${_SET_TIME}" ]]; do
|
||||
_timezone
|
||||
_timeset
|
||||
done
|
||||
[[ -e /tmp/.clock-running ]] && rm /tmp/.clock-running
|
||||
clear
|
||||
exit 0
|
||||
_cleanup
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
|
|
@ -1,19 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# written by Tobias Powalowski <tpowa@archlinux.org>
|
||||
LANG=C
|
||||
_ANSWER="/tmp/.launcher"
|
||||
_RUNNING_ARCH="$(uname -m)"
|
||||
_TITLE="Archboot ${_RUNNING_ARCH} | Arch Linux Setup | Launcher"
|
||||
# _dialog()
|
||||
# an el-cheapo dialog wrapper
|
||||
#
|
||||
# parameters: see dialog(1)
|
||||
# returns: whatever dialog did
|
||||
_dialog() {
|
||||
dialog --backtitle "${_TITLE}" --aspect 15 "$@"
|
||||
return $?
|
||||
}
|
||||
_TITLE="Archboot ${_RUNNING_ARCH} | Basic Setup | Launcher"
|
||||
. /usr/lib/archboot/basic-common.sh
|
||||
|
||||
_show_login() {
|
||||
[[ -e /tmp/.launcher-running ]] && rm /tmp/.launcher-running
|
||||
|
@ -96,6 +85,7 @@ _exit() {
|
|||
"3" "Poweroff System" 2>${_ANSWER} || return 1
|
||||
_EXIT="$(cat ${_ANSWER})"
|
||||
if [[ "${_EXIT}" == "1" ]]; then
|
||||
[[ -e /tmp/.launcher-running ]] && rm /tmp/.launcher-running
|
||||
_show_login
|
||||
exit 0
|
||||
elif [[ "${_EXIT}" == "2" ]]; then
|
||||
|
@ -138,13 +128,7 @@ _launcher() {
|
|||
esac
|
||||
}
|
||||
|
||||
if [[ -e /tmp/.launcher-running ]]; then
|
||||
echo "launcher already runs on a different console!"
|
||||
echo "Please remove /tmp/.launcher-running first to launch launcher!"
|
||||
exit 1
|
||||
fi
|
||||
: >/tmp/.launcher
|
||||
: >/tmp/.launcher-running
|
||||
_check
|
||||
while true; do
|
||||
_check_desktop
|
||||
_check_manage
|
||||
|
|
|
@ -1,32 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# written by Tobias Powalowski <tpowa@archlinux.org>
|
||||
LANG=C
|
||||
_ANSWER="/tmp/.network"
|
||||
_RUNNING_ARCH="$(uname -m)"
|
||||
_TITLE="Archboot ${_RUNNING_ARCH} | Arch Linux Setup | Network Configuration"
|
||||
_LOG="/dev/tty7"
|
||||
_NO_LOG="/dev/null"
|
||||
# _dialog()
|
||||
# an el-cheapo dialog wrapper
|
||||
#
|
||||
# parameters: see dialog(1)
|
||||
# returns: whatever dialog did
|
||||
_dialog() {
|
||||
dialog --backtitle "${_TITLE}" --aspect 15 "$@"
|
||||
return $?
|
||||
}
|
||||
|
||||
_abort() {
|
||||
if _dialog --yesno "Abort Arch Linux Network Configuration?" 5 45; then
|
||||
[[ -e /tmp/.network-running ]] && rm /tmp/.network-running
|
||||
[[ -e /tmp/.network ]] && rm /tmp/.network
|
||||
clear
|
||||
exit 1
|
||||
else
|
||||
_CONTINUE=""
|
||||
fi
|
||||
}
|
||||
_TITLE="Archboot ${_RUNNING_ARCH} | Basic Setup | Network Configuration"
|
||||
. /usr/lib/archboot/basic-common.sh
|
||||
|
||||
_printk()
|
||||
{
|
||||
|
@ -222,22 +198,9 @@ _network() {
|
|||
return 0
|
||||
}
|
||||
|
||||
if [[ -e /tmp/.network-running ]]; then
|
||||
clear
|
||||
echo "network already runs on a different console!"
|
||||
echo "Please remove /tmp/.network-running first to launch network!"
|
||||
exit 1
|
||||
fi
|
||||
: >/tmp/.network-running
|
||||
if [[ -n "${1}" ]]; then
|
||||
_LABEL="Back"
|
||||
else
|
||||
_LABEL="Exit"
|
||||
fi
|
||||
_check
|
||||
while true; do
|
||||
_network && break
|
||||
done
|
||||
[[ -e /tmp/.network-running ]] && rm /tmp/.network-running
|
||||
clear
|
||||
exit 0
|
||||
_cleanup
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
||||
|
|
|
@ -1,31 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# written by Tobias Powalowski <tpowa@archlinux.org>
|
||||
LANG=C
|
||||
_ANSWER="/tmp/.vconsole"
|
||||
_RUNNING_ARCH="$(uname -m)"
|
||||
_TITLE="Archboot ${_RUNNING_ARCH} | Arch Linux Setup | Vconsole Configuration"
|
||||
. /usr/lib/archboot/basic-common.sh
|
||||
_TITLE="Archboot ${_RUNNING_ARCH} | Basic Setup | Vconsole Configuration"
|
||||
_LIST_MAPS="localectl list-keymaps --no-pager"
|
||||
# _dialog()
|
||||
# an el-cheapo dialog wrapper
|
||||
#
|
||||
# parameters: see dialog(1)
|
||||
# returns: whatever dialog did
|
||||
_dialog() {
|
||||
dialog --backtitle "${_TITLE}" --aspect 15 "$@"
|
||||
return $?
|
||||
}
|
||||
|
||||
_abort() {
|
||||
if _dialog --yesno "Abort Arch Linux Vconsole Configuration?" 5 45; then
|
||||
[[ -e /tmp/.vconsole-running ]] && rm /tmp/.vconsole-running
|
||||
[[ -e /tmp/.vconsole ]] && rm /tmp/.vconsole
|
||||
clear
|
||||
exit 1
|
||||
else
|
||||
_CONTINUE=""
|
||||
fi
|
||||
}
|
||||
|
||||
_vconsole() {
|
||||
_dialog --infobox "Setting vconsole font ${_FONT} and keymap ${_KEYMAP}..." 3 80
|
||||
|
@ -35,6 +13,7 @@ _vconsole() {
|
|||
sleep 3
|
||||
_dialog --infobox "Vconsole configuration completed successfully." 3 50
|
||||
sleep 3
|
||||
return 0
|
||||
}
|
||||
|
||||
_vconsole_font() {
|
||||
|
@ -95,21 +74,11 @@ _vconsole_keymap() {
|
|||
done
|
||||
}
|
||||
|
||||
if [[ -e /tmp/.vconsole-running ]]; then
|
||||
echo "vconsole already runs on a different vconsole!"
|
||||
echo "Please remove /tmp/.vconsole-running first to launch vconsole!"
|
||||
exit 1
|
||||
fi
|
||||
: >/tmp/.vconsole-running
|
||||
if [[ -n "${1}" ]]; then
|
||||
_LABEL="Back"
|
||||
else
|
||||
_LABEL="Exit"
|
||||
fi
|
||||
_vconsole_font
|
||||
_vconsole_keymap
|
||||
[[ -e /tmp/.vconsole-running ]] && rm /tmp/.vconsole-running
|
||||
_vconsole
|
||||
clear
|
||||
exit 0
|
||||
_check
|
||||
while true; dp
|
||||
_vconsole_font
|
||||
_vconsole_keymap
|
||||
_vconsole && break
|
||||
done
|
||||
_cleanup
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
|
48
usr/lib/archboot/basic-common.sh
Normal file
48
usr/lib/archboot/basic-common.sh
Normal file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# created by Tobias Powalowski <tpowa@archlinux.org>
|
||||
LANG=C
|
||||
_ANSWER="/tmp/.${0}"
|
||||
_RUNNING_ARCH="$(uname -m)"
|
||||
_LOG="/dev/tty7"
|
||||
_NO_LOG="/dev/null"
|
||||
_DLPROG="wget -q"
|
||||
_MIRRORLIST="/etc/pacman.d/mirrorlist"
|
||||
|
||||
# _dialog()
|
||||
# an el-cheapo dialog wrapper
|
||||
#
|
||||
# parameters: see dialog(1)
|
||||
# returns: whatever dialog did
|
||||
_dialog() {
|
||||
dialog --backtitle "${_TITLE}" --aspect 15 "$@"
|
||||
return $?
|
||||
}
|
||||
|
||||
_abort() {
|
||||
if _dialog --yesno "Abort$(echo ${_TITLE} | cut -d '|' -f3) ?" 5 45; then
|
||||
[[ -e "${_ANSWER}-running" ]] && rm "${_ANSWER}-running"
|
||||
[[ -e "${_ANSWER}" ]] && ${_ANSWER}
|
||||
clear
|
||||
exit 1
|
||||
else
|
||||
_CONTINUE=""
|
||||
fi
|
||||
}
|
||||
|
||||
_check() {
|
||||
if [[ -e "${_ANSWER}-running" ]]; then
|
||||
clear
|
||||
echo "${0} already runs on a different console!"
|
||||
echo "Please remove ${_ANSWER}-running first to launch ${0}!"
|
||||
exit 1
|
||||
fi
|
||||
: >"${_ANSWER}"
|
||||
: >"${_ANSWER}-running"
|
||||
}
|
||||
|
||||
_cleanup() {
|
||||
[[ -e "${_ANSWER}-running" ]] && rm "${_ANSWER}-running"
|
||||
clear
|
||||
exit 0
|
||||
}
|
|
@ -4,50 +4,11 @@
|
|||
_getsource() {
|
||||
_PACMAN_CONF=""
|
||||
if [[ -e "${_LOCAL_DB}" ]]; then
|
||||
_NEXTITEM="4"
|
||||
_local_pacman_conf
|
||||
else
|
||||
_select_mirror || return 1
|
||||
fi
|
||||
_S_SRC=1
|
||||
}
|
||||
|
||||
_select_mirror() {
|
||||
_NEXTITEM="3"
|
||||
## Download updated mirrorlist, if possible (only on x86_64)
|
||||
if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then
|
||||
_dialog --infobox "Downloading latest mirrorlist..." 3 40
|
||||
${_DLPROG} "https://www.archlinux.org/mirrorlist/?country=all&protocol=http&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on" -O /tmp/pacman_mirrorlist.txt
|
||||
if grep -q '#Server = http:' /tmp/pacman_mirrorlist.txt; then
|
||||
mv "${_MIRRORLIST}" "${_MIRRORLIST}.bak"
|
||||
cp /tmp/pacman_mirrorlist.txt "${_MIRRORLIST}"
|
||||
fi
|
||||
fi
|
||||
# FIXME: this regex doesn't honor commenting
|
||||
_MIRRORS=$(grep -E -o '((http)|(https))://[^/]*' "${_MIRRORLIST}" | sed 's|$| _|g')
|
||||
#shellcheck disable=SC2086
|
||||
_dialog --title " Pacman Package Mirror " --menu "" 13 55 7 \
|
||||
${_MIRRORS} \
|
||||
"Custom" "_" 2>${_ANSWER} || return 1
|
||||
#shellcheck disable=SC2155
|
||||
local _SERVER=$(cat "${_ANSWER}")
|
||||
if [[ "${_SERVER}" == "Custom" ]]; then
|
||||
_dialog --inputbox "Enter the full URL to repositories." 8 65 \
|
||||
"" 2>"${_ANSWER}" || return 1
|
||||
_SYNC_URL=$(cat "${_ANSWER}")
|
||||
else
|
||||
# Form the full URL for our mirror by grepping for the server name in
|
||||
# our mirrorlist and pulling the full URL out. Substitute 'core' in
|
||||
# for the repository name, and ensure that if it was listed twice we
|
||||
# only return one line for the mirror.
|
||||
_SYNC_URL=$(grep -E -o "${_SERVER}.*" "${_MIRRORLIST}" | head -n1)
|
||||
fi
|
||||
_NEXTITEM="4"
|
||||
echo "Using mirror: ${_SYNC_URL}" >"${_LOG}"
|
||||
#shellcheck disable=SC2027,SC2086
|
||||
echo "Server = "${_SYNC_URL}"" >> /etc/pacman.d/mirrorlist
|
||||
}
|
||||
|
||||
_enable_testing() {
|
||||
if ! grep -q "^\[.*testing\]" /etc/pacman.conf; then
|
||||
_DOTESTING=""
|
||||
|
|
|
@ -116,7 +116,7 @@ _download_latest() {
|
|||
done
|
||||
# main libs
|
||||
echo -e "\e[1mStep 3/4:\e[m Downloading latest script libs..."
|
||||
LIBS="common.sh container.sh release.sh iso.sh login.sh cpio.sh"
|
||||
LIBS="basic-common.sh common.sh container.sh release.sh iso.sh login.sh cpio.sh"
|
||||
for i in ${LIBS}; do
|
||||
wget -q "${_SOURCE}${_LIB}/${i}?inline=false" -O "${_LIB}/${i}"
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue