Browse Source

add run-command script

master
parent
commit
f524ad3abd
  1. 60
      shellinabox/rc.shellinabox
  2. 37
      shellinabox/shellinabox.spec

60
shellinabox/rc.shellinabox

@ -0,0 +1,60 @@
#!@l_prefix@/bin/openpkg rc
##
## rc.shellinabox -- Run-Commands
##
%config
shellinabox_enable="$openpkg_rc_def"
shellinabox_flags="--localhost-only --port=4200 --disable-ssl --service=/:SSH:localhost"
shellinabox_log_prolog="true"
shellinabox_log_epilog="true"
shellinabox_log_numfiles="10"
shellinabox_log_minsize="1M"
shellinabox_log_complevel="9"
%common
shellinabox_pidfile="@l_prefix@/var/shellinabox/shellinabox.pid"
shellinabox_logfile="@l_prefix@/var/shellinabox/shellinabox.log"
shellinabox_signal () {
[ -f $shellinabox_pidfile ] && kill -$1 `cat $shellinabox_pidfile`
}
%status -u @l_susr@ -o
shellinabox_usable="unknown"
shellinabox_active="no"
rcService shellinabox enable yes && \
shellinabox_signal 0 && shellinabox_active="yes"
echo "shellinabox_enable=\"$shellinabox_enable\""
echo "shellinabox_usable=\"$shellinabox_usable\""
echo "shellinabox_active=\"$shellinabox_active\""
%start -u @l_susr@
rcService shellinabox enable yes || exit 0
rcService shellinabox active yes && exit 0
@l_prefix@/bin/shellinabox \
--verbose \
--user=@l_nusr@ --group=@l_ngrp@ \
--background --pidfile=$shellinabox_pidfile \
${shellinabox_flags} \
>$shellinabox_logfile 2>&1 </dev/null
%stop -u @l_susr@
rcService shellinabox enable yes || exit 0
rcService shellinabox active no && exit 0
shellinabox_signal TERM
sleep 2
%restart -u @l_susr@
rcService shellinabox enable yes || exit 0
rcService shellinabox active no && exit 0
rc shellinabox stop start
%daily -u @l_susr@
rcService shellinabox enable yes || exit 0
shtool rotate -f \
-n ${shellinabox_log_numfiles} -s ${shellinabox_log_minsize} -d \
-z ${shellinabox_log_complevel} -m 644 -o @l_nusr@ -g @l_ngrp@ \
-P "${shellinabox_log_prolog}" \
-E "${shellinabox_log_epilog}; rc shellinabox restart" \
$shellinabox_logfile

37
shellinabox/shellinabox.spec

@ -36,6 +36,7 @@ Release: 20110806
# list of sources
Source0: http://download.openpkg.org/components/versioned/shellinabox/shellinabox-%{version}.tar.gz
Source1: rc.shellinabox
Patch0: shellinabox.patch
# build information
@ -62,6 +63,7 @@ PreReq: openssl
%patch -p0
%build
# configure program
CC="%{l_cc}" \
CFLAGS="%{l_cflags -O}" \
CPPFLAGS="%{l_cppflags}" \
@ -70,19 +72,52 @@ PreReq: openssl
--prefix=%{l_prefix} \
--mandir=%{l_prefix}/man \
--enable-ssl
# build program
%{l_make} %{l_mflags}
%install
# install program
%{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
# post-adjust installation
strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
%{l_shtool} mkdir -f -p -m 755 \
$RPM_BUILD_ROOT%{l_prefix}/share/shellinabox
mv $RPM_BUILD_ROOT%{l_prefix}/share/doc/shellinabox/*.css \
$RPM_BUILD_ROOT%{l_prefix}/share/shellinabox
rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/doc
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
# install run-command script
%{l_shtool} mkdir -f -p -m 755 \
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
%{l_shtool} install -c -m 755 %{l_value -s -a} \
%{SOURCE rc.shellinabox} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
# create run-time directory
%{l_shtool} mkdir -f -p -m 755 \
$RPM_BUILD_ROOT%{l_prefix}/var/shellinabox
# determine installation files
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
%{l_files_std} \
'%attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/var/shellinabox'
%files -f files
%clean
%post
# after upgrade, restart service
[ $1 -eq 2 ] || exit 0
eval `%{l_rc} shellinabox status 2>/dev/null`
[ ".$shellinabox_active" = .yes ] && %{l_rc} shellinabox restart
exit 0
%preun
# before erase, stop service and remove log files
[ $1 -eq 0 ] || exit 0
%{l_rc} shellinabox stop 2>/dev/null
rm -f $RPM_INSTALL_PREFIX/var/shellinabox/* >/dev/null 2>&1 || true
exit 0

Loading…
Cancel
Save