summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames Maki <jmaki@multitech.com>2010-04-23 16:14:25 -0500
committerJames Maki <jmaki@multitech.com>2010-04-23 16:14:25 -0500
commitf54678ced932d4994e026b6688c5451313e7c9ea (patch)
treef03dd4d967cfd03d3f74763dfe6a0155df5f62a5 /src
downloadupgrade-reboot-f54678ced932d4994e026b6688c5451313e7c9ea.tar.gz
upgrade-reboot-f54678ced932d4994e026b6688c5451313e7c9ea.tar.bz2
upgrade-reboot-f54678ced932d4994e026b6688c5451313e7c9ea.zip
first commit
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am8
-rw-r--r--src/upgrade_reboot.c92
-rw-r--r--src/upgrade_reboot.h6
3 files changed, 106 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..bf78ecc
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,8 @@
+AUTOMAKE_OPTIONS = gnu
+AM_CFLAGS = -Wall -static
+sbin_PROGRAMS = upgrade-reboot
+upgrade_reboot_SOURCES = upgrade_reboot.c
+noinst_HEADERS = upgrade_reboot.h
+
+EXTRA_DIST =
+
diff --git a/src/upgrade_reboot.c b/src/upgrade_reboot.c
new file mode 100644
index 0000000..6a8647b
--- /dev/null
+++ b/src/upgrade_reboot.c
@@ -0,0 +1,92 @@
+/*
+ * Reboot command to run after firmware upgrade.
+ *
+ * Copyright (C) 2010 by Multi-Tech Systems
+ *
+ * Author: James Maki <jmaki@multitech.com>
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/reboot.h>
+
+#include "upgrade_reboot.h"
+
+static void print_version(const char *name) {
+ printf("%s (" PACKAGE ") " VERSION " (" __DATE__ " " __TIME__ ")\n", name);
+ printf("Copyright (C) 2010 by Multi-Tech Systems\n");
+ printf(
+"This program is free software; you may redistribute it under the terms of\n"
+"the GNU General Public License version 2 or (at your option) any later version.\n"
+"This program has absolutely no warranty.\n");
+}
+
+static void usage(FILE *out) {
+ fprintf(out, "Usage: upgrade-reboot\n");
+ fprintf(out, "\n");
+}
+
+enum {
+ OPT_VERSION = 128,
+ OPT_HELP,
+};
+
+static char *short_options = "";
+static struct option long_options[] = {
+ {"version", 0, NULL, OPT_VERSION},
+ {"help", 0, NULL, OPT_HELP},
+ {0, 0, 0, 0},
+};
+
+int main(int argc, char *argv[]) {
+ int i;
+ int option_index;
+
+ while((i = getopt_long(argc, argv, short_options, long_options, &option_index)) >= 0) {
+ switch(i) {
+ case 0:
+ break;
+
+ case OPT_VERSION:
+ print_version("upgrade-reboot");
+ exit(0);
+ break;
+
+ case OPT_HELP:
+ usage(stdout);
+ exit(0);
+ break;
+
+ default:
+ usage(stderr);
+ exit(1);
+ }
+ }
+
+ sync();
+ sleep(2);
+
+ reboot(RB_AUTOBOOT);
+
+ return 0;
+}
+
diff --git a/src/upgrade_reboot.h b/src/upgrade_reboot.h
new file mode 100644
index 0000000..f4f0f1d
--- /dev/null
+++ b/src/upgrade_reboot.h
@@ -0,0 +1,6 @@
+#ifndef __UPGRADE_REBOOT_H
+#define __UPGRADE_REBOOT_H
+
+#include "config.h"
+
+#endif /* ~__UPGRADE_REBOOT_H */