Moved the Agents into their own repo. Kept the agent.pl just for reference

This commit is contained in:
Frank Harris 2025-09-11 13:27:32 -04:00
parent 22381be29a
commit 8680a02b13
18132 changed files with 0 additions and 2569420 deletions

View file

@ -1,43 +0,0 @@
#!/bin/bash
# Generic Init script if we can't find what kind of Linux we're on
agent_dir=OGP_AGENT_DIR
agent_user=OGP_USER
# Start function.
start() {
echo "Starting OGP Agent..."
cd $agent_dir
su -c "screen -d -m -t ogp_agent -c ogp_screenrc -S ogp_agent ./ogp_agent_run -pidfile ogp_agent_run.pid" $agent_user &> $agent_dir/ogp_agent.svc &
echo
}
# Stop function.
stop() {
echo "Stopping OGP Agent..."
kill `cat $agent_dir/ogp_agent_run.pid`
}
restart() {
stop
start
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "Usage: ogp_agent {start|stop|restart}"
exit 1
;;
esac
exit 0;

View file

@ -1,138 +0,0 @@
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: ogp_agent
# Required-Start: $all
# Required-Stop: $all
# Should-Start: $all
# Should-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop the OGP Agent
# Description: Start and stop the OGP Agent
### END INIT INFO
#
agent_dir=OGP_AGENT_DIR
agent_user=OGP_USER
#
# main()
#
if [ "X`whoami`" != "Xroot" ]
then
exit 1
fi
start() {
if [ -e "$agent_dir/ogp_agent_run.pid" ]
then
pid=$(cat $agent_dir/ogp_agent_run.pid)
out=$(kill -0 $pid > /dev/null 2>&1)
if [ $? == 0 ]
then
return 1
fi
fi
# Lets the agent user to use sudo to enable FTP accounts and use renice and taskset.
if [ "$( groups $agent_user | grep "\bsudo\b" )" == "" ]
then
if [ "$( egrep -i "^sudo" /etc/group )" == "" ]
then
groupadd sudo >/dev/null 2>&1
fi
usermod -aG sudo $agent_user >/dev/null 2>&1
fi
user_id=$(id -u $agent_user)
group_id=$(id -g $agent_user)
out=$(chown -Rf $user_id:$group_id $agent_dir >/dev/null 2>&1)
# Lets the agent user to attach screens.
if [ "$(groups $agent_user|grep -o "\stty\s")" == "" ]
then
usermod -aG tty $agent_user >/dev/null 2>&1
fi
out=$(chmod g+rw /dev/pts/* >/dev/null 2>&1)
out=$(chmod g+rw /dev/tty* >/dev/null 2>&1)
# Check the FTP status
if [ -f "/etc/init.d/pure-ftpd" ] && [ -d "/etc/pure-ftpd/conf" ]
then
echo no > /etc/pure-ftpd/conf/PAMAuthentication
echo no > /etc/pure-ftpd/conf/UnixAuthentication
echo yes > /etc/pure-ftpd/conf/CreateHomeDir
if [ ! -f /etc/pure-ftpd/pureftpd.passwd ]
then
touch /etc/pure-ftpd/pureftpd.passwd
fi
if [ ! -f /etc/pureftpd.passwd ]
then
ln -s /etc/pure-ftpd/pureftpd.passwd /etc/pureftpd.passwd
fi
if [ ! -f /etc/pure-ftpd/auth/50pure ]
then
ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/50pure
fi
if [ ! -f /etc/pureftpd.pdb ]
then
ln -s /etc/pure-ftpd/pureftpd.pdb /etc/pureftpd.pdb
fi
out=$(pure-pw mkdb >/dev/null 2>&1)
out=$(service pure-ftpd force-reload >/dev/null 2>&1)
fi
cd $agent_dir
out=$(su -c "screen -d -m -t ogp_agent -c ogp_screenrc -S ogp_agent ./ogp_agent_run -pidfile ogp_agent_run.pid" $agent_user >/dev/null 2>&1)
return 0
}
stop() {
if [ -e "$agent_dir/ogp_agent_run.pid" ]
then
pid=$(cat $agent_dir/ogp_agent_run.pid)
kill -0 $pid > /dev/null 2>&1
if [ $? == 0 ]
then
kill $pid >/dev/null 2>&1
return $?
fi
else
return 1
fi
return 0
}
case "${1:-''}" in
'start')
start
RETVAL=$?
;;
'stop')
stop
RETVAL=$?
;;
'restart')
stop
sleep 1
start
RETVAL=$?
;;
*)
echo "Usage: service ogp_agent start|stop|restart"
exit 1
;;
esac
if [ ! -z "$RETVAL" ]; then
exit $RETVAL
else
exit 1
fi

View file

@ -1,25 +0,0 @@
#!/sbin/runscript
# Distributed under the terms of the GNU General Public License v2
# GF: Config is in $agent_dir/Cfg/Config.pm
agent_dir=OGP_AGENT_DIR
agent_user=OGP_USER
depend() {
need net
}
start() {
ebegin "Starting OGP Agent"
start-stop-daemon --verbose --chdir $agent_dir --start --background --user $agent_user -e PWD="$agent_dir" --exec screen -d -m -t ogp_agent -c ogp_screenrc -S ogp_agent ./ogp_agent_run -pidfile ogp_agent_run.pid
eend $? "Failed to start OGP Agent"
}
stop() {
ebegin "Stopping OGP Agent"
start-stop-daemon --stop --quiet --pidfile $agent_dir/ogp_agent_run.pid
eend $? "Failed to stop OGP Agent"
}

View file

@ -1,153 +0,0 @@
#!/bin/sh
#
# Startup/shutdown script for the OGP Agent.
#
# Linux chkconfig stuff:
#
# chkconfig: 2345 88 10
# description: Startup/shutdown script for the OGP Agent
agent_dir=OGP_AGENT_DIR
agent_user=OGP_USER
service=ogp_agent
# Source function library.
if [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
elif [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
fi
if [ "$( whoami )" != "root" ]
then
if [ -f "/usr/bin/sudo" ] && [ "$( groups $agent_user | grep "\bsudo\b" )" != "" ]
then
sudo /etc/init.d/ogp_agent ${1:-''}
exit
else
echo "Permission denied."
exit
fi
fi
start() {
echo -n "Starting OGP Agent: "
if [ -e "$agent_dir/ogp_agent_run.pid" ]; then
PID=`cat $agent_dir/ogp_agent_run.pid`
RET=$(kill -s 0 $PID &> /dev/null; echo $?)
if [ $RET -eq 0 ]; then
echo -n "already running."
return 1
fi
fi
# Lets the agent user to use sudo to enable FTP accounts and use renice and taskset.
if [ "$( cat /etc/group | grep "^sudo" )" == "" ]
then
groupadd sudo &> /dev/null
fi
if [ "$( cat /etc/sudoers | grep "^%sudo" )" == "" ]
then
echo '%sudo ALL=(ALL) ALL' >> /etc/sudoers
fi
if [ "$( groups $agent_user | grep "\bsudo\b" )" == "" ]
then
usermod -a -G sudo $agent_user &> /dev/null
fi
group=`groups $agent_user | awk '{ print $3 }'`;
# Had to add the "|| true" part to the end of the below command due to chown causing the entire bash script to exit on failure in case of protected files (that have chattr +i applied)
# http://unix.stackexchange.com/questions/118217/chmod-silent-mode-how-force-exit-code-0-in-spite-of-error
chown -Rf $agent_user:$group $agent_dir &> /dev/null || true
# Lets the agent user to attach screens.
if [ "$( groups $agent_user | grep "\btty\b" )" == "" ]
then
usermod -a -G tty $agent_user &> /dev/null
fi
chmod g+rw /dev/pts/* &> /dev/null
chmod g+rw /dev/tty* &> /dev/null
# Give access for ifconfig to the user of the agent
if [ ! -f /usr/bin/ifconfig ]
then
ln -s /sbin/ifconfig /usr/bin/ifconfig
fi
# Check the FTP status
if [ -f "/etc/init.d/pure-ftpd" ]
then
if [ "$( cat /etc/pure-ftpd/pure-ftpd.conf | grep "^PureDB" )" == "" ]
then
sed -i 's|.*PureDB.*|PureDB /etc/pure-ftpd/pureftpd.pdb|' /etc/pure-ftpd/pure-ftpd.conf
sed -i 's|.*BrokenClientsCompatibility.*|BrokenClientsCompatibility yes|' /etc/pure-ftpd/pure-ftpd.conf
sed -i 's|.*NoAnonymous.*|NoAnonymous yes|' /etc/pure-ftpd/pure-ftpd.conf
sed -i 's|.*PAMAuthentication.*|PAMAuthentication no|' /etc/pure-ftpd/pure-ftpd.conf
sed -i 's|.*CreateHomeDir.*|CreateHomeDir yes|' /etc/pure-ftpd/pure-ftpd.conf
pure-pw mkdb &> /dev/null
service pure-ftpd restart &> /dev/null
fi
PURE_STATUS=`service pure-ftpd status`
if test $? -ne 0
then
service pure-ftpd restart &> /dev/null
fi
fi
cd $agent_dir
su -c "screen -d -m -t ogp_agent -c ogp_screenrc -S ogp_agent ./ogp_agent_run -pidfile ogp_agent_run.pid" $agent_user &> $agent_dir/ogp_agent.svc &
echo -n "started successfully."
bold=`tput bold`
normal=`tput sgr0`
echo
echo "Use ${bold}sudo su -c 'screen -S ogp_agent -r' $agent_user${normal} to attach the agent screen,"
echo "and ${bold}ctrl+A+D${normal} to detach it."
return 0
}
stop() {
# Stop daemon
echo -n "Stopping OGP Agent: "
if [ -f $agent_dir/ogp_agent_run.pid ]
then
PID=`cat $agent_dir/ogp_agent_run.pid`
RET=$(kill $PID &> /dev/null; echo $?)
if [ $RET -ne 0 ]; then
echo -n "not running."
else
echo -n "stopped successfully."
fi
else
echo -n "PID file not found ($agent_dir/ogp_agent_run.pid)"
fi
echo
return 0
}
case "$1" in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
restart)
stop
${!}
start
RETVAL=$?
;;
*)
echo "Usage: service ogp_agent start|stop|restart"
RETVAL=1
echo
;;
esac
exit $RETVAL