Add installer

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-12-19 17:36:05 +00:00
parent 4f13f13df6
commit dbc913fcd8
16 changed files with 271 additions and 30 deletions

View File

@@ -3,7 +3,6 @@
set -o errexit
set -o nounset
set -o pipefail
set -x
check_root() {
if [[ "${EUID}" -ne 0 ]]; then
@@ -22,11 +21,10 @@ check_network() {
echo "No network connection detected."
echo "Would you like to connect to a Wi-Fi network? [y/N]"
read -r connect_wifi
if ! [[ "${connect_wifi}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo "Please connect to a network before proceeding."
echo "Connect to a network before proceeding."
exit 1
fi
@@ -34,33 +32,33 @@ check_network() {
}
setup_wifi() {
echo "Available network interfaces:"
ip link show | grep -E '^[0-9]+:' | awk '{print $2}' | tr -d ':'
echo "Available Wi-Fi interfaces:"
nmcli device status | awk '$2 == "wifi" {print $1}'
echo "Enter the network interface you want to use:"
echo "Enter the Wi-Fi interface you want to use:"
read -r interface
echo "Enter the SSID of the open network:"
echo "Scanning for Wi-Fi networks..."
nmcli device wifi rescan
echo "Available Wi-Fi networks:"
nmcli device wifi list
echo "Enter the SSID of the network:"
read -r ssid
echo "Do you want to connect to an open network? [y/N]"
echo "Is this network open? [y/N]"
read -r open_network
if [[ "${open_network}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
wpa_supplicant -i "${interface}" -c <(wpa_passphrase "${ssid}") -B
nmcli device wifi connect "${ssid}" ifname "${interface}"
else
echo "Enter the passphrase:"
read -rs passphrase
wpa_passphrase "${ssid}" "${passphrase}" > wifi.conf
wpa_supplicant -i "${interface}" -c wifi.conf -B
rm wifi.conf
nmcli device wifi connect "${ssid}" password "${passphrase}" ifname "${interface}"
fi
dhcpcd
echo "Waiting for a network connection..."
for i in {1..10}; do
if ping -c 1 google.com &>/dev/null; then
echo "Connected to the network successfully."
@@ -148,12 +146,12 @@ main() {
copy_keys
install
copy_config
echo "Installation complete. Please reboot your system."
echo "Installation complete. Reboot your system."
;;
2)
prepare_disk "mount"
install
echo "Repair complete. Please reboot your system."
echo "Repair complete. Reboot your system."
;;
*)
echo "Invalid choice."