mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-20 03:50:37 +02:00
shellcheck fixes
This commit is contained in:
parent
4c6a5ff756
commit
04c347cdf0
2 changed files with 111 additions and 111 deletions
|
@ -69,7 +69,7 @@ _set_vconsole() {
|
||||||
fi
|
fi
|
||||||
_abort_dialog || return 1
|
_abort_dialog || return 1
|
||||||
_KEYMAPS=""
|
_KEYMAPS=""
|
||||||
for i in $(${LIST_MAPS} | grep "^${_KEYMAP}" | grep -v '^carpalx' | grep -v 'defkey' | grep -v 'mac' | grep -v 'amiga' | grep -v 'sun' | grep -v 'atari'); do
|
for i in $(${_LIST_MAPS} | grep "^${_KEYMAP}" | grep -v '^carpalx' | grep -v 'defkey' | grep -v 'mac' | grep -v 'amiga' | grep -v 'sun' | grep -v 'atari'); do
|
||||||
_KEYMAPS="${_KEYMAPS} ${i} -"
|
_KEYMAPS="${_KEYMAPS} ${i} -"
|
||||||
done
|
done
|
||||||
_CANCEL=""
|
_CANCEL=""
|
||||||
|
@ -82,7 +82,7 @@ _set_vconsole() {
|
||||||
_S_NEXTITEM=2
|
_S_NEXTITEM=2
|
||||||
}
|
}
|
||||||
|
|
||||||
mainmenu() {
|
_mainmenu() {
|
||||||
if [[ -n "${_S_NEXTITEM}" ]]; then
|
if [[ -n "${_S_NEXTITEM}" ]]; then
|
||||||
_DEFAULT="--default-item ${_S_NEXTITEM}"
|
_DEFAULT="--default-item ${_S_NEXTITEM}"
|
||||||
else
|
else
|
||||||
|
|
|
@ -9,7 +9,17 @@ else
|
||||||
_EXIT="Exit"
|
_EXIT="Exit"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
abort()
|
# _dialog()
|
||||||
|
# an el-cheapo dialog wrapper
|
||||||
|
#
|
||||||
|
# parameters: see dialog(1)
|
||||||
|
# returns: whatever dialog did
|
||||||
|
_dialog() {
|
||||||
|
dialog --backtitle "${_TITLE}" --aspect 15 "$@"
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
_abort()
|
||||||
{
|
{
|
||||||
_dialog --yesno "Abort Time And Date Setting?" 6 40 || return 0
|
_dialog --yesno "Abort Time And Date Setting?" 6 40 || return 0
|
||||||
[[ -e /tmp/.timezone ]] && rm -f /tmp/.timezone
|
[[ -e /tmp/.timezone ]] && rm -f /tmp/.timezone
|
||||||
|
@ -22,142 +32,132 @@ abort()
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# _dialog()
|
_dohwclock() {
|
||||||
# an el-cheapo dialog wrapper
|
echo "0.0 0 0.0" > /etc/adjtime
|
||||||
#
|
echo "0" >> /etc/adjtime
|
||||||
# parameters: see dialog(1)
|
[[ "${_HARDWARECLOCK}" = "UTC" ]] && echo UTC >> /etc/adjtime
|
||||||
# returns: whatever dialog did
|
[[ "${_HARDWARECLOCK}" = "" ]] && echo LOCAL >> /etc/adjtime
|
||||||
_dialog() {
|
if [[ "${_HARDWARECLOCK}" = "UTC" ]]; then
|
||||||
dialog --backtitle "${_TITLE}" --aspect 15 "$@"
|
timedatectl set-local-rtc 0
|
||||||
return $?
|
_DATE_PROGRAM=timedatectl
|
||||||
}
|
# for setup script
|
||||||
|
echo UTC > /tmp/.hardwareclock
|
||||||
dohwclock() {
|
|
||||||
echo "0.0 0 0.0" > /etc/adjtime
|
|
||||||
echo "0" >> /etc/adjtime
|
|
||||||
[[ "${_HARDWARECLOCK}" = "UTC" ]] && echo UTC >> /etc/adjtime
|
|
||||||
[[ "${_HARDWARECLOCK}" = "" ]] && echo LOCAL >> /etc/adjtime
|
|
||||||
if [[ "${_HARDWARECLOCK}" = "UTC" ]]; then
|
|
||||||
timedatectl set-local-rtc 0
|
|
||||||
DATE_PROGRAM=timedatectl
|
|
||||||
# for setup script
|
|
||||||
echo UTC > /tmp/.hardwareclock
|
|
||||||
else
|
|
||||||
timedatectl set-local-rtc 1
|
|
||||||
#shellcheck disable=SC2209
|
|
||||||
DATE_PROGRAM=date
|
|
||||||
# for setup script
|
|
||||||
echo LOCAL > /tmp/.hardwareclock
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
dotimezone () {
|
|
||||||
_SET_ZONE=""
|
|
||||||
while ! [[ "${_SET_ZONE}" = "1" ]]; do
|
|
||||||
_REGIONS="America - Europe - Africa - Asia - Australia -"
|
|
||||||
#shellcheck disable=SC2086
|
|
||||||
_dialog --menu "Please Select A Region:" 12 40 7 ${_REGIONS} 2>${_ANSWER}
|
|
||||||
_REGION=$(cat ${_ANSWER})
|
|
||||||
_ZONES=""
|
|
||||||
for i in $(timedatectl --no-pager list-timezones | grep -w "${_REGION}" | cut -d '/' -f 2 | sort -u); do
|
|
||||||
_ZONES="${_ZONES} ${i} -"
|
|
||||||
done
|
|
||||||
#shellcheck disable=SC2086
|
|
||||||
_dialog --menu "Please Select A Timezone:" 22 40 16 ${_ZONES} 2>${_ANSWER} && _SET_ZONE="1"
|
|
||||||
_ZONE=$(cat ${_ANSWER})
|
|
||||||
[[ "${_ZONE}" == "${_REGION}" ]] || _ZONE="${_REGION}/${_ZONE}"
|
|
||||||
if [[ "${_SET_ZONE}" = "1" ]]; then
|
|
||||||
_dialog --infobox "Setting Timezone to ${_ZONE} ..." 0 0
|
|
||||||
echo "${_ZONE}" > /tmp/.timezone
|
|
||||||
timedatectl set-timezone "${_ZONE}"
|
|
||||||
_S_NEXTITEM="2"
|
|
||||||
else
|
else
|
||||||
_S_NEXTITEM="1"
|
timedatectl set-local-rtc 1
|
||||||
return 1
|
#shellcheck disable=SC2209
|
||||||
|
_DATE_PROGRAM=date
|
||||||
|
# for setup script
|
||||||
|
echo LOCAL > /tmp/.hardwareclock
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dotimeset() {
|
_dotimezone () {
|
||||||
if [[ ! -s /tmp/.timezone ]]; then
|
_SET_ZONE=""
|
||||||
_dialog --msgbox "Error:\nYou have to select timezone first." 0 0
|
while ! [[ "${_SET_ZONE}" = "1" ]]; do
|
||||||
_S_NEXTITEM="1"
|
_REGIONS="America - Europe - Africa - Asia - Australia -"
|
||||||
dotimezone || return 1
|
#shellcheck disable=SC2086
|
||||||
fi
|
_dialog --menu "Please Select A Region:" 12 40 7 ${_REGIONS} 2>${_ANSWER}
|
||||||
_SET_TIME=""
|
_REGION=$(cat ${_ANSWER})
|
||||||
while [[ "${_SET_TIME}" == "" ]]; do
|
_ZONES=""
|
||||||
_HARDWARECLOCK=""
|
for i in $(timedatectl --no-pager list-timezones | grep -w "${_REGION}" | cut -d '/' -f 2 | sort -u); do
|
||||||
DATE_PROGRAM=""
|
_ZONES="${_ZONES} ${i} -"
|
||||||
_dialog --yesno "Do you want to use UTC for your clock?\n\nIf you choose 'YES' UTC (recommended default) is used,\nwhich ensures daylightsaving is set automatically.\n\nIf you choose 'NO' Localtime is used, which means\nthe system will not change the time automatically.\nLocaltime is also prefered on dualboot machines,\nwhich also run Windows, because UTC may confuse it." 14 60 && _HARDWARECLOCK="UTC"
|
done
|
||||||
dohwclock
|
#shellcheck disable=SC2086
|
||||||
# check internet connection
|
_dialog --menu "Please Select A Timezone:" 22 40 16 ${_ZONES} 2>${_ANSWER} && _SET_ZONE="1"
|
||||||
if ping -c1 www.google.com >/dev/null 2>&1; then
|
_ZONE=$(cat ${_ANSWER})
|
||||||
if _dialog --yesno \
|
[[ "${_ZONE}" == "${_REGION}" ]] || _ZONE="${_REGION}/${_ZONE}"
|
||||||
"Do you want to use the Network Time Protocol (NTP) for syncing your clock, by using the internet clock pool?" 6 60; then
|
if [[ "${_SET_ZONE}" = "1" ]]; then
|
||||||
_dialog --infobox "Syncing clock with NTP pool ..." 3 45
|
_dialog --infobox "Setting Timezone to ${_ZONE} ..." 0 0
|
||||||
# sync immediatly with standard pool
|
echo "${_ZONE}" > /tmp/.timezone
|
||||||
if ! systemctl restart systemd-timesyncd; then
|
timedatectl set-timezone "${_ZONE}"
|
||||||
_dialog --msgbox "An error has occured, time was not changed!" 0 0
|
_S_NEXTITEM="2"
|
||||||
|
else
|
||||||
|
_S_NEXTITEM="1"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
_dotimeset() {
|
||||||
|
if [[ ! -s /tmp/.timezone ]]; then
|
||||||
|
_dialog --msgbox "Error:\nYou have to select timezone first." 0 0
|
||||||
|
_S_NEXTITEM="1"
|
||||||
|
dotimezone || return 1
|
||||||
|
fi
|
||||||
|
_SET_TIME=""
|
||||||
|
while [[ -z "${_SET_TIME}" ]]; do
|
||||||
|
_HARDWARECLOCK=""
|
||||||
|
_DATE_PROGRAM=""
|
||||||
|
_dialog --yesno "Do you want to use UTC for your clock?\n\nIf you choose 'YES' UTC (recommended default) is used,\nwhich ensures daylightsaving is set automatically.\n\nIf you choose 'NO' Localtime is used, which means\nthe system will not change the time automatically.\nLocaltime is also prefered on dualboot machines,\nwhich also run Windows, because UTC may confuse it." 14 60 && _HARDWARECLOCK="UTC"
|
||||||
|
_dohwclock
|
||||||
|
# check internet connection
|
||||||
|
if ping -c1 www.google.com >/dev/null 2>&1; then
|
||||||
|
if _dialog --yesno \
|
||||||
|
"Do you want to use the Network Time Protocol (NTP) for syncing your clock, by using the internet clock pool?" 6 60; then
|
||||||
|
_dialog --infobox "Syncing clock with NTP pool ..." 3 45
|
||||||
|
# sync immediatly with standard pool
|
||||||
|
if ! systemctl restart systemd-timesyncd; then
|
||||||
|
_dialog --msgbox "An error has occured, time was not changed!" 0 0
|
||||||
|
_S_NEXTITEM="2"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# enable background syncing
|
||||||
|
timedatectl set-ntp 1
|
||||||
|
_SET_TIME="1"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ "${_SET_TIME}" == "" ]]; then
|
||||||
|
timedatectl set-ntp 0
|
||||||
|
# display and ask to set date/time
|
||||||
|
_CANCEL=""
|
||||||
|
dialog --calendar "Set the date.\nUse <TAB> to navigate and arrow keys to change values." 0 0 0 0 0 2> ${_ANSWER} || _CANCEL="1"
|
||||||
|
if [[ "${_CANCEL}" = "1" ]]; then
|
||||||
_S_NEXTITEM="2"
|
_S_NEXTITEM="2"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# enable background syncing
|
_DATE="$(cat ${_ANSWER})"
|
||||||
timedatectl set-ntp 1
|
dialog --timebox "Set the time.\nUse <TAB> to navigate and up/down to change values." 0 0 2> ${_ANSWER} || _CANCEL="1"
|
||||||
|
if [[ "${_CANCEL}" = "1" ]]; then
|
||||||
|
_S_NEXTITEM="2"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
_TIME="$(cat ${_ANSWER})"
|
||||||
|
# save the time
|
||||||
|
# DD/MM/YYYY hh:mm:ss -> YYYY-MM-DD hh:mm:ss
|
||||||
|
_DATETIME="$(echo "${_DATE}" "${_TIME}" | sed 's#\(..\)/\(..\)/\(....\) \(..\):\(..\):\(..\)#\3-\2-\1 \4:\5:\6#g')"
|
||||||
|
timedatectl set-time "${_DATETIME}"
|
||||||
_SET_TIME="1"
|
_SET_TIME="1"
|
||||||
fi
|
fi
|
||||||
fi
|
_dialog --cr-wrap --defaultno --yesno "Your current time and date is:\n$(${_DATE_PROGRAM})\n\nDo you want to change it?" 0 0 && _SET_TIME=""
|
||||||
if [[ "${_SET_TIME}" == "" ]]; then
|
done
|
||||||
timedatectl set-ntp 0
|
_S_NEXTITEM="3"
|
||||||
# display and ask to set date/time
|
|
||||||
_CANCEL=""
|
|
||||||
dialog --calendar "Set the date.\nUse <TAB> to navigate and arrow keys to change values." 0 0 0 0 0 2> ${_ANSWER} || _CANCEL="1"
|
|
||||||
if [[ "${_CANCEL}" = "1" ]]; then
|
|
||||||
_S_NEXTITEM="2"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_DATE="$(cat ${_ANSWER})"
|
|
||||||
dialog --timebox "Set the time.\nUse <TAB> to navigate and up/down to change values." 0 0 2> ${_ANSWER} || _CANCEL="1"
|
|
||||||
if [[ "${_CANCEL}" = "1" ]]; then
|
|
||||||
_S_NEXTITEM="2"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_TIME="$(cat ${_ANSWER})"
|
|
||||||
# save the time
|
|
||||||
# DD/MM/YYYY hh:mm:ss -> YYYY-MM-DD hh:mm:ss
|
|
||||||
_DATETIME="$(echo "${_DATE}" "${_TIME}" | sed 's#\(..\)/\(..\)/\(....\) \(..\):\(..\):\(..\)#\3-\2-\1 \4:\5:\6#g')"
|
|
||||||
timedatectl set-time "${_DATETIME}"
|
|
||||||
_SET_TIME="1"
|
|
||||||
fi
|
|
||||||
_dialog --cr-wrap --defaultno --yesno "Your current time and date is:\n$(${DATE_PROGRAM})\n\nDo you want to change it?" 0 0 && _SET_TIME=""
|
|
||||||
done
|
|
||||||
_S_NEXTITEM="3"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mainmenu() {
|
_mainmenu() {
|
||||||
if [[ -n "${_S_NEXTITEM}" ]]; then
|
if [[ -n "${_S_NEXTITEM}" ]]; then
|
||||||
DEFAULT="--default-item ${_S_NEXTITEM}"
|
_DEFAULT="--default-item ${_S_NEXTITEM}"
|
||||||
else
|
else
|
||||||
DEFAULT=""
|
_DEFAULT=""
|
||||||
fi
|
fi
|
||||||
#shellcheck disable=SC2086
|
#shellcheck disable=SC2086
|
||||||
_dialog ${DEFAULT} --backtitle "${_TITLE}" --title " MAIN MENU " \
|
_dialog ${_DEFAULT} --backtitle "${_TITLE}" --title " MAIN MENU " \
|
||||||
--menu "Use the UP and DOWN arrows to navigate menus.\nUse TAB to switch between buttons and ENTER to select." 11 58 13 \
|
--menu "Use the UP and DOWN arrows to navigate menus.\nUse TAB to switch between buttons and ENTER to select." 11 58 13 \
|
||||||
"1" "Select Timezone" \
|
"1" "Select Timezone" \
|
||||||
"2" "Set Time and Date" \
|
"2" "Set Time and Date" \
|
||||||
"3" "${_EXIT}" 2>${_ANSWER}
|
"3" "${_EXIT}" 2>${_ANSWER}
|
||||||
case $(cat ${_ANSWER}) in
|
case $(cat ${_ANSWER}) in
|
||||||
"1")
|
"1")
|
||||||
dotimezone
|
_dotimezone
|
||||||
;;
|
;;
|
||||||
"2")
|
"2")
|
||||||
dotimeset
|
_dotimeset
|
||||||
;;
|
;;
|
||||||
"3")
|
"3")
|
||||||
[[ -e /tmp/.tz-running ]] && rm /tmp/.tz-running
|
[[ -e /tmp/.tz-running ]] && rm /tmp/.tz-running
|
||||||
clear
|
clear
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
*)
|
*)
|
||||||
abort ;;
|
_abort ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ fi
|
||||||
: >/tmp/.tz-running
|
: >/tmp/.tz-running
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
mainmenu
|
_mainmenu
|
||||||
done
|
done
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
Loading…
Reference in a new issue