|
|
@@ -149,33 +149,32 @@ checkDepends() {
|
|
|
}
|
|
|
|
|
|
update() {
|
|
|
- # Run the update
|
|
|
+ # Run the git update
|
|
|
if test -n "$AUTO_UPDATE"; then
|
|
|
- if [ -z "$CURL" -o -z "$UNZIP" ]; then
|
|
|
+ if [ -z "$CURL" -o -z "$UNZIP" -o -z "$GIT" ]; then
|
|
|
checkDepends
|
|
|
fi
|
|
|
- if [ -f "$CURL" -a -x "$CURL" ] && [ -f "$UNZIP" -a -x "$UNZIP" ]; then
|
|
|
+ if [ -f "$CURL" -a -x "$CURL" ] && [ -f "$UNZIP" -a -x "$UNZIP" ] && [ -f "$GIT" -a -x "$GIT" ]; then
|
|
|
cd $AGENTDIR
|
|
|
if [ ! -d tmp ]; then
|
|
|
mkdir tmp
|
|
|
fi
|
|
|
cd tmp
|
|
|
- REPONAME=OGP-Agent-Linux
|
|
|
+ REPONAME=OGP-Agent-Windows
|
|
|
REVISION=`git ls-remote --heads https://github.com/OpenGamePanel/${REPONAME}.git | grep -owE "^[^?\s]+"`
|
|
|
- curl -Os https://raw.githubusercontent.com/OpenGamePanel/${REPONAME}/${REVISION}/ogp_agent_run
|
|
|
- diff ./ogp_agent_run $AGENTDIR/ogp_agent_run &>/dev/null
|
|
|
+ curl -Os https://raw.githubusercontent.com/OpenGamePanel/${REPONAME}/${REVISION}/bin/ogp_agent
|
|
|
+ diff ./ogp_agent /bin/ogp_agent &>/dev/null
|
|
|
if test $? -ne 0; then
|
|
|
- cp -f ./ogp_agent_run $AGENTDIR/ogp_agent_run &> /dev/null
|
|
|
+ cp -f ./ogp_agent /bin/ogp_agent &> /dev/null
|
|
|
if test $? -eq 0; then
|
|
|
- cd $AGENTDIR
|
|
|
- chmod ug+x ogp_agent_run 2>/dev/null
|
|
|
+ cd /bin
|
|
|
+ chmod ugo+x ogp_agent 2>/dev/null
|
|
|
echo "`date`: The agent updater has been changed, relaunching..."
|
|
|
rm -Rf tmp
|
|
|
- ./ogp_agent_run
|
|
|
+ /bin/ogp_agent
|
|
|
exit 0
|
|
|
fi
|
|
|
fi
|
|
|
- cd $AGENTDIR
|
|
|
CURRENT=$(cat $AGENTDIR/Cfg/Config.pm | grep version | grep -Eo '[0-9a-f]{40}')
|
|
|
if [ "$CURRENT" == "$REVISION" ]; then
|
|
|
echo "The agent is up to date."
|
|
|
@@ -195,8 +194,11 @@ update() {
|
|
|
rm -Rf ${REPONAME}-* &> /dev/null
|
|
|
else
|
|
|
cd ${REPONAME}-${REVISION}
|
|
|
- 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
|
|
|
+ cp -avf OGP/* $AGENTDIR/. &> /dev/null
|
|
|
+ CP_APP_RET=$?
|
|
|
+ cp -avf bin/* /usr/bin/. &> /dev/null
|
|
|
+ CP_BIN_RET=$?
|
|
|
+ if [ $CP_APP_RET -ne 0 -o $CP_BIN_RET -ne 0 ]; then
|
|
|
echo "`date`: The agent files cannot be overwritten."
|
|
|
echo "Cleaning up..."
|
|
|
cd ..
|
|
|
@@ -210,7 +212,6 @@ update() {
|
|
|
chmod +x $AGENTDIR/ogp_agent.pl &> /dev/null
|
|
|
chmod +x $AGENTDIR/agent_conf.sh &> /dev/null
|
|
|
chmod +x /usr/bin/ogp_agent &> /dev/null
|
|
|
- chmod +x /usr/bin/ogp_install &> /dev/null
|
|
|
echo "Cleaning up..."
|
|
|
cd ..
|
|
|
rm -Rf ${REPONAME}-* &> /dev/null
|
|
|
@@ -224,10 +225,12 @@ update() {
|
|
|
echo "Try again later."
|
|
|
fi
|
|
|
fi
|
|
|
+
|
|
|
else
|
|
|
echo "Update failed."
|
|
|
fi
|
|
|
fi
|
|
|
+
|
|
|
return 0
|
|
|
}
|
|
|
|
|
|
@@ -297,4 +300,4 @@ init $*
|
|
|
run
|
|
|
|
|
|
# Quit normally
|
|
|
-quit 0
|
|
|
+quit 0
|