Compare commits

...

19 commits

Author SHA1 Message Date
Tobias Powalowski
7d508b346d switch to external archboot-net in setup 2023-07-12 14:16:41 +02:00
Tobias Powalowski
3f0bac2c67 add NO_LOG 2023-07-12 12:38:56 +02:00
Tobias Powalowski
68a4ff9bc2 start at prepare storage in offline mode 2023-07-12 12:35:19 +02:00
Tobias Powalowski
f0d7557e05 rename functions 2023-07-12 12:33:00 +02:00
Tobias Powalowski
b80af07ac2 add archboot-net.sh 2023-07-12 12:17:36 +02:00
Tobias Powalowski
94bf840103 change menu order 2023-07-12 12:07:58 +02:00
Tobias Powalowski
20ac5347c3 run basic setup on first login 2023-07-12 12:00:52 +02:00
Tobias Powalowski
1e862556c7 run basic setup on first login 2023-07-12 12:00:11 +02:00
Tobias Powalowski
09513518c3 start at select source in setup 2023-07-12 11:57:46 +02:00
Tobias Powalowski
710bca62f1 start at select source in setup 2023-07-12 11:56:00 +02:00
Tobias Powalowski
ce70d1b0d3 run basic setup on first login 2023-07-12 11:39:43 +02:00
Tobias Powalowski
c1f6040d69 run basic setup on first login 2023-07-12 11:32:52 +02:00
Tobias Powalowski
76c0cf8fe6 run basic setup on first login 2023-07-12 11:27:02 +02:00
Tobias Powalowski
3eb2d6a44b sync height of bemenu with waybar 2023-07-12 09:11:38 +02:00
Tobias Powalowski
7f64eb03e6 fix waybar check 2023-07-12 08:45:41 +02:00
Tobias Powalowski
8eb09a4fdf extend check 2023-07-12 08:19:03 +02:00
Tobias Powalowski
fbc3a393e5 fix hiding sway-bar 2023-07-12 08:15:37 +02:00
Tobias Powalowski
fe91b246b9 update CHANGELOG 2023-07-12 08:12:12 +02:00
Tobias Powalowski
9827221a9c replace sway-bar with waybar in sway 2023-07-12 08:04:42 +02:00
7 changed files with 277 additions and 29 deletions

View file

@ -21,7 +21,7 @@ _GNOME_PACKAGES="gnome-desktop-4 gnome-shell gnome-terminal gnome-control-center
_PLASMA_PACKAGES="plasma-wayland-session plasma-desktop konsole kscreen kate dolphin powerdevil ark gwenview"
### SWAY defaults
# Sway packages
_SWAY_PACKAGES="sway swaybg foot bemenu-wayland j4-dmenu-desktop wayvnc"
_SWAY_PACKAGES="sway swaybg foot bemenu-wayland j4-dmenu-desktop wayvnc waybar ttf-font-awesome"
### XFCE defaults
# Xfce packages
_XFCE_PACKAGES="xfce4 breeze-icons gvfs-smb thunar-archive-plugin file-roller gnome-keyring mousepad ristretto"

207
usr/bin/archboot-net.sh Normal file
View file

@ -0,0 +1,207 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0-only
# created by Tobias Powalowski <tpowa@archlinux.org>
_ANSWER="/tmp/.net"
_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 $?
}
_net_interfaces() {
find /sys/class/net/* -type l ! -name 'lo' -printf '%f ' -exec cat {}/address \;
}
_essid_scan() {
# scan the area
iwctl station "${_INTERFACE}" scan
# only show lines with signal '*'
# kill spaces from the end and replace spaces with + between
# '+' character is one of 6 forbidden characters in SSID standard
for dev in $(iwctl station "${_INTERFACE}" get-networks | grep '\*' | cut -c 1-41 | sed -e 's|\ *.$||g' -e 's|^.*\ \ ||g' -e 's| |\+|g'); do
echo "${dev}"
[[ "${1}" ]] && echo "${1}"
done
}
_do_wireless() {
_WLAN_HIDDEN=""
_WLAN_SSID=""
_WLAN_KEY=""
_WLAN_AUTH=""
if [[ "${_CONNECTION}" == "wireless" ]]; then
# disconnect the interface first!
iwctl station "${_INTERFACE}" disconnect &>"${_NO_LOG}"
# clean old keys first!
rm -f /var/lib/iwd/* &>"${_NO_LOG}"
#shellcheck disable=SC2086,SC2046
_dialog --menu "Choose your SSID:\n(Empty spaces in your SSID are replaced by '+' char)" 14 60 7 \
$(_essid_scan _) \
"Hidden" "_" 2>"${_ANSWER}" || return 1
_WLAN_SSID=$(cat "${_ANSWER}")
_WLAN_CONNECT="connect"
if [[ "${_WLAN_SSID}" == "Hidden" ]]; then
_dialog --inputbox "Enter the hidden SSID:" 8 65 \
"secret" 2>"${_ANSWER}" || return 1
_WLAN_SSID=$(cat "${_ANSWER}")
_WLAN_CONNECT="connect-hidden"
_WLAN_HIDDEN=1
fi
# replace # with spaces again
#shellcheck disable=SC2001,SC2086
_WLAN_SSID="$(echo ${_WLAN_SSID} | sed -e 's|\+|\ |g')"
#shellcheck disable=SC2001,SC2086
while [[ -z "${_WLAN_AUTH}" ]]; do
# expect hidden network has a WLAN_KEY
#shellcheck disable=SC2143
if ! [[ "$(iwctl station "${_INTERFACE}" get-networks | grep -w "${_WLAN_SSID}" | cut -c 42-49 | grep -q 'open')" ]] || [[ "${_WLAN_CONNECT}" == "connect-hidden" ]]; then
_dialog --inputbox "Enter your KEY for SSID='${_WLAN_SSID}'" 8 50 "SecretWirelessKey" 2>"${_ANSWER}" || return 1
_WLAN_KEY=$(cat "${_ANSWER}")
fi
# time to connect
_dialog --infobox "Connection to SSID='${_WLAN_SSID}' with interface ${_INTERFACE}..." 3 70
_printk off
if [[ -z "${_WLAN_KEY}" ]]; then
iwctl station "${_INTERFACE}" "${_WLAN_CONNECT}" "${_WLAN_SSID}" &>"${_NO_LOG}" && _WLAN_AUTH=1
else
iwctl --passphrase="${_WLAN_KEY}" station "${_INTERFACE}" "${_WLAN_CONNECT}" "${_WLAN_SSID}" &>"${_NO_LOG}" && _WLAN_AUTH=1
fi
if [[ -n "${_WLAN_AUTH}" ]]; then
_dialog --infobox "Authentification was successful. Continuing in 5 seconds..." 3 70
sleep 5
else
_dialog --msgbox "Error:\nAuthentification failed. Please configure again!" 6 60
fi
_printk on
done
fi
}
_donetwork() {
_S_NET=""
_NETPARAMETERS=""
while [[ -z "${_NETPARAMETERS}" ]]; do
# select network interface
_INTERFACE=""
_INTERFACES=$(_net_interfaces)
while [[ -z "${_INTERFACE}" ]]; do
#shellcheck disable=SC2086
_dialog --ok-label "Select" --menu "Select a network interface:" 12 40 6 ${_INTERFACES} 2>"${_ANSWER}"
case $? in
1) return 1 ;;
0) _INTERFACE=$(cat "${_ANSWER}") ;;
esac
done
echo "${_INTERFACE}" >/tmp/.network-interface
# iwd renames wireless devices to wlanX
if echo "${_INTERFACE}" | grep -q wlan; then
_CONNECTION="wireless"
else
_CONNECTION="ethernet"
fi
# profile name
_NETWORK_PROFILE=""
_dialog --inputbox "Enter your network profile name:" 7 40 "${_INTERFACE}-${_CONNECTION}" 2>"${_ANSWER}" || return 1
_NETWORK_PROFILE=/etc/systemd/network/$(cat "${_ANSWER}").network
# wifi setup first
_do_wireless || return 1
# dhcp switch
_IP=""
_dialog --yesno "Do you want to use DHCP?" 5 40
#shellcheck disable=SC2181
if [[ $? -eq 0 ]]; then
_IP="dhcp"
_IPADDR=""
_GW=""
_DNS=""
else
_IP="static"
_dialog --inputbox "Enter your IP address and netmask:" 8 40 "192.168.1.23/24" 2>"${_ANSWER}" || return 1
_IPADDR=$(cat "${_ANSWER}")
_dialog --inputbox "Enter your gateway:" 8 40 "192.168.1.1" 2>"${_ANSWER}" || return 1
_GW=$(cat "${_ANSWER}")
_dialog --inputbox "Enter your DNS server IP:" 8 40 "192.168.1.1" 2>"${_ANSWER}" || return 1
_DNS=$(cat "${_ANSWER}")
fi
# http/ftp proxy settings
_dialog --inputbox "Enter your proxy server, for example:\nhttp://name:port\nhttp://ip:port\nhttp://username:password@ip:port\n\n Leave the field empty if no proxy is needed to install." 13 65 "" 2>"${_ANSWER}" || return 1
_PROXY=$(cat "${_ANSWER}")
_PROXIES="http_proxy https_proxy ftp_proxy rsync_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY RSYNC_PROXY"
_dialog --yesno "Are these settings correct?\n\nInterface: ${_INTERFACE}\nConnection: ${_CONNECTION}\nNetwork profile: ${_NETWORK_PROFILE}\nSSID: ${_WLAN_SSID}\nHidden: ${_WLAN_HIDDEN}\nKey: ${_WLAN_KEY}\ndhcp or static: ${_IP}\nIP address: ${_IPADDR}\nGateway: ${_GW}\nDNS server: ${_DNS}\nProxy setting: ${_PROXY}" 0 0
case $? in
1) ;;
0) _NETPARAMETERS=1 ;;
esac
done
# write systemd-networkd profile
echo "#$_NETWORK_PROFILE generated by archboot setup" > "${_NETWORK_PROFILE}"
#shellcheck disable=SC2129
echo "[Match]" >> "${_NETWORK_PROFILE}"
echo "Name=${_INTERFACE}" >> "${_NETWORK_PROFILE}"
echo "" >> "${_NETWORK_PROFILE}"
echo "[Network]" >> "${_NETWORK_PROFILE}"
[[ "${_IP}" == "dhcp" ]] && echo "DHCP=yes" >> "${_NETWORK_PROFILE}"
if [[ "${_CONNECTION}" == "wireless" ]]; then
#shellcheck disable=SC2129
echo "IgnoreCarrierLoss=3s" >>"${_NETWORK_PROFILE}"
fi
if [[ "${_IP}" == "static" ]]; then
#shellcheck disable=SC2129
echo "Address=${_IPADDR}" >>"${_NETWORK_PROFILE}"
echo "Gateway=${_GW}" >>"${_NETWORK_PROFILE}"
echo "DNS=${_DNS}" >>"${_NETWORK_PROFILE}"
fi
# set proxies
if [[ -z "${_PROXY}" ]]; then
for i in ${_PROXIES}; do
unset "${i}"
done
else
for i in ${_PROXIES}; do
export "${i}"="${_PROXY}"
done
fi
if [[ -e /etc/systemd/network/10-wired-auto-dhcp.network ]]; then
echo "Disabled Archboot's bootup wired auto dhcp browsing." >"${_LOG}"
rm /etc/systemd/network/10-wired-auto-dhcp.network
fi
echo "Using setup's network profile ${_NETWORK_PROFILE} now..." >"${_LOG}"
systemctl restart systemd-networkd
systemctl restart systemd-resolved
_dialog --infobox "Waiting for network link to come up..." 3 60
# add sleep here for systemd-resolve get correct values
sleep 5
if ! getent hosts www.google.com &>"${_LOG}"; then
_dialog --msgbox "Error:\nYour network is not working correctly, please configure again!" 6 70
return 1
fi
_dialog --infobox "Link is up. Continuing in 5 seconds..." 3 60
sleep 5
}
if [[ -e /tmp/.net-running ]]; then
clear
echo "net already runs on a different console!"
echo "Please remove /tmp/.net-running first to launch net!"
exit 1
fi
: >/tmp/.net-running
if ! _donetwork; then
clear
[[ -e /tmp/.net ]] && rm /tmp/.net
[[ -e /tmp/.net-running ]] && rm /tmp/.net-running
exit 1
fi
[[ -e /tmp/.net ]] && rm /tmp/.net
[[ -e /tmp/.net-running ]] && rm /tmp/.net-running
clear
exit 0
# vim: set ft=sh ts=4 sw=4 et:

View file

@ -139,42 +139,57 @@ _set_guid() {
fi
}
_set_vconsole() {
_configure_vconsole() {
if [[ -e /usr/bin/km ]]; then
km && _NEXTITEM=1
elif [[ -e /usr/bin/archboot-km.sh ]]; then
archboot-km.sh && _NEXTITEM=1
else
_dialog --msgbox "Error:\nkm script not found, aborting console and keyboard setting." 0 0
_dialog --msgbox "Error:\nkm script not found, aborting console and keyboard configuration." 0 0
fi
}
_configure_network() {
if [[ -e /usr/bin/net ]]; then
net && _NEXTITEM="2"
elif [[ -e /usr/bin/archboot-net.sh ]]; then
archboot-tz.sh && _NEXTITEM="2"
else
_dialog --msgbox "Error:\nnet script not found, aborting network configuration" 0 0
fi
}
_configure_clock() {
if [[ -e /usr/bin/tz ]]; then
tz && _NEXTITEM="3"
elif [[ -e /usr/bin/archboot-tz.sh ]]; then
archboot-tz.sh && _NEXTITEM="3"
else
_dialog --msgbox "Error:\ntz script not found, aborting clock configuration" 0 0
fi
}
_select_source() {
_NEXTITEM="2"
_NEXTITEM="3"
_set_title
_S_SRC=""
if [[ -e "${_LOCAL_DB}" ]]; then
_getsource || return 1
else
if [[ -z ${_S_NET} ]]; then
_check_network || return 1
if ! [[ -e /tmp/.network ]]; then
net || return 1
_S_NET=1
else
_S_NET=1
fi
fi
if [[ -z ${_S_SRC} ]]; then
[[ "${_RUNNING_ARCH}" == "x86_64" ]] && _enable_testing
_getsource || return 1
fi
fi
_NEXTITEM="3"
}
_set_clock() {
if [[ -e /usr/bin/tz ]]; then
tz && _NEXTITEM="4"
elif [[ -e /usr/bin/archboot-tz.sh ]]; then
archboot-tz.sh && _NEXTITEM="4"
else
_dialog --msgbox "Error:\ntz script not found, aborting clock setting" 0 0
fi
_NEXTITEM="4"
}
_prepare_storagedrive() {
@ -279,16 +294,18 @@ _configure_system() {
_mainmenu() {
if [[ -n "${_NEXTITEM}" ]]; then
_DEFAULT="--default-item ${_NEXTITEM}"
elif [[ -e "${_LOCAL_DB}" ]]; then
_DEFAULT="--default-item 4"
else
_DEFAULT=""
_DEFAULT="--default-item 3"
fi
#shellcheck disable=SC2086
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." 17 58 14 \
"0" "Configure Console" \
"1" "Configure Network" \
"2" "Select Source" \
"3" "Configure Clock" \
"2" "Configure Clock" \
"3" "Select Source" \
"4" "Prepare Storage Device" \
"5" "Install Packages" \
"6" "Configure System" \
@ -297,24 +314,24 @@ _mainmenu() {
_NEXTITEM="$(cat ${_ANSWER})"
case $(cat ${_ANSWER}) in
"0")
_set_vconsole ;;
_configure_vconsole ;;
"1")
if [[ -e "/var/cache/pacman/pkg/archboot.db" ]]; then
if [[ -e "${_LOCAL_DB}" ]]; then
_abort_local_mode
else
_donetwork
_configure_network
fi ;;
"2")
_configure_clock ;;
"3")
if [[ "${_DESTDIR}" == "/" ]]; then
_abort_running_system
elif [[ -e "/var/cache/pacman/pkg/archboot.db" ]]; then
elif [[ -e "${_LOCAL_DB}" ]]; then
_abort_local_mode
else
_select_source || return 1
_update_environment
fi ;;
"3")
_set_clock ;;
"4")
if [[ "${_DESTDIR}" == "/" ]]; then
_abort_running_system

View file

@ -141,7 +141,7 @@ _run_update_installer() {
fi
}
if ! [[ -e "/.vconsole-run" ]]; then
if ! [[ -e /.vconsole-run ]]; then
touch /.vconsole-run
FB_SIZE="$(cut -d 'x' -f 1 "$(find /sys -wholename '*fb0/modes')" | sed -e 's#.*:##g')"
if [[ "${FB_SIZE}" -gt '1900' ]]; then
@ -153,7 +153,7 @@ if ! [[ -e "/.vconsole-run" ]]; then
echo FONT=ter-v${SIZE}n >> /etc/vconsole.conf
systemctl restart systemd-vconsole-setup
fi
if ! [[ -e "/.clean-pacman-db" ]]; then
if ! [[ -e /.clean-pacman-db ]]; then
touch /.clean-pacman-db
_RM_PACMAN_DB="base grub libxml2 icu gettext refind amd-ucode intel-ucode edk2-shell \
libisoburn libburn libisofs mkinitcpio memtest linux-api-headers jansson libwbclient \
@ -171,7 +171,7 @@ else
systemctl start systemd-networkd
systemctl start systemd-resolved
# initialize pacman keyring
if [[ -e "/etc/systemd/system/pacman-init.service" ]]; then
if [[ -e /etc/systemd/system/pacman-init.service ]]; then
systemctl start pacman-init
fi
fi
@ -179,10 +179,20 @@ fi
if [[ -e /usr/bin/setup ]]; then
_local_mode
_enter_shell
# basic setup
if ! [[ -e /tmp/.locale ]]; then
archboot-locale.sh
source /etc/locale.conf
fi
if ! [[ -e /tmp/.keymap ]]; then
km && : > /tmp/.keymap
fi
if ! [[ -e /tmp/.network && -e /var/cache/pacman/pkg/archboot.db ]]; then
net && : > /tmp/.network
fi
if ! [[ -e /tmp/.timezone ]]; then
tz && : >/tmp/.timezone
fi
if ! [[ -e /tmp/.setup ]]; then
setup
fi

View file

@ -664,7 +664,7 @@ EOF
_configure_sway() {
echo "Configuring Sway..."
echo "Configuring bemenu..."
sed -i -e 's|^set $menu.*|set $menu j4-dmenu-desktop --dmenu=\x27bemenu -i --tf "#00ff00" --hf "#00ff00" --nf "#dcdccc" --fn "pango:Terminus 12"\x27 --no-generic --term="foot"|g' /etc/sway/config
sed -i -e 's|^set $menu.*|set $menu j4-dmenu-desktop --dmenu=\x27bemenu -i --tf "#00ff00" --hf "#00ff00" --nf "#dcdccc" --fn "pango:Terminus 12" -H 30\x27 --no-generic --term="foot"|g' /etc/sway/config
echo "Configuring wallpaper..."
sed -i -e 's|^output .*|output * bg /usr/share/archboot/grub/archboot-background.png fill|g' /etc/sway/config
echo "Configuring foot..."
@ -740,6 +740,15 @@ EOF
echo "[DESKTOP ENTRY]" > /usr/share/applications/"${i}".desktop
echo 'NoDisplay=true' >> /usr/share/applications/"${i}".desktop
done
echo "Configuring waybar..."
if ! grep -q 'exec waybar' /etc/sway/config; then
# hide sway-bar
sed -i '/position top/a mode invisible' /etc/sway/config
# diable not usable plugins
echo "exec waybar" >> /etc/sway/config
sed -i -e 's#, "custom/media"##g' /etc/xdg/waybar/config
sed -i -e 's#"mpd", "idle_inhibitor", "pulseaudio",##g' /etc/xdg/waybar/config
fi
echo "Configuring dialog..."
cat <<EOF > /etc/dialogrc
border_color = (BLACK,WHITE,ON)

View file

@ -16,6 +16,10 @@ build ()
if echo "${HOOKS[@]}" | grep -qw archboot_keymap ; then
echo -e " - Use the \e[1;92m'km'\e[m script to change to a non-US keymap." >> "${MOTD}"
fi
if echo "${HOOKS[@]}" | grep -qw archboot_net_common ; then
echo -e "\e[1mNetwork Configuration:\e[m" >> "${MOTD}"
echo -e " - Use the \e[1;92m'net'\e[m script to change your network settings." >> "${MOTD}"
fi
if echo "${HOOKS[@]}" | grep -qw archboot_tz; then
echo -e "\e[1mClock Configuration:\e[m" >> "${MOTD}"
echo -e " - Use the \e[1;92m'tz'\e[m script to change your time and date." >> "${MOTD}"

View file

@ -6,6 +6,7 @@ build ()
{
add_all_modules -f '_cs|b44|broadcom/bnx2x|brocade|cavium|chelsio|cisco|netronome|mellanox|myricom|qlogic|qualcomm' '/drivers/net/ethernet|/net/ipv4|/net/ipv6|/drivers/net/usb'
map add_binary ip getent ping wget
add_file /usr/bin/archboot-net.sh /usr/bin/net
# start dhcpcd on startup
add_file "/usr/share/archboot/net/etc/systemd/network/10-wired-auto-dhcp.network" "/etc/systemd/network/10-wired-auto-dhcp.network"
add_file /etc/wgetrc