major source structure and module name changes
This commit is contained in:
108
micasad/startup/Makefile.am
Normal file
108
micasad/startup/Makefile.am
Normal file
@@ -0,0 +1,108 @@
|
||||
#######################################################################
|
||||
#
|
||||
# Copyright (C) 2006 Novell, Inc.
|
||||
#
|
||||
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
if DEBUG
|
||||
TARGET_CFG = Debug
|
||||
CFLAGS += -v -w
|
||||
else
|
||||
TARGET_CFG = Release
|
||||
endif
|
||||
|
||||
SUBDIRS =
|
||||
DIST_SUBDIRS =
|
||||
|
||||
EXTRA_DIST = $(CFILES) *.sh *casa*
|
||||
|
||||
CASAROOT = ../..
|
||||
|
||||
CASALIBDIR = $(CASAROOT)/$(LIB)
|
||||
|
||||
if LIB64
|
||||
CASABINDIR = $(CASAROOT)/bin64
|
||||
else
|
||||
CASABINDIR = $(CASAROOT)/bin
|
||||
endif
|
||||
|
||||
# handle Mono secondary dependencies
|
||||
export MONO_PATH := $(MONO_PATH)
|
||||
|
||||
PLATFORMINDEPENDENTSOURCEDIR = ..
|
||||
PLATFORMDEPENDENTSOURCEDIR = .
|
||||
|
||||
MODULE_NAME =micasad-init
|
||||
MODULE_EXT =
|
||||
|
||||
CFILES = micasad-init.c
|
||||
|
||||
CSFILES_CSC :=
|
||||
EXTRA_CFLAGS =
|
||||
RESOURCES =
|
||||
OBJDIR = ./$(TARGET_CFG)/$(LIB)
|
||||
|
||||
#OBJS = $(addprefix $(OBJDIR)/, $(CFILES:%.c=%.o))
|
||||
OBJS = micasad-init
|
||||
|
||||
CUR_DIR := $(shell pwd)
|
||||
|
||||
all: $(OBJDIR)/$(MODULE_NAME)
|
||||
|
||||
#
|
||||
# Pattern based rules.
|
||||
#
|
||||
vpath %.c $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
vpath %.cpp $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
|
||||
|
||||
$(OBJS):
|
||||
@echo [======== Compiling $@ ========]
|
||||
@echo [======== OBJDIR $(OBJDIR) ========]
|
||||
$(CC) -o $@ $(CFILES)
|
||||
|
||||
$(OBJDIR)/$(MODULE_NAME): $(OBJDIR) $(OBJS)
|
||||
cp -f $(OBJS) $(OBJDIR)/$(MODULE_NAME)
|
||||
cp -f $(OBJDIR)/$(MODULE_NAME) $(CASABINDIR)/$(TARGET_CFG)/$(MODULE_NAME)
|
||||
|
||||
$(OBJDIR):
|
||||
[ -d $(OBJDIR) ] || mkdir -p $(OBJDIR)
|
||||
[ -d $(CASABINDIR) ] || mkdir -p $(CASABINDIR)
|
||||
[ -d $(CASABINDIR)/$(TARGET_CFG) ] || mkdir -p $(CASABINDIR)/$(TARGET_CFG)
|
||||
|
||||
|
||||
install-exec-local: $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
$(INSTALL_PROGRAM) $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(DESTDIR)$(libdir)/
|
||||
|
||||
uninstall-local:
|
||||
cd $(DESTDIR)$(libdir); rm -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT)
|
||||
rmdir $(DESTDIR)$(libdir)
|
||||
|
||||
#installcheck-local: install
|
||||
# $(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
# $(INSTALL_PROGRAM) $(DESTDIR)$(libdir)
|
||||
# cd $(DESTDIR)$(libdir); $(MONO)
|
||||
|
||||
clean-local:
|
||||
if [ -d $(TARGET_CFG) ]; then rm -rf $(TARGET_CFG); fi
|
||||
|
||||
distclean-local:
|
||||
|
||||
maintainer-clean-local:
|
||||
rm -f Makefile.in
|
||||
|
||||
24
micasad/startup/casacfgpam
Executable file
24
micasad/startup/casacfgpam
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# Adding CASA pam entries to pam files.
|
||||
rm -f *.rpmsave
|
||||
for file in "/etc/pam.d/login" "/etc/pam.d/sshd" "/etc/pam.d/xdm" "/etc/pam.d/gdm" "/etc/pam.d/kdm"
|
||||
do
|
||||
if [ -f $file ]
|
||||
then
|
||||
sed -i '/pam_micasa/d' $file
|
||||
var=`grep pam_unix2.so $file`
|
||||
entry=`echo -e "auth\t required\tpam_micasa.so"`
|
||||
if [ "$var" != "" ]
|
||||
then
|
||||
sed -i "/^auth.*required.*pam_unix2.so/a$entry" $file
|
||||
continue
|
||||
fi
|
||||
var2=`grep common-auth $file`
|
||||
if [ "$var2" != "" ]
|
||||
then
|
||||
sed -i "/^auth.*include.*common-auth/a$entry" $file
|
||||
continue
|
||||
fi
|
||||
sed -i "0,/^auth/s/^\(auth.*\)/\1\n$entry/" $file
|
||||
fi
|
||||
done
|
||||
10
micasad/startup/casaucfgpam
Normal file
10
micasad/startup/casaucfgpam
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Remove the CASA pam entries from pam files.
|
||||
for pam_file in "/etc/pam.d/login" "/etc/pam.d/sshd" "/etc/pam.d/xdm" "/etc/pam.d/gdm" "/etc/pam.d/kdm"
|
||||
do
|
||||
if [ -f $pam_file ]
|
||||
then
|
||||
sed -i '/pam_micasa/d' $pam_file
|
||||
fi
|
||||
done
|
||||
|
||||
12
micasad/startup/installcasa
Executable file
12
micasad/startup/installcasa
Executable file
@@ -0,0 +1,12 @@
|
||||
# enable the service
|
||||
insserv -d /etc/init.d/micasad >/dev/null 2>&1
|
||||
# install PAM modules
|
||||
(/usr/sbin/casacfgpam)
|
||||
RCODE=$?
|
||||
if(test $RCODE != 0)
|
||||
then
|
||||
exit $RCODE
|
||||
else
|
||||
/etc/init.d/micasad restart >/dev/null 2>&1
|
||||
exit 0
|
||||
fi
|
||||
18
micasad/startup/iscasaconfiged
Executable file
18
micasad/startup/iscasaconfiged
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
set -x
|
||||
#
|
||||
CFG=`rpm -qa |grep -i ^casa-[1-9]`
|
||||
if [ "$CFG" != "" ]
|
||||
then
|
||||
PAM=`find /etc/pam.d -exec grep -i casa \{\} \;`
|
||||
if [ "$PAM" != "" ]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
125
micasad/startup/micasad
Normal file
125
micasad/startup/micasad
Normal file
@@ -0,0 +1,125 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: micasad
|
||||
# Required-Start:
|
||||
# Should-Start:
|
||||
# Required-Stop:
|
||||
# Should-Stop:
|
||||
# Default-Start: 1 2 3 5
|
||||
# Default-Stop:
|
||||
# Short-Description: miCASA daemon
|
||||
# Description: miCASA daemon
|
||||
### END INIT INFO
|
||||
|
||||
MICASAD_BIN=/usr/sbin/micasad.sh
|
||||
test -x $MICASAD_BIN || exit 5
|
||||
|
||||
. /etc/rc.status
|
||||
|
||||
# Shell functions sourced from /etc/rc.status:
|
||||
# rc_check check and set local and overall rc status
|
||||
# rc_status check and set local and overall rc status
|
||||
# rc_status -v ditto but be verbose in local rc status
|
||||
# rc_status -v -r ditto and clear the local rc status
|
||||
# rc_failed set local and overall rc status to failed
|
||||
# rc_reset clear local rc status (overall remains)
|
||||
# rc_exit exit appropriate to overall rc status
|
||||
|
||||
# First reset status of this service
|
||||
rc_reset
|
||||
|
||||
function pid_exists()
|
||||
{
|
||||
test -f /var/run/micasad.pid 2> /dev/null
|
||||
}
|
||||
|
||||
function process_running()
|
||||
{
|
||||
kill -0 `cat /var/run/micasad.pid` 2> /dev/null
|
||||
}
|
||||
|
||||
function is_running()
|
||||
{
|
||||
pid_exists && process_running
|
||||
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
if ! is_running; then \
|
||||
echo -n "Starting miCASA daemon"
|
||||
$MICASAD_BIN
|
||||
fi
|
||||
# Remember status and be verbose
|
||||
rc_status -v
|
||||
|
||||
;;
|
||||
stop)
|
||||
if is_running; then \
|
||||
echo -n "Shutting down miCASA daemon"
|
||||
#killproc -TERM $MICASAD_BIN
|
||||
pid=`cat /var/run/micasad.pid` >/dev/null 2>&1
|
||||
kill -s TERM $pid >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# Remember status and be verbose
|
||||
rc_status -v
|
||||
;;
|
||||
try-restart|condrestart)
|
||||
$0 status
|
||||
if test $? = 0
|
||||
then
|
||||
$0 restart
|
||||
else
|
||||
rc_reset # Not running is not a failure.
|
||||
fi
|
||||
# Remember status and be quiet
|
||||
rc_status
|
||||
;;
|
||||
restart)
|
||||
## Stop the service and regardless of whether it was
|
||||
## running or not, start it again.
|
||||
echo "Restarting miCASA daemon"
|
||||
$0 stop
|
||||
$0 start
|
||||
|
||||
# Remember status and be quiet
|
||||
rc_status
|
||||
;;
|
||||
reload)
|
||||
## Stop the service and regardless of whether it was
|
||||
## running or not, start it again.
|
||||
echo "Restarting miCASA daemon"
|
||||
$0 stop
|
||||
$0 start
|
||||
|
||||
# Remember status and be quiet
|
||||
rc_status
|
||||
;;
|
||||
force-reload)
|
||||
## Stop the service and regardless of whether it was
|
||||
## running or not, start it again.
|
||||
echo "Restarting miCASA daemon"
|
||||
$0 stop
|
||||
$0 start
|
||||
|
||||
# Remember status and be quiet
|
||||
rc_status
|
||||
;;
|
||||
status)
|
||||
echo -n "Checking miCASA daemon"
|
||||
if pid_exists && ! process_running 2> /dev/null; then \
|
||||
rc_failed 1
|
||||
elif ! pid_exists && ! process_running 2> /dev/null; then \
|
||||
rc_failed 3
|
||||
fi
|
||||
|
||||
rc_status -v
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|try-restart|reload|force-reload|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
rc_exit
|
||||
39
micasad/startup/micasad-init.c
Normal file
39
micasad/startup/micasad-init.c
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int no_fds = 0;
|
||||
int fd = -1;
|
||||
int rc = 0;
|
||||
pid_t sid;
|
||||
|
||||
/*
|
||||
* Fork a child process
|
||||
* Exit parent
|
||||
* Change directory to "/"
|
||||
* Redirect stdin, stdout, stderr to "/dev/null"
|
||||
*/
|
||||
rc = daemon (0, 0);
|
||||
if ( rc < 0 )
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Create a new session */
|
||||
setsid();
|
||||
|
||||
/* Set the file mode creation mask */
|
||||
umask(022);
|
||||
|
||||
/* Close the associated standard file descriptors */
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
|
||||
/* Start micasad */
|
||||
return execv ("/usr/bin/mono", argv);
|
||||
}
|
||||
11
micasad/startup/micasad.sh
Normal file
11
micasad/startup/micasad.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
HOST_ARCH=`uname -a | grep -c x86_64`
|
||||
if [ $HOST_ARCH -gt 0 ]
|
||||
then ARCH_LIB=64
|
||||
else
|
||||
ARCH_LIB=
|
||||
fi
|
||||
|
||||
|
||||
export MONO_PATH=/usr/lib$ARCH_LIB/
|
||||
exec /usr/bin/micasad-init /usr/bin/micasad.exe
|
||||
12
micasad/startup/uninstallcasa
Executable file
12
micasad/startup/uninstallcasa
Executable file
@@ -0,0 +1,12 @@
|
||||
#disable the service
|
||||
/etc/init.d/micasad stop >/dev/null 2>&1
|
||||
insserv -r /etc/init.d/micasad >/dev/null 2>&1
|
||||
# uninstall PAM modules
|
||||
(/usr/sbin/casaucfgpam)
|
||||
RCODE=$?
|
||||
if(test $RCODE != 0)
|
||||
then
|
||||
exit $RCODE
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
Reference in New Issue
Block a user