2016-12-06 18:00:41 +03:00
|
|
|
#!/sbin/openrc-run
|
2011-10-28 17:13:27 +04:00
|
|
|
# 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
|
2016-12-07 12:30:00 +03:00
|
|
|
|
2011-10-28 17:13:27 +04:00
|
|
|
# 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
|
2016-12-07 12:30:00 +03:00
|
|
|
|
2011-10-28 17:13:27 +04:00
|
|
|
while read shell
|
|
|
|
do
|
|
|
|
if [ "$shell" = "$SHELL" ] ; then
|
|
|
|
shell_exist=true
|
|
|
|
fi
|
|
|
|
done < /tmp/tmp.shells
|
2016-12-07 12:30:00 +03:00
|
|
|
|
2011-10-28 17:13:27 +04:00
|
|
|
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
|
2016-12-07 12:30:00 +03:00
|
|
|
|
2011-10-28 17:13:27 +04:00
|
|
|
if [ -z "$GROUPNAME" ] ; then
|
|
|
|
GROUPID=`grep ^$USERNAME: /etc/passwd | awk -F : '{print $4}'`
|
|
|
|
GROUPNAME=`grep :$GROUPID: /etc/group | awk -F : '{print $1}'`
|
|
|
|
fi
|
2016-12-07 12:30:00 +03:00
|
|
|
|
2011-10-28 17:13:27 +04:00
|
|
|
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
|
2013-12-25 10:22:08 +04:00
|
|
|
export LD_LIBRARY_PATH="/netup/utm5/lib"
|
2016-12-07 12:30:00 +03:00
|
|
|
start-stop-daemon --start --quiet --background \
|
|
|
|
--make-pidfile --pidfile /run/utm5_rfw.pid \
|
|
|
|
--exec /netup/utm5/bin/utm5_rfw -- $ARGS -c /etc/utm5/rfw5.cfg
|
2011-10-28 17:13:27 +04:00
|
|
|
eend $?
|
|
|
|
}
|
|
|
|
|
2016-12-07 12:30:00 +03:00
|
|
|
stop() {
|
2011-10-28 17:13:27 +04:00
|
|
|
ebegin "Stopping utm5_rfw"
|
2016-12-07 12:30:00 +03:00
|
|
|
start-stop-daemon --stop --quiet --signal KILL --pidfile /run/utm5_rfw.pid
|
2011-10-28 17:13:27 +04:00
|
|
|
eend $?
|
|
|
|
}
|