ebuild for UTM5

This commit is contained in:
2011-10-28 17:13:27 +04:00
parent 02d2a047e3
commit 49d12dad37
9 changed files with 293 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
*utm5-1.10.009 (07 Mar 2005)
07 Mar 2005; Peter Volkov <pvolkov@mics.msu.su> utm5-1.10.009.ebuild:
The begining.
Added initial ChangeLog which should be updated whenever the package is
updated in any way. This changelog is targetted to users. This means that
the comments should well explained and written in clean English. The
details about writing correct changelogs are explained in the
skel.ChangeLog file which you can find in the root directory of the
portage repository.

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<herd>no-herd</herd>
<maintainer>
<email>info@netup.ru</email>
<description>NetUP Inc</description>
</maintainer>
<longdescription>UTM5 billing system, see www.netup.ru for details.</longdescription>
</pkgmetadata>

51
net-misc/utm5/files/utm5_core Executable file
View File

@@ -0,0 +1,51 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
check_db_is_running() {
if ! `/etc/init.d/mysql status 2>/dev/null | grep "started" > /dev/null 2>&1 ` ; then
if ! `/etc/init.d/postgresql status 2>/dev/null | grep "started" > /dev/null 2>&1` ; then
ewarn "You have not started neither mysql nor postgresql!"
eerror "Please start anything."
return 1
fi
fi
}
depend() {
after mysql postgresql
}
start() {
check_db_is_running || return 1
ebegin "Starting utm5_core"
start-stop-daemon --start --quiet --make-pidfile --pidfile /var/run/safe_utm5_core.pid \
--background --exec /netup/utm5/bin/safe_utm5_core -- start
eend $?
}
stop() {
ebegin "Stopping safe_utm5_core"
start-stop-daemon --stop --quiet --signal 9 --pidfile /var/run/safe_utm5_core.pid
eend $?
ebegin "Stopping utm5_core"
killall -s USR1 utm5_core
# Now we need to check that the processes are really stoped.
for i in 1 2 3 4 5 ; do
sleep 2
my_status=`ps aux | grep -v "grep utm5_core" | grep -v "stop" | grep utm5_core >/dev/null 2>&1; echo $?`
if [ "$my_status" = "1" ] ;then
echo -n "All process dead..."
break;
fi
done
my_status=`ps aux | grep -v "grep utm5_core" | grep -v "stop" | grep utm5_core >/dev/null 2>&1; echo $?`
if [ $my_status = "0" ] ; then
echo -n "Wated for 10 sec and no result... Killing!"
killall -9 utm5_core
fi
eend 0
}

16
net-misc/utm5/files/utm5_radius Executable file
View File

@@ -0,0 +1,16 @@
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
start() {
ebegin "Starting utm5_radius"
start-stop-daemon --start --quiet --background --exec /netup/utm5/bin/safe_utm5_radius -- start
eend $?
}
stop() {
ebegin "Stopping utm5_radius"
start-stop-daemon --start --quiet --exec /netup/utm5/bin/safe_utm5_radius -- stop
eend $?
}

74
net-misc/utm5/files/utm5_rfw Executable file
View File

@@ -0,0 +1,74 @@
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
checkconfig() {
if [ ! -f /etc/conf.d/utm5_rfw.conf ] ; then
eerror "You will need an /etc/conf.d/utm5_rfw.conf."
return 1
fi
. /etc/conf.d/utm5_rfw.conf
# Checking for valid shell for supplied user.
SHELL=`grep ^$USERNAME: /etc/passwd | awk -F : '{print $7}'`
if [ -z "$SHELL" ] ; then
eerror "Supply user with valid shell in /etc/conf.d/utm5_rfw.conf."
return 1
fi
# This is durty and assumes that shell is in /bin directory. But in most cases this is true.
shell_exist=false
rm -f /tmp/tmp.shells ; grep "^/bin/" /etc/shells > /tmp/tmp.shells
while read shell
do
if [ "$shell" = "$SHELL" ] ; then
shell_exist=true
fi
done < /tmp/tmp.shells
if [ "$shell_exist" = "false" ] ; then
eerror "Supply user with a valid shell in /etc/conf.d/utm5_rfw.conf."
return 1
fi
if [ "$shell_exist" = "true" ] ; then
return 0
fi
eerror Init script error? Please submit a report at support@netup.ru.
}
start() {
checkconfig || return 1
ebegin "Starting utm5_rfw"
. /etc/conf.d/utm5_rfw.conf
if [ -z "$GROUPNAME" ] ; then
GROUPID=`grep ^$USERNAME: /etc/passwd | awk -F : '{print $4}'`
GROUPNAME=`grep :$GROUPID: /etc/group | awk -F : '{print $1}'`
fi
LOG_FILENAME=`grep "log_file_main" /etc/utm5/rfw5.cfg | grep "=" | awk -F= '{print $2}'`
if [ ! -f $LOG_FILENAME ] ; then
mkdir -p `dirname $LOG_FILENAME`
touch $LOG_FILENAME
chown $USERNAME:$GROUPNAME $LOG_FILENAME
fi
# Checking the possibility to write in log file.
if ! `/bin/su $USERNAME -c "/bin/echo \">>>\" \`date\` Starting utm5_rfw. >> $LOG_FILENAME"`
then
eerror "Can not write into $LOG_FILENAME. Please check permitions."
fi
/bin/su $USERNAME -c "/netup/utm5/bin/utm5_rfw $ARGS -c /etc/utm5/rfw5.cfg >> $LOG_FILENAME 2>&1 &"
eend $?
}
stop() {
ebegin "Stopping utm5_rfw"
killall -s 9 utm5_rfw
eend $?
}

View File

@@ -0,0 +1,13 @@
# This is configuration file for /etc/init.d/utm5_rfw.
# Username we should start service from. If you do not know what to do just issue the commands:
# groupadd rfw
# useradd -g rfw rfw
USERNAME="rfw"
# Name of group, log file will be owned by. If not specified, will be primary group for rfw user.
# GROUPNAME="users"
# You may add here additional parameters.
# For example -f will issue rules for Connected users with the start of utm5_rfw.
ARGS="-f"