From 5ce97e6f22fd25279793fbc75211d2e86413ae73 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Tue, 22 Jan 2008 17:03:46 -0500 Subject: initial stop/restart support Add Stop and Restart methods to the Manager object. We'll rename the Manager object to System in the near future. Use libpolkit to determine authorization. --- tools/Makefile.am | 10 ++++++++++ tools/freebsd/Makefile.am | 38 ++++++++++++++++++++++++++++++++++++++ tools/freebsd/ck-system-restart | 12 ++++++++++++ tools/freebsd/ck-system-stop | 18 ++++++++++++++++++ tools/linux/Makefile.am | 38 ++++++++++++++++++++++---------------- tools/linux/ck-system-restart | 12 ++++++++++++ tools/linux/ck-system-stop | 12 ++++++++++++ tools/solaris/Makefile.am | 38 ++++++++++++++++++++++++++++++++++++++ tools/solaris/ck-system-restart | 12 ++++++++++++ tools/solaris/ck-system-stop | 12 ++++++++++++ 10 files changed, 186 insertions(+), 16 deletions(-) create mode 100644 tools/freebsd/Makefile.am create mode 100755 tools/freebsd/ck-system-restart create mode 100755 tools/freebsd/ck-system-stop create mode 100755 tools/linux/ck-system-restart create mode 100755 tools/linux/ck-system-stop create mode 100644 tools/solaris/Makefile.am create mode 100755 tools/solaris/ck-system-restart create mode 100755 tools/solaris/ck-system-stop (limited to 'tools') diff --git a/tools/Makefile.am b/tools/Makefile.am index 61d60cc..dd3fbd7 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -10,8 +10,18 @@ if CK_COMPILE_LINUX SUBDIRS += linux endif +if CK_COMPILE_FREEBSD +SUBDIRS += freebsd +endif + +if CK_COMPILE_SOLARIS +SUBDIRS += solaris +endif + DIST_SUBDIRS = \ linux \ + freebsd \ + solaris \ $(NULL) INCLUDES = \ diff --git a/tools/freebsd/Makefile.am b/tools/freebsd/Makefile.am new file mode 100644 index 0000000..d25930e --- /dev/null +++ b/tools/freebsd/Makefile.am @@ -0,0 +1,38 @@ +## We require new-style dependency handling. +AUTOMAKE_OPTIONS = 1.7 + +NULL = + +SUBDIRS = \ + $(NULL) + +scriptdir = $(libdir)/ConsoleKit/scripts +script_SCRIPTS = \ + ck-system-stop \ + ck-system-restart \ + $(NULL) + +EXTRA_DIST = \ + $(script_SCRIPTS) \ + $(NULL) + +MAINTAINERCLEANFILES = \ + *~ \ + Makefile.in + + +check: + for f in $(script_SCRIPTS); do \ + echo -n "Validate bash syntax in $$f : "; \ + bash -n $(srcdir)/$$f 2> bash.error;\ + if test -s bash.error; then \ + echo failed; \ + cat bash.error; \ + rm -f bash.error; \ + exit 1; \ + else \ + echo ok; \ + rm -f bash.error; \ + fi; \ + done; + diff --git a/tools/freebsd/ck-system-restart b/tools/freebsd/ck-system-restart new file mode 100755 index 0000000..8e0664e --- /dev/null +++ b/tools/freebsd/ck-system-restart @@ -0,0 +1,12 @@ +#!/bin/sh + +#Try for common tools +if [ -x "/sbin/shutdown" ] ; then + /sbin/shutdown -r now + exit $? +elif [ -x "/usr/sbin/shutdown" ] ; then + /usr/sbin/shutdown -r now + exit $? +else + exit 1 +fi diff --git a/tools/freebsd/ck-system-stop b/tools/freebsd/ck-system-stop new file mode 100755 index 0000000..c947bea --- /dev/null +++ b/tools/freebsd/ck-system-stop @@ -0,0 +1,18 @@ +#!/bin/sh + +unsupported() { + echo "org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported" >&2 + echo "No shutdown command found" >&2 + exit 1 +} + +#Try for common tools +if [ -x "/sbin/shutdown" ] ; then + /sbin/shutdown -p now + exit $? +elif [ -x "/usr/sbin/shutdown" ] ; then + /usr/sbin/shutdown -p now + exit $? +else + unsupported +fi diff --git a/tools/linux/Makefile.am b/tools/linux/Makefile.am index 0830734..51196c0 100644 --- a/tools/linux/Makefile.am +++ b/tools/linux/Makefile.am @@ -6,27 +6,33 @@ NULL = SUBDIRS = \ $(NULL) -INCLUDES = \ - -I. \ - -I$(srcdir) \ - -I$(top_srcdir)/src \ - $(CONSOLE_KIT_CFLAGS) \ - $(DISABLE_DEPRECATED_CFLAGS) \ - -DPREFIX=\""$(prefix)"\" \ - -DBINDIR=\""$(bindir)"\" \ - -DLIBDIR=\""$(libdir)"\" \ - -DLIBEXECDIR=\""$(libexecdir)"\" \ - -DDATADIR=\""$(datadir)"\" \ - -DSYSCONFDIR=\""$(sysconfdir)"\" \ - $(WARN_CFLAGS) \ - $(DEBUG_CFLAGS) \ - $(TOOLS_CFLAGS) \ +scriptdir = $(libdir)/ConsoleKit/scripts +script_SCRIPTS = \ + ck-system-stop \ + ck-system-restart \ $(NULL) - EXTRA_DIST = \ + $(script_SCRIPTS) \ $(NULL) MAINTAINERCLEANFILES = \ *~ \ Makefile.in + + +check: + for f in $(script_SCRIPTS); do \ + echo -n "Validate bash syntax in $$f : "; \ + bash -n $(srcdir)/$$f 2> bash.error;\ + if test -s bash.error; then \ + echo failed; \ + cat bash.error; \ + rm -f bash.error; \ + exit 1; \ + else \ + echo ok; \ + rm -f bash.error; \ + fi; \ + done; + diff --git a/tools/linux/ck-system-restart b/tools/linux/ck-system-restart new file mode 100755 index 0000000..8e0664e --- /dev/null +++ b/tools/linux/ck-system-restart @@ -0,0 +1,12 @@ +#!/bin/sh + +#Try for common tools +if [ -x "/sbin/shutdown" ] ; then + /sbin/shutdown -r now + exit $? +elif [ -x "/usr/sbin/shutdown" ] ; then + /usr/sbin/shutdown -r now + exit $? +else + exit 1 +fi diff --git a/tools/linux/ck-system-stop b/tools/linux/ck-system-stop new file mode 100755 index 0000000..e26bca3 --- /dev/null +++ b/tools/linux/ck-system-stop @@ -0,0 +1,12 @@ +#!/bin/sh + +#Try for common tools +if [ -x "/sbin/shutdown" ] ; then + /sbin/shutdown -h now + exit $? +elif [ -x "/usr/sbin/shutdown" ] ; then + /usr/sbin/shutdown -h now + exit $? +else + exit 1 +fi diff --git a/tools/solaris/Makefile.am b/tools/solaris/Makefile.am new file mode 100644 index 0000000..d25930e --- /dev/null +++ b/tools/solaris/Makefile.am @@ -0,0 +1,38 @@ +## We require new-style dependency handling. +AUTOMAKE_OPTIONS = 1.7 + +NULL = + +SUBDIRS = \ + $(NULL) + +scriptdir = $(libdir)/ConsoleKit/scripts +script_SCRIPTS = \ + ck-system-stop \ + ck-system-restart \ + $(NULL) + +EXTRA_DIST = \ + $(script_SCRIPTS) \ + $(NULL) + +MAINTAINERCLEANFILES = \ + *~ \ + Makefile.in + + +check: + for f in $(script_SCRIPTS); do \ + echo -n "Validate bash syntax in $$f : "; \ + bash -n $(srcdir)/$$f 2> bash.error;\ + if test -s bash.error; then \ + echo failed; \ + cat bash.error; \ + rm -f bash.error; \ + exit 1; \ + else \ + echo ok; \ + rm -f bash.error; \ + fi; \ + done; + diff --git a/tools/solaris/ck-system-restart b/tools/solaris/ck-system-restart new file mode 100755 index 0000000..8e0664e --- /dev/null +++ b/tools/solaris/ck-system-restart @@ -0,0 +1,12 @@ +#!/bin/sh + +#Try for common tools +if [ -x "/sbin/shutdown" ] ; then + /sbin/shutdown -r now + exit $? +elif [ -x "/usr/sbin/shutdown" ] ; then + /usr/sbin/shutdown -r now + exit $? +else + exit 1 +fi diff --git a/tools/solaris/ck-system-stop b/tools/solaris/ck-system-stop new file mode 100755 index 0000000..e26bca3 --- /dev/null +++ b/tools/solaris/ck-system-stop @@ -0,0 +1,12 @@ +#!/bin/sh + +#Try for common tools +if [ -x "/sbin/shutdown" ] ; then + /sbin/shutdown -h now + exit $? +elif [ -x "/usr/sbin/shutdown" ] ; then + /usr/sbin/shutdown -h now + exit $? +else + exit 1 +fi -- cgit