int unattended = 0;
int serialconsole = 0;
+ int require_networking = 0;
struct keyvalue *unattendedkv = initkeyvalues();
char restore_file[STRING_SIZE] = "";
splashWindow(title, _("Warning: Unattended installation will start in 10 seconds..."), 10);
unattended = 1;
}
+
+ // check if the installer should start networking
+ if (strstr(line, "installer.net") != NULL) {
+ require_networking = 1;
+ }
+
// check if we have to patch for serial console
if (strstr (line, "console=ttyS0") != NULL) {
serialconsole = 1;
/* Search for a source drive that holds the right
* version of the image we are going to install. */
sourcedrive = hw_find_source_medium(hw);
-
fprintf(flog, "Source drive: %s\n", sourcedrive);
+
+ /* If we could not find a source drive, we will try
+ * downloading the install image */
if (!sourcedrive) {
- newtWinMessage(title, _("OK"), _("No local source media found. Starting download."));
- runcommandwithstatus("/bin/downloadsource.sh", title, _("Downloading installation image ..."), logfile);
- if ((handle = fopen("/tmp/source_device", "r")) == NULL) {
- errorbox(_("Download error"));
+ require_networking = 1;
+
+ if (!unattended) {
+ rc = newtWinOkCancel(title, _("No source drive could be found.\n\n"
+ "You can try to download the required installation data. "
+ "Please make sure to connect your machine to a network and "
+ "the installer will try connect to acquire an IP address."),
+ 55, 10, _("Download installation image"), _("Cancel"));
+
+ if (rc != 0)
+ goto EXIT;
+ }
+ }
+
+ // Try starting the networking if we require it
+ if (require_networking) {
+ statuswindow(60, 4, title, _("Trying to start networking (DHCP)..."));
+
+ rc = hw_start_networking(logfile);
+ newtPopWindow();
+
+ if (rc) {
+ errorbox(_("Networking could not be started "
+ "but is required to go on with the installation.\n\n"
+ "Please connect your machine to a network with a "
+ "DHCP server and retry."));
goto EXIT;
}
- fgets(sourcedrive, 5, handle);
- fclose(handle);
+ // Download the image if required
+ if (!sourcedrive) {
+ runcommandwithstatus("/usr/bin/downloadsource.sh",
+ title, _("Downloading installation image..."), logfile);
+
+ if ((handle = fopen("/tmp/source_device", "r")) == NULL) {
+ errorbox(_("Download error"));
+ goto EXIT;
+ }
+
+ fgets(sourcedrive, 5, handle);
+ fclose(handle);
+ }
}
assert(sourcedrive);
--- /dev/null
+#!/bin/bash
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2014 IPFire Team <info@ipfire.org> #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+function list_interfaces() {
+ local interface
+
+ for interface in /sys/class/net/*; do
+ [ -d "${interface}" ] || continue
+
+ interface="$(basename ${interface})"
+ case "${interface}" in
+ eth*)
+ echo "${interface}"
+ ;;
+ esac
+ done
+}
+
+function try_dhcp() {
+ local interface="${1}"
+
+ # Bring up the interface
+ ip link set "${interface}" up
+
+ # Try to make the lights of the adapter light up
+ ethtool -i "${interface}" &>/dev/null
+
+ # Start the DHCP client
+ dhcpcd "${interface}"
+}
+
+function main() {
+ local interface
+ for interface in $(list_interfaces); do
+ if ! try_dhcp "${interface}"; then
+ echo "Could not acquire an IP address on ${interface}"
+ continue
+ fi
+
+ echo "Successfully started on ${interface}"
+ return 0
+ done
+
+ return 1
+}
+
+main