mirror of https://github.com/infosecn1nja/HELK.git
Minor improvements
parent
596bd4cdb8
commit
4dce1883a2
|
@ -11,17 +11,31 @@ REBUILD_NEEDED=0
|
|||
|
||||
echo -e "[HELK-UPDATE-INFO] CHECKING FOR UPDATES..."
|
||||
|
||||
if [ -x "$(command -v python)" ]; then
|
||||
echo "Python is available" >> $LOGFILE
|
||||
else
|
||||
echo "Python is not available" >> $LOGFILE
|
||||
apt-get update >> $LOGFILE 2>&1 && apt-get -qqy install python >> $LOGFILE 2>&1
|
||||
ERROR=$?
|
||||
if [ $ERROR -ne 0 ]; then
|
||||
echoerror "Could not install Python (Error Code: $ERROR)."
|
||||
exit 1
|
||||
fi
|
||||
echo "Python installed." >> $LOGFILE
|
||||
fi
|
||||
|
||||
for image in $HELK_IMAGES
|
||||
do
|
||||
TAG=$(sudo docker images | grep $image | awk '{print $2}')
|
||||
echo -e "\nTag for $image --> $TAG" >> $LOGFILE 2>&1
|
||||
echo -e "Tag for $image --> $TAG" >> $LOGFILE 2>&1
|
||||
REMOTE_TAG="$(curl --silent "https://hub.docker.com/v2/repositories/$image/tags/" | python -c 'import sys, json; print (json.load(sys.stdin)["results"][0]["name"])')"
|
||||
[ "$TAG" = "$REMOTE_TAG" ] ; SHOULD_UPDATE=$?
|
||||
if [ $SHOULD_UPDATE == "0" ]; then
|
||||
echo "[+] $image is up to date"
|
||||
else
|
||||
REBUILD_NEEDED=1
|
||||
echo "[+] Newer tag for $image found --> $REMOTE_TAG (current: $TAG). Pulling new image."
|
||||
echo -e "[+] Newer tag for $image found --> $REMOTE_TAG (current: $TAG)."
|
||||
echo -e "[HELK-UPDATE-INFO] Stopping HELK and pulling new image for $image."
|
||||
sed -i "s|$image:$TAG|$image:$REMOTE_TAG|" docker-compose.yml
|
||||
ERROR=$?
|
||||
if [ $ERROR -ne 0 ]; then
|
||||
|
@ -29,7 +43,8 @@ do
|
|||
echo "This could happen if 2 or more images for $image with different tags exist together. Please delete the image not being used by a running HELK container and try again."
|
||||
exit 1
|
||||
fi
|
||||
docker stop $(docker ps -a -q --filter="name=$image:$TAG" --format="{{.ID}}") >> $LOGFILE 2>&1
|
||||
docker-compose stop >> $LOGFILE 2>&1
|
||||
docker-compose down >> $LOGFILE 2>&1
|
||||
docker rmi -f "$image:$TAG" >> $LOGFILE 2>&1
|
||||
fi
|
||||
done
|
||||
|
@ -40,6 +55,7 @@ get_jupyter_token(){
|
|||
sleep 1
|
||||
done
|
||||
jupyter_token="$(docker exec -ti helk-jupyter jupyter notebook list | grep -oP '(?<=token=).*(?= ::)' | awk '{$1=$1};1')" >> $LOGFILE 2>&1
|
||||
echo "[HELK-UPDATE-INFO] New Jupyter token: $jupyter_token"
|
||||
}
|
||||
|
||||
if [ $REBUILD_NEEDED == 1 ]; then
|
||||
|
@ -59,10 +75,9 @@ if [ $REBUILD_NEEDED == 1 ]; then
|
|||
echo "Could not run HELK via docker-compose (Error Code: $ERROR)."
|
||||
exit 1
|
||||
fi
|
||||
docker restart $(sudo docker ps -a -q --filter="name=helk-") >> $LOGFILE 2>&1
|
||||
get_jupyter_token
|
||||
sleep 180
|
||||
echo -e "\n[HELK-UPDATE-INFO] YOUR HELK HAS BEEN UPDATED."
|
||||
echo -e "\n[HELK-UPDATE-INFO] YOUR HELK HAS BEEN UPDATED!"
|
||||
else
|
||||
echo -e "\n[HELK-UPDATE-INFO] YOUR HELK IS ALREADY UP-TO-DATE."
|
||||
fi
|
Loading…
Reference in New Issue