From 63886a075cde83940841c5535484305939a9c0da Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Tue, 8 Apr 2008 20:30:58 +0000 Subject: [PATCH] Initial add of monitor spec, init, and cron file for the monitor root account scripts --- monitor.cron | 5 +++++ monitor.init | 49 +++++++++++++++++++++++++++++++++++++++++++++ monitor.spec | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 monitor.cron create mode 100644 monitor.init create mode 100644 monitor.spec diff --git a/monitor.cron b/monitor.cron new file mode 100644 index 0000000..57d98eb --- /dev/null +++ b/monitor.cron @@ -0,0 +1,5 @@ +# Runs once a day at 12pm to fetch the monitor account keys in case it was +# inaccessible previously due to a network outage. + +0 12 * * * root /etc/init.d/monitor start > /dev/null 2>&1 + diff --git a/monitor.init b/monitor.init new file mode 100644 index 0000000..2b03f77 --- /dev/null +++ b/monitor.init @@ -0,0 +1,49 @@ +#!/bin/bash +# +# monitor Enables the monitor account by setting up the ssh key from the enabled PLC. +# +# Load before nm, vcached, and vservers, vserver-reference +# chkconfig: 3 59 80 +# description: Fetch monitor ssh key to enable access to machine via monitor immediately. +# +# Stephen Soltesz +# Copyright (C) 2008 The Trustees of Princeton University +# +# $Id$ +# + +case "$1" in + start|restart|reload) + ;; + stop|status) + exit 0 + ;; + *) + echo $"Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac + +# NOTE: If user already exists, this just exists with status 9. I think it's +# ok to simply let this command check and error out. +# Parse PLC configuration +if [ -r /etc/planetlab/plc_config ] ; then + . /etc/planetlab/plc_config +else + PLC_NAME="PlanetLab" + PLC_SLICE_PREFIX="pl" + PLC_BOOT_HOST="boot.planet-lab.org" +fi + +USER="${PLC_SLICE_PREFIX}_monitor" +/usr/sbin/useradd -p "" -m $USER &> /dev/null || : + +if [ ! -d /home/$USER/.ssh ] ; then + mkdir /home/$USER/.ssh + chmod 700 /home/$USER/.ssh + chown $USER.$USER /home/$USER/.ssh +fi + +URL="http://${PLC_BOOT_HOST}/PlanetLabConf/keys.php?$USER" +curl -s "$URL" > /home/$USER/.ssh/authorized_keys +chown $USER.$USER /home/$USER/.ssh/authorized_keys diff --git a/monitor.spec b/monitor.spec new file mode 100644 index 0000000..440550f --- /dev/null +++ b/monitor.spec @@ -0,0 +1,56 @@ +# +# $Id$ +# + +%define url $URL: svn+ssh://svn.planet-lab.org/svn/monitor/trunk/monitor.spec $ + +%define name monitor +%define version 1.0 +%define taglevel 0 + +%define release %{taglevel}%{?date:.%{date}} + +Summary: Monitor account initialization for the root image. +Name: %{name} +Version: %{version} +Release: %{release} +Source0: %{name}-%{version}.tar.bz2 +License: GPL +Group: Applications/System +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot + +Vendor: PlanetLab +Packager: PlanetLab Central +Distribution: PlanetLab %{plrelease} +URL: %(echo %{url} | cut -d ' ' -f 2) + +%description +Scripts for creating the monitor account in the root filesystem, to enable node access +without using the 'root' account. + +%prep +%setup -q + +%build +echo "There is no build stage. Simply copy files." + +%install +rm -rf $RPM_BUILD_ROOT +install -D -m 755 monitor.init $RPM_BUILD_ROOT/%{_initrddir}/monitor +install -D -m 755 monitor.cron $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/monitor + +%clean +rm -rf $RPM_BUILD_ROOT + +%files %{name} +%defattr(-,root,root) +%{_initrddir}/monitor +%{_sysconfdir}/cron.d/monitor + +%post %{slicefamily} +chkconfig --add monitor +chkconfig monitor on + +%changelog +* Mon Apr 07 2008 Stephen Soltesz - monitor-1.0-0 +- initial addition. -- 2.47.0