+check_dbglvl(void)
+{
+ FILE *fp = fopen("/tmp/debug_level", "r");
+ int lvl = 0;
+
+ if (!fp)
+ return;
+ if (fscanf(fp, "%d", &lvl) == EOF)
+ ERROR("failed to read debug level: %m\n");
+ fclose(fp);
+ unlink("/tmp/debug_level");
+
+ if (lvl > 0 && lvl < 5)
+ debug = lvl;
+}
+
+static void
+check_sysupgrade(void)
+{
+ char *prefix = NULL, *path = NULL, *command = NULL;
+ size_t n;
+
+ if (chdir("/"))
+ return;
+
+ FILE *sysupgrade = fopen("/tmp/sysupgrade", "r");
+ if (!sysupgrade)
+ return;
+
+ n = 0;
+ if (getdelim(&prefix, &n, 0, sysupgrade) < 0)
+ goto fail;
+ n = 0;
+ if (getdelim(&path, &n, 0, sysupgrade) < 0)
+ goto fail;
+ n = 0;
+ if (getdelim(&command, &n, 0, sysupgrade) < 0)
+ goto fail;
+
+ fclose(sysupgrade);
+
+ sysupgrade_exec_upgraded(prefix, path, command);
+
+ while (true)
+ sleep(1);
+
+fail:
+ fclose(sysupgrade);
+ free(prefix);
+ free(path);
+ free(command);
+}
+
+static void