testing auto updater
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 3s
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 3s
This commit is contained in:
parent
a60b3a55a6
commit
c038e372d9
@ -1,9 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
RED='\033[1;31m'
|
||||||
|
NC='\033[0m'
|
||||||
|
LIGHT_BLUE='\033[1;34m'
|
||||||
|
LIGHT_GREEN='\033[1;32m'
|
||||||
|
LIGHT_GREY='\033[0;37m'
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
# check if FILE_NAME is set
|
# check if FILE_NAME is set
|
||||||
if [ -z "$FILE_NAME" ]; then
|
if [ -z "$FILE_NAME" ]; then
|
||||||
echo "Error: FILE_NAME is not set." >&2
|
echo -e "${RED}[x] Error: FILE_NAME is not set.${NC}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -14,29 +20,29 @@ SERVER_OK=1
|
|||||||
curl -s --head $SERVER_FILE | head -n 1 | grep -E "HTTP/[12] [23].." > /dev/null
|
curl -s --head $SERVER_FILE | head -n 1 | grep -E "HTTP/[12] [23].." > /dev/null
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error: $SERVER_FILE not found." >&2
|
echo -e "${RED}[x] Error: $SERVER_FILE not found.${NC}" >&2
|
||||||
SERVER_OK=0
|
SERVER_OK=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $SERVER_OK -eq 1 ]; then
|
if [ $SERVER_OK -eq 1 ]; then
|
||||||
echo "Running auto-update..."
|
echo -e "${LIGHT_BLUE}[i] Running auto-update"
|
||||||
|
|
||||||
# Compare the local and server files sha256sum to check if an update is needed
|
# Compare the local and server files sha256sum to check if an update is needed
|
||||||
LOCAL_SHA256=$(sha256sum $FILE_NAME | awk '{print $1}')
|
LOCAL_SHA256=$(sha256sum $FILE_NAME | awk '{print $1}')
|
||||||
SERVER_SHA256=$(curl -s $SERVER_FILE | sha256sum | awk '{print $1}')
|
SERVER_SHA256=$(curl -s $SERVER_FILE | sha256sum | awk '{print $1}')
|
||||||
|
|
||||||
if [ "$LOCAL_SHA256" != "$SERVER_SHA256" ]; then
|
if [ "$LOCAL_SHA256" != "$SERVER_SHA256" ]; then
|
||||||
echo "Updating $FILE_NAME..."
|
echo -e "${LIGHT_GREY}[i] Updating $FILE_NAME${NC}"
|
||||||
|
|
||||||
curl -s -o $FILE_NAME $SERVER_FILE
|
curl -s -o $FILE_NAME $SERVER_FILE
|
||||||
echo "$FILE_NAME updated."
|
|
||||||
|
|
||||||
chmod +x $FILE_NAME
|
chmod +x $FILE_NAME
|
||||||
echo "Permissions set up."
|
echo -e "${LIGHT_GREEN}[i] $FILE_NAME updated.${NC}"
|
||||||
|
|
||||||
echo "Running updated $FILE_NAME..."
|
echo -e "${LIGHT_BLUE}[i] Running updated $FILE_NAME...${NC}"
|
||||||
./$FILE_NAME
|
./$FILE_NAME
|
||||||
exit 0
|
exit 2
|
||||||
else
|
else
|
||||||
echo "$FILE_NAME is up to date.."
|
echo -e "${LIGHT_GREEN}[i] $FILE_NAME is already up to date.${NC}"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
@ -1,11 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
### AUTO-UPDATER ###
|
### AUTO-UPDATER ###
|
||||||
FILE_NAME="docker-updater.sh"
|
export FILE_NAME="docker-updater.sh"
|
||||||
SERVER_AU="https://git.ivanch.me/ivanch/server-scripts/raw/branch/main/auto-updater.sh"
|
SERVER_AU="https://git.ivanch.me/ivanch/server-scripts/raw/branch/main/auto-updater.sh"
|
||||||
|
|
||||||
# Run auto-updater script
|
# Run auto-updater script
|
||||||
curl -sSL $SERVER_AU | bash
|
UPDATER=$(curl -sSL $SERVER_AU | bash)
|
||||||
|
|
||||||
|
if [ $? -eq 2 ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
####################
|
####################
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user