+#define DEFAULT_LANG "English"
+#define NUM_LANGS 10
+
+static struct lang {
+ const char* code;
+ char* name;
+} languages[NUM_LANGS + 1] = {
+ { "da.utf8", "Danish (Dansk)" },
+ { "nl_NL.utf8", "Dutch (Nederlands)" },
+ { "en_US.utf8", "English" },
+ { "fr_FR.utf8", "French (Français)" },
+ { "de_DE.utf8", "German (Deutsch)" },
+ { "pl_PL.utf8", "Polish (Polski)" },
+ { "pt_BR.utf8", "Portuguese (Brasil)" },
+ { "ru_RU.utf8", "Russian (Русский)" },
+ { "es_ES.utf8", "Spanish (Español)" },
+ { "tr_TR.utf8", "Turkish (Türkçe)" },
+ { NULL, NULL },
+};
+
+static struct config {
+ int unattended;
+ int serial_console;
+ int require_networking;
+ int perform_download;
+ int disable_swap;
+ char download_url[STRING_SIZE];
+ char postinstall[STRING_SIZE];
+} config = {
+ .unattended = 0,
+ .serial_console = 0,
+ .require_networking = 0,
+ .perform_download = 0,
+ .disable_swap = 0,
+ .download_url = DOWNLOAD_URL,
+ .postinstall = "\0",
+};
+
+static void parse_command_line(struct config* c) {
+ char buffer[STRING_SIZE];
+ char cmdline[STRING_SIZE];
+
+ FILE* f = fopen("/proc/cmdline", "r");
+ if (!f)
+ return;
+
+ int r = fread(&cmdline, 1, sizeof(cmdline) - 1, f);
+ if (r > 0) {
+ char* token = strtok(cmdline, " ");
+
+ while (token) {
+ strncpy(buffer, token, sizeof(buffer));
+ char* val = buffer;
+ char* key = strsep(&val, "=");
+
+ // serial console
+ if (strcmp(token, "console=ttyS0") == 0)
+ c->serial_console = 1;
+
+ // enable networking?
+ else if (strcmp(token, "installer.net") == 0)
+ c->require_networking = 1;
+
+ // unattended mode
+ else if (strcmp(token, "installer.unattended") == 0)
+ c->unattended = 1;
+
+ // disable swap
+ else if (strcmp(token, "installer.disable-swap") == 0)
+ c->disable_swap = 1;
+
+ // download url
+ else if (strcmp(key, "installer.download-url") == 0) {
+ strncpy(c->download_url, val, sizeof(c->download_url));
+ c->perform_download = 1;
+
+ // Require networking for the download
+ c->require_networking = 1;
+
+ // postinstall script
+ } else if (strcmp(key, "installer.postinstall") == 0) {
+ strncpy(c->postinstall, val, sizeof(c->postinstall));
+
+ // Require networking for the download
+ c->require_networking = 1;
+ }
+
+ token = strtok(NULL, " ");
+ }
+ }
+
+ fclose(f);
+}
+