|
@@ -7,6 +7,13 @@
|
|
|
#
|
|
#
|
|
|
# The ogp_agent_run script should be at the top level of the agent tree
|
|
# The ogp_agent_run script should be at the top level of the agent tree
|
|
|
# Make sure we are in that directory since the script assumes this is the case
|
|
# Make sure we are in that directory since the script assumes this is the case
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+########################
|
|
|
|
|
+# NOTICE #
|
|
|
|
|
+########################
|
|
|
|
|
+# THIS FILE IS NOT USED FOR OGP WIN AGENT? It looks like it uses ogp_agent in BIN folder
|
|
|
|
|
+
|
|
|
AGENTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
AGENTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
BASH_PREFS_CONF="$AGENTDIR/Cfg/bash_prefs.cfg"
|
|
BASH_PREFS_CONF="$AGENTDIR/Cfg/bash_prefs.cfg"
|
|
|
chmod -Rf 770 $AGENTDIR
|
|
chmod -Rf 770 $AGENTDIR
|
|
@@ -56,16 +63,8 @@ init() {
|
|
|
then
|
|
then
|
|
|
AUTO_UPDATE="yes"
|
|
AUTO_UPDATE="yes"
|
|
|
fi
|
|
fi
|
|
|
-
|
|
|
|
|
- if [ -z "$sf_update_mirror" ]
|
|
|
|
|
- then
|
|
|
|
|
- MIRROR="master"
|
|
|
|
|
- else
|
|
|
|
|
- MIRROR=$sf_update_mirror
|
|
|
|
|
- fi
|
|
|
|
|
else
|
|
else
|
|
|
AUTO_UPDATE="yes"
|
|
AUTO_UPDATE="yes"
|
|
|
- MIRROR="master"
|
|
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
while test $# -gt 0; do
|
|
while test $# -gt 0; do
|
|
@@ -140,58 +139,64 @@ update() {
|
|
|
fi
|
|
fi
|
|
|
cd $AGENTDIR
|
|
cd $AGENTDIR
|
|
|
rm -Rf tmp
|
|
rm -Rf tmp
|
|
|
- CURRENT=$(cat $AGENTDIR/Cfg/Config.pm | grep version | grep -Eo '[0-9]{1,6}')
|
|
|
|
|
- REVISION=$(curl -L -b "FreedomCookie=true;path=/;expires=$expires" -s https://sourceforge.net/projects/ogpextras/rss?path=/Alternative-Snapshot\&limit=3 | grep -m 1 "title.*hldstart-code-" | grep -o -P '(?<=hldstart-code-).*(?=.zip)')
|
|
|
|
|
- if [ "$CURRENT" == "$REVISION" ]; then
|
|
|
|
|
- echo "The agent is up to date."
|
|
|
|
|
- else
|
|
|
|
|
- URL=https://${MIRROR}.dl.sourceforge.net/project/ogpextras/Alternative-Snapshot/linux-agent-${REVISION}.zip
|
|
|
|
|
- HEAD=$(curl -L --insecure -b "FreedomCookie=true;path=/;expires=$expires" -Os --head -w "%{http_code}" "$URL")
|
|
|
|
|
- if [ "$HEAD" == "200" ]; then
|
|
|
|
|
- echo "Updating agent using curl."
|
|
|
|
|
- curl -L --insecure -b "FreedomCookie=true;path=/;expires=$expires" -Os $URL
|
|
|
|
|
- if test $? -ne 0; then
|
|
|
|
|
- echo "`date`: curl failed to download the update package."
|
|
|
|
|
- else
|
|
|
|
|
- unzip -oq linux-agent-${REVISION}.zip
|
|
|
|
|
|
|
+ CURRENT=$(cat $AGENTDIR/Cfg/Config.pm | grep version | egrep -o "([a-f0-9]{40})")
|
|
|
|
|
+ REVISION=`curl -L -k -s https://github.com/OpenGamePanel/OGP-Agent-Windows/commits/master.atom | egrep -o "([a-f0-9]{40})" | awk 'NR==1{print $1}'`
|
|
|
|
|
+ if [ ! -z "$REVISION" ]; then
|
|
|
|
|
+ if [ "$CURRENT" == "$REVISION" ]; then
|
|
|
|
|
+ echo "The agent is up to date."
|
|
|
|
|
+ else
|
|
|
|
|
+ URL=https://github.com/OpenGamePanel/OGP-Agent-Windows/archive/master.zip
|
|
|
|
|
+ HEAD=$(curl -LOks --head -w "%{http_code}" "$URL")
|
|
|
|
|
+ if [ "$HEAD" == "200" ]; then
|
|
|
|
|
+ echo "Updating agent using curl."
|
|
|
|
|
+ curl -LOks "$URL"
|
|
|
if test $? -ne 0; then
|
|
if test $? -ne 0; then
|
|
|
- echo "`date`: Unable to unzip the update package."
|
|
|
|
|
- echo "cleaning up..."
|
|
|
|
|
- rm -Rf linux-agent-* &> /dev/null
|
|
|
|
|
|
|
+ echo "`date`: curl failed to download the update package."
|
|
|
else
|
|
else
|
|
|
- cd linux-agent-${REVISION}
|
|
|
|
|
- cp -avf Schedule Time FastDownload php-query ogp_agent.pl ogp_screenrc ogp_agent_run agent_conf.sh $AGENTDIR &> /dev/null
|
|
|
|
|
|
|
+ unzip -oq master.zip
|
|
|
if test $? -ne 0; then
|
|
if test $? -ne 0; then
|
|
|
- echo "`date`: The agent files cannot be overwritten."
|
|
|
|
|
- echo "Cleaning up..."
|
|
|
|
|
- cd ..
|
|
|
|
|
|
|
+ echo "`date`: Unable to unzip the update package."
|
|
|
|
|
+ echo "cleaning up..."
|
|
|
rm -Rf linux-agent-* &> /dev/null
|
|
rm -Rf linux-agent-* &> /dev/null
|
|
|
- echo "Agent update failed."
|
|
|
|
|
else
|
|
else
|
|
|
- if test ! -d "$AGENTDIR/IspConfig"; then
|
|
|
|
|
- cp -Rf IspConfig $AGENTDIR/IspConfig &> /dev/null
|
|
|
|
|
- fi
|
|
|
|
|
- if test ! -d "$AGENTDIR/EHCP"; then
|
|
|
|
|
- cp -Rf EHCP $AGENTDIR/EHCP &> /dev/null
|
|
|
|
|
- fi
|
|
|
|
|
- if test ! -f "$AGENTDIR/Cfg/Preferences.pm"; then
|
|
|
|
|
- cp -f Cfg/Preferences.pm $AGENTDIR/Cfg/Preferences.pm &> /dev/null
|
|
|
|
|
|
|
+ if [ -e "OGP-Agent-Windows-master/OGP" ]; then
|
|
|
|
|
+ cd OGP-Agent-Windows-master/OGP
|
|
|
|
|
+ cp -avf Schedule Time FastDownload php-query ogp_agent.pl ogp_screenrc ogp_agent_run agent_conf.sh $AGENTDIR &> /dev/null
|
|
|
|
|
+ if test $? -ne 0; then
|
|
|
|
|
+ echo "`date`: The agent files cannot be overwritten."
|
|
|
|
|
+ echo "Cleaning up..."
|
|
|
|
|
+ cd ..
|
|
|
|
|
+ cd ..
|
|
|
|
|
+ rm -Rf OGP-Agent-Windows* &> /dev/null
|
|
|
|
|
+ echo "Agent update failed."
|
|
|
|
|
+ else
|
|
|
|
|
+ if test ! -d "$AGENTDIR/IspConfig"; then
|
|
|
|
|
+ cp -Rf IspConfig $AGENTDIR/IspConfig &> /dev/null
|
|
|
|
|
+ fi
|
|
|
|
|
+ if test ! -d "$AGENTDIR/EHCP"; then
|
|
|
|
|
+ cp -Rf EHCP $AGENTDIR/EHCP &> /dev/null
|
|
|
|
|
+ fi
|
|
|
|
|
+ if test ! -f "$AGENTDIR/Cfg/Preferences.pm"; then
|
|
|
|
|
+ cp -f Cfg/Preferences.pm $AGENTDIR/Cfg/Preferences.pm &> /dev/null
|
|
|
|
|
+ fi
|
|
|
|
|
+ echo "Fixing permissions..."
|
|
|
|
|
+ chmod ug+x $AGENTDIR/ogp_agent.pl &> /dev/null
|
|
|
|
|
+ chmod ug+x $AGENTDIR/ogp_agent_run &> /dev/null
|
|
|
|
|
+ chmod ug+x $AGENTDIR/agent_conf.sh &> /dev/null
|
|
|
|
|
+ echo "Cleaning up..."
|
|
|
|
|
+ cd ..
|
|
|
|
|
+ cd ..
|
|
|
|
|
+ rm -Rf OGP-Agent-Windows* &> /dev/null
|
|
|
|
|
+ sed -i "s/version.*/version => 'v${REVISION}',/" $AGENTDIR/Cfg/Config.pm
|
|
|
|
|
+ echo "Agent updated successfully."
|
|
|
|
|
+ fi
|
|
|
fi
|
|
fi
|
|
|
- echo "Fixing permissions..."
|
|
|
|
|
- chmod ug+x $AGENTDIR/ogp_agent.pl &> /dev/null
|
|
|
|
|
- chmod ug+x $AGENTDIR/ogp_agent_run &> /dev/null
|
|
|
|
|
- chmod ug+x $AGENTDIR/agent_conf.sh &> /dev/null
|
|
|
|
|
- echo "Cleaning up..."
|
|
|
|
|
- cd ..
|
|
|
|
|
- rm -Rf linux-agent-* &> /dev/null
|
|
|
|
|
- sed -i "s/version.*/version => 'v${REVISION}',/" $AGENTDIR/Cfg/Config.pm
|
|
|
|
|
- echo "Agent updated successfully."
|
|
|
|
|
fi
|
|
fi
|
|
|
fi
|
|
fi
|
|
|
|
|
+ else
|
|
|
|
|
+ echo "There is a update available (${REVISION}) but the download source is not ready.";
|
|
|
|
|
+ echo "Try again later."
|
|
|
fi
|
|
fi
|
|
|
- else
|
|
|
|
|
- echo "There is a update available (${REVISION}) but the download source is not ready.";
|
|
|
|
|
- echo "Try again later."
|
|
|
|
|
fi
|
|
fi
|
|
|
fi
|
|
fi
|
|
|
else
|
|
else
|